Example usage for org.openqa.selenium WebElement submit

List of usage examples for org.openqa.selenium WebElement submit

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement submit.

Prototype

void submit();

Source Link

Document

If this current element is a form, or an element within a form, then this will be submitted to the remote server.

Usage

From source file:eu.jasha.portaltests.pages.Portal.java

License:Apache License

public void login(String username, String password) {
    final WebElement loginForm = getLoginForm();
    loginForm.findElement(By.id("usernameField")).sendKeys(username);
    loginForm.findElement(By.id("passwordField")).sendKeys(password);
    loginForm.submit();
}

From source file:eu.jasha.portaltests.pages.Portal.java

License:Apache License

public void openIdLogin(String openIdUrl) {
    final WebElement openIdLogin = getOpenIdLoginForm();
    openIdLogin.findElement(By.id("openid_identifier")).sendKeys(openIdUrl);
    openIdLogin.submit();
}

From source file:eu.jasha.portaltests.steps.DefaultAccountSteps.java

License:Apache License

@When("I provide my OpenID password \"$openIdPassword\"")
public void loginToOpenIdProvider(String openIdPassword) {
    final WebElement openIdLoginForm = portal.findElement(By.id("password-signin-form"));
    openIdLoginForm.findElement(By.id("password")).sendKeys(openIdPassword);
    openIdLoginForm.submit();
}

From source file:eu.jasha.portaltests.steps.DeleteNewUserSteps.java

License:Apache License

@When("I search for username \"$newuser\"")
public void searchForNewUser(String newuser) {
    WebElement searchForm = portal.findElement(By.id("userSearchForm"));
    searchForm.findElement(By.id("searchTerm")).sendKeys(newuser);
    searchForm.submit();
}

From source file:eu.jasha.portaltests.steps.DeleteNewUserSteps.java

License:Apache License

@When("I delete the the user \"$newuser\"")
public void deleteNewUser() {
    WebElement deleteUserProfileForm = portal.findElement(By.id("deleteUserProfile"));
    //Click the checkbox to confirm the deletion.
    deleteUserProfileForm.findElement(By.id("confirmdelete")).click();
    deleteUserProfileForm.submit();
}

From source file:eu.jasha.portaltests.steps.NewUserSteps.java

License:Apache License

@When("I fill in the login form with username \"$username\" password \"$password\"")
public void login(String username, String password) {
    final WebElement loginForm = portal.getLoginForm();
    loginForm.findElement(By.id("usernameField")).sendKeys(username);
    loginForm.findElement(By.id("passwordField")).sendKeys(password);
    loginForm.submit();
}

From source file:examples.tutorial.WeatherTestCase.java

License:Apache License

@Test
@RunAsClient//from w  w  w. ja v a 2  s  .  c om
public void testWeather5() throws Exception {
    URL url = getApplicationURL("weather5");
    driver.get(url.toString());
    WebElement locationElt = driver.findElement(By.cssSelector("input[name='location']"));
    locationElt.sendKeys("bastia");
    locationElt.submit();
    WebElement body = driver.findElement(By.tagName("body"));
    assertTrue(body.getText().contains("temperature in bastia"));
    assertTrue(body.getText().contains("10 degrees"));
}

From source file:facebookfriendsoffriends.FacebookFriendsOfFriends.java

public void login() {
    this.driver.get(this.facebookUrl);
    try {/*from  w  w  w  .  j  av a  2 s . c o m*/
        Thread.sleep(1000);
    } catch (Exception e) {

    }
    this.driver.navigate().refresh();

    WebElement userName = driver.findElement(By.name("email"));
    WebElement password = driver.findElement(By.name("pass"));

    //        try{
    //            Thread.sleep(2000);
    //        }
    //        catch(Exception e){
    //            
    //        }

    userName.sendKeys(this.userName);
    password.sendKeys(this.password);
    password.submit();
    try {
        Thread.sleep(2000);
    } catch (Exception ex) {

    }

    List<WebElement> buttons = driver.findElements(By.tagName("a"));
    WebElement not_now = buttons.get(buttons.size() - 2);
    System.out.println("found " + not_now.getText());
    not_now.click();

}

From source file:GlennsPack.GlennWebAPI.Example.java

License:Open Source License

public static void testGoogleSearch() {
    // Optional, if not specified, WebDriver will search your path for chromedriver.
    System.setProperty("webdriver.chrome.driver", "C:/Users/Glenn/Downloads/chromedriver/chromedriver.exe");

    WebDriver driver = new ChromeDriver();
    driver.get("http://whatismybrowser.com");
    try {//from w w w . j  a v  a  2s  .co m
        Thread.sleep(5000);
    } catch (InterruptedException e) {
        // FIXME Auto-generated catch block
        e.printStackTrace();
    } // Let the user actually see something!
    WebElement searchBox = driver.findElement(By.name("q"));
    searchBox.sendKeys("ChromeDriver");
    searchBox.submit();
    try {
        Thread.sleep(5000);
    } catch (InterruptedException e) {
        // FIXME Auto-generated catch block
        e.printStackTrace();
    } // Let the user actually see something!
    driver.quit();
}

From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.login.LoginHandler21.java

License:Apache License

public boolean shouldProcessURL(String URL) {
    System.out.print("============SELENIUM=================");
    System.out.println("DEBUG:::::" + URL);
    System.setProperty("webdriver.firefox.bin", "/Applications/Firefox.app/Contents/MacOS/firefox");
    WebDriver driver = new FirefoxDriver();

    // And now use this to visit Google
    driver.get(URL);/*from ww w  .  ja  v  a  2s.  co  m*/
    try {

        String url1, url2, url3, url4;

        url1 = "www.arguntrader.com/ucp.php?mode=login";
        url2 = "www.buyusedguns.net/login.php";
        url3 = "www.hawaiiguntrader.com/login/";
        url4 = "www.gunidaho.com/site/login.htm";

        WebElement username;
        WebElement password;
        WebElement submit;

        if (URL.contains(url1)) {
            System.out.println(url1
                    + " :***************************login page***********************************************8");
            username = driver.findElement(By.id("username"));
            username.sendKeys("bhanuprasad");
            password = driver.findElement(By.id("password"));
            password.sendKeys("lasvegas");
            submit = driver.findElement(By.name("login"));
            submit.submit();
        } else if (URL.contains(url2)) {
            System.out.println(url2
                    + " :***************************login page***********************************************8");
            username = driver.findElement(By.id("username"));
            username.sendKeys("bhanuirprasadir");
            password = driver.findElement(By.id("password"));
            password.sendKeys("bhanu@prasad");
            submit = driver.findElement(By.id("submit"));
            submit.submit();
        }

        else if (URL.contains(url3)) {
            System.out.println(url3
                    + " :***************************login page***********************************************8");
            username = driver.findElement(By.id("login_username"));
            username.sendKeys("bhanuir.prasadir@gmail.com");
            password = driver.findElement(By.id("login_password"));
            password.sendKeys("bhanu@prasad");
            submit = driver.findElement(By.id("login"));
            submit.submit();
        }

        else if (URL.contains(url4)) {
            System.out.println(url4
                    + " :***************************login page***********************************************8");
            username = driver.findElement(By.id("User_email"));
            username.sendKeys("bhanuir.prasadir@gmail.com");
            password = driver.findElement(By.id("User_password"));
            password.sendKeys("vcytaybmabzk");
            submit = driver.findElement(By.name("btnLogin"));
            submit.submit();
        } else if (URL.contains("page")) {
            System.out.println(URL
                    + " :************************pagination page***********************************************8");
            if (URL.contains("http://www.shooting.org/"))
                driver.findElement(By.xpath("//a[@rel='next']"));
            else if (URL.contains("https://www.alphacatarmory.com/"))
                driver.findElement(By.className("next"));

            else if (URL.contains("http://www.budsgunshop.com/catalog/"))
                driver.findElement(By.xpath("//a[@class='pageResults' and  @title=' Next Page ']"));
        } else if ((URL.contains("www.store.kimberamerica.com/customer/account/login"))
                || (URL.contains("www.palmettostatearmory.com/index.php/customer/account/login/"))
                || (URL.contains("www.osagecountyguns.com/customer/account/login/"))
                || (URL.contains("www.sogknives.com/customer/account/login/"))
                || (URL.contains("www.budsgunshop.com/catalog/login.php"))) {
            System.out.println(
                    "***************************login page***********************************************8");
            WebElement email_element = driver.findElement(By.id("email"));
            email_element.sendKeys("las567vegas@gmail.com");
            WebElement pass_element = driver.findElement(By.id("pass"));
            pass_element.sendKeys("lasvegas");
            WebElement submit_element = driver.findElement(By.id("send2"));
            submit_element.submit();
        }

    } catch (Exception e) {
        driver.quit();
        System.out.println("In exception!!!" + e);

    }
    return true;
}