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:sf.wicklet.ext.test.arquillian.Test01.java

License:Apache License

@Test
public void testCodec01(@ArquillianResource final URL httpContext) throws Exception {
    final StepWatch timer = new StepWatch(true);
    final TestHtmlUnitDriver driver = new TestHtmlUnitDriver();
    final URL url = new URL(httpContext, TestCodec01Page.MNT_PATH);
    // Get the login page.
    getAndRedirect(driver, timer, url);//  ww w.  ja  va  2  s.c om
    final String ret = driver.getWebResponse().getContentAsString();
    if (Test01.DEBUG.isDebug()) {
        System.out.println(ret);
    }
    Assert.assertTrue(ret, ret.matches("(?ms)^.*wIcklEtpcI\\d*-.*$"));
    final WebElement e = driver.findElementById("form");
    e.submit();
    final String title = driver.getTitle();
    if (Test01.DEBUG.isDebug()) {
        System.out.println(timer.toString("Page title is: " + title));
        System.out.println(driver.getPageSource());
    }
    Assert.assertEquals("Test", driver.getTitle());
    final List<WebElement> p1 = driver.findElementsByLinkText("Panel1");
    Assert.assertEquals(1, p1.size());
}

From source file:sf.wicklet.test.support.SeleniumTestUtil.java

License:Apache License

public static void submit(final TestHtmlUnitDriver driver, final boolean debug, final StepWatch timer,
        final WebElement button) {
    button.submit();
    if (debug) {/*from  w  ww  .j a v  a 2  s  . c  o  m*/
        debugprint(driver, debug, timer);
    }
    redirects(driver, debug, timer);
}

From source file:testSelenium.BIWebSiteTestEngine.java

@Then("^Search \"(.*?)\" from a web page with \"(.*?)\" id name$")
public void searchNameWebPAge(String names, String id) throws InterruptedException {
    WebElement searchBox = firefoxDriver.findElement(By.id(id));
    Thread.sleep(20000);/*  w  w w. j  a v  a2s  .  c o  m*/
    searchBox.sendKeys(names);
    searchBox.submit();
    Thread.sleep(20000);
    firefoxDriver.close();
}

From source file:tmn.qa.project.GitHubTestNG.java

License:Open Source License

/**
 * Use the main search field to find repositories containing the string
 * "tmn"/*from  w w  w. ja v a 2  s .  c o  m*/
 */
@Test(priority = 1)
public void repoSearchTest() {
    // Get the search field
    WebElement element = driver.findElement(By.name("q"));
    Assert.assertNotNull(element);
    Assert.assertEquals(element.getAttribute("placeholder"), "Search GitHub");
    log.info("Accessed the site search field. Placeholder text is: '" + element.getAttribute("placeholder")
            + "'.");

    // Search for the repository containing this code
    element.sendKeys("tmn");
    element.submit();
    log.info("Searched the site for 'tmn'");
}

From source file:tmn.qa.project.GitHubTestNG.java

License:Open Source License

/**
 * Search the tcpatt/tmn repository for occurrences of "TruMedia" and make
 * some assertions about the results//from w ww  . j  av  a 2 s  .c om
 */
@Test(priority = 3)
public void simpleSearchTest() {
    // Make sure we are on the correct page
    Assert.assertEquals(driver.getTitle(), "tcpatt/tmn  GitHub");
    log.info("Active page title: '" + driver.getTitle() + "'.");
    // Get the search field
    WebElement element = driver.findElement(By.name("q"));
    Assert.assertNotNull(element);
    Assert.assertEquals(element.getAttribute("placeholder"), "Search");
    Assert.assertEquals(element.getAttribute("aria-label"), "Search this repository");
    // Send the search term
    element.sendKeys("TruMedia");
    element.submit();
    log.info("Executed a simple search on the current repository " + "(tcpatt/tmn) for 'TruMedia'");
    // Check the count of files containing "TruMedia" in this repository
    element = driver.findElement(By.className("counter"));
    simpleSearchCount = element.getText();
    log.info("Found " + simpleSearchCount + " files containing " + "'TruMedia'.");
}

From source file:tmn.qa.project.GitHubTestNG.java

License:Open Source License

/**
 * Navigate to the advanced search page and enter some values into the
 * fields. Conduct the advanced search./*from   w w w . j  a v  a 2s . co  m*/
 */
@Test(priority = 5)
public void advancedSearchTest() {
    // Make sure we are on the correct page
    Assert.assertEquals(driver.getTitle(), "Search  TruMedia  GitHub");
    log.info("Active page title: '" + driver.getTitle() + "'.");
    // Find the advanced search link
    WebElement element = driver.findElement(By.linkText("Advanced search"));
    Assert.assertNotNull(element);
    element.click();
    log.info("Clicked on 'Advanced search'");
    // Edit the advanced search form
    element = driver.findElement(By.id("search_repos"));
    Assert.assertNotNull(element);
    element.sendKeys("tcpatt/tmn");
    log.info("Entered 'tcpatt/tmn' into the text field for 'In these " + "repositories'");
    Select dropdown = new Select(driver.findElement(By.id("search_language")));
    Assert.assertNotNull(dropdown);
    Assert.assertTrue(!dropdown.getOptions().isEmpty());
    dropdown.selectByValue("Java");
    log.info("Selected 'Java' in the 'Written in this language' drop down");
    element.submit();
    log.info("Searching based on the form values entered.");
    // Check the count of files containing "TruMedia" in this repository
    element = driver.findElement(By.className("counter"));
    Assert.assertEquals(element.getText(), simpleSearchCount);
    log.info("Simple search and advanced search both return " + simpleSearchCount
            + " files containing 'TruMedia'.");
}

From source file:tmn.qa.project.GitHubUsingMain.java

License:Open Source License

/**
 * Use the main search field to find repositories containing the string
 * "tmn"// ww w .ja v a2s .  c  o m
 */
private static void repoSearch() {
    // Get the search field
    WebElement element = driver.findElement(By.name("q"));
    Assert.assertNotNull(element);
    Assert.assertEquals(element.getAttribute("placeholder"), "Search GitHub");
    log.info("Accessed the site search field. Placeholder text is: '" + element.getAttribute("placeholder")
            + "'.");

    // Search for the repository containing this code
    element.sendKeys("tmn");
    element.submit();
    log.info("Searched the site for 'tmn'");
}

From source file:tmn.qa.project.GitHubUsingMain.java

License:Open Source License

/**
 * Search the tcpatt/tmn repository for occurrences of "TruMedia" and make
 * some assertions about the results/*from   www.j av a 2 s  .  co m*/
 */
private static void simpleSearch() {
    // Make sure we are on the correct page
    Assert.assertEquals(driver.getTitle(), "tcpatt/tmn  GitHub");
    log.info("Active page title: '" + driver.getTitle() + "'.");
    // Get the search field
    WebElement element = driver.findElement(By.name("q"));
    Assert.assertNotNull(element);
    Assert.assertEquals(element.getAttribute("placeholder"), "Search");
    Assert.assertEquals(element.getAttribute("aria-label"), "Search this repository");
    // Send the search term
    element.sendKeys("TruMedia");
    element.submit();
    log.info("Executed a simple search on the current repository " + "(tcpatt/tmn) for 'TruMedia'");
    // Check the count of files containing "TruMedia" in this repository
    element = driver.findElement(By.className("counter"));
    simpleSearchCount = element.getText();
    log.info("Found " + simpleSearchCount + " files containing " + "'TruMedia'.");
}

From source file:tmn.qa.project.GitHubUsingMain.java

License:Open Source License

/**
 * Navigate to the advanced search page and enter some values into the
 * fields. Conduct the advanced search.//from  w  w w.  j a  v  a 2s. c om
 */
private static void advancedSearch() {
    // Make sure we are on the correct page
    Assert.assertEquals(driver.getTitle(), "Search  TruMedia  GitHub");
    log.info("Active page title: '" + driver.getTitle() + "'.");
    // Find the advanced search link
    WebElement element = driver.findElement(By.linkText("Advanced search"));
    Assert.assertNotNull(element);
    element.click();
    log.info("Clicked on 'Advanced search'");
    // Edit the advanced search form
    element = driver.findElement(By.id("search_repos"));
    Assert.assertNotNull(element);
    element.sendKeys("tcpatt/tmn");
    log.info("Entered 'tcpatt/tmn' into the text field for 'In these " + "repositories'");
    Select dropdown = new Select(driver.findElement(By.id("search_language")));
    Assert.assertNotNull(dropdown);
    Assert.assertTrue(!dropdown.getOptions().isEmpty());
    dropdown.selectByValue("Java");
    log.info("Selected 'Java' in the 'Written in this language' drop down");
    element.submit();
    log.info("Searching based on the form values entered.");
    // Check the count of files containing "TruMedia" in this repository
    element = driver.findElement(By.className("counter"));
    Assert.assertEquals(element.getText(), simpleSearchCount);
    log.info("Simple search and advanced search both return " + simpleSearchCount
            + " files containing 'TruMedia'.");
}

From source file:uk.co.rockhoppersuk.seleniumtest.Selenium2Example.java

private void searchGoogle(final WebDriver driver, final String searchText) {

    driver.get("http://www.google.com");

    WebElement element = driver.findElement(By.name("q"));

    element.sendKeys(searchText);//from  ww  w . j  a va2s  . co m

    element.submit();

    System.out.println("Page Title is : " + driver.getTitle());

    (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
        @Override
        public Boolean apply(WebDriver d) {
            return d.getTitle().toLowerCase().startsWith(searchText.toLowerCase());
        }
    });

    System.out.println("Page Title is : " + driver.getTitle());
    driver.quit();

}