Example usage for org.openqa.selenium By tagName

List of usage examples for org.openqa.selenium By tagName

Introduction

In this page you can find the example usage for org.openqa.selenium By tagName.

Prototype

public static By tagName(String tagName) 

Source Link

Usage

From source file:seleniumTester.java

@Test
public void test2() throws Exception {
    WebElement element = driver.findElement(By.id("filter"));
    element.sendKeys("1999");
    (new WebDriverWait(driver, WAIT_MAX)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {
            WebElement e = d.findElement(By.tagName("tbody"));
            List<WebElement> rows = e.findElements(By.tagName("tr"));

            return rows.size() == 2;
        }//from  w w w  . j  a  va2  s . c om
    });

}

From source file:seleniumTester.java

@Test
public void test3() {
    WebElement element = driver.findElement(By.id("filter"));
    element.sendKeys(Keys.CONTROL + "a");
    element.sendKeys(Keys.DELETE);/*from ww w. java2s. c  o m*/

    (new WebDriverWait(driver, WAIT_MAX)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {
            WebElement e = d.findElement(By.tagName("tbody"));
            List<WebElement> rows = e.findElements(By.tagName("tr"));

            Assert.assertThat(rows.size(), is(5));
            return rows.size() == 5;
        }
    });

}

From source file:seleniumTester.java

@Test
public void test_4() {
    WebElement element = driver.findElement(By.id("h_year"));
    element.click();/*www  . j av a 2 s .  c o m*/
    WebElement e = driver.findElement(By.tagName("tbody"));
    List<WebElement> rows = e.findElements(By.tagName("tr"));

    WebElement firstRow = rows.get(0);
    String firstRow_id = firstRow.findElement(By.tagName("td")).getText();
    WebElement lastRow = rows.get((rows.size() - 1));
    String lastRow_id = lastRow.findElement(By.tagName("td")).getText();

    Assert.assertThat(firstRow_id, is("938"));
    Assert.assertThat(lastRow_id, is("940"));
}

From source file:seleniumTester.java

@Test
public void test_5() {
    List<WebElement> tds = driver.findElement(By.id("tbodycars")).findElements(By.cssSelector("tr")).get(0)
            .findElements(By.tagName("td"));
    tds.get(7).findElements(By.tagName("a")).get(0).click();
    WebElement element = driver.findElement(By.id("description"));
    element.sendKeys(Keys.CONTROL + "a");
    element.sendKeys(Keys.DELETE);//from  ww  w.  jav a  2 s.  c om
    element.sendKeys("Cool car");
    driver.findElement(By.id("save")).click();

    (new WebDriverWait(driver, WAIT_MAX)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {
            WebElement e = d.findElement(By.tagName("tbody"));
            List<WebElement> rows = e.findElements(By.tagName("tr"));
            String result = null;
            for (int i = 0; i < rows.size(); i++) {
                if (rows.get(i).findElements(By.tagName("td")).get(0).getText().equalsIgnoreCase("938")) {
                    result = rows.get(i).findElements(By.tagName("td")).get(5).getText();
                    break;
                }
            }
            assertThat(result, is("Cool car"));
            return true;
        }
    });
}

From source file:seleniumTester.java

@Test
public void test_7() {
    driver.findElement(By.id("new")).click();

    driver.findElement(By.id("year")).sendKeys("1994");
    driver.findElement(By.id("registered")).sendKeys("1995-5-5");
    driver.findElement(By.id("make")).sendKeys("Ford");
    driver.findElement(By.id("model")).sendKeys("Probe GT");
    driver.findElement(By.id("description")).sendKeys("Old");
    driver.findElement(By.id("price")).sendKeys("100000");

    driver.findElement(By.id("save")).click();

    List<WebElement> cars = driver.findElement(By.tagName("tbody")).findElements(By.tagName("tr"));
    assertThat(cars.size(), is(6));/*from  ww  w .j a  va  2  s  .  c om*/

    List<WebElement> carDetails = cars.get(5).findElements(By.tagName("td"));
    assertThat(carDetails.get(1).getText(), is("1994"));
    assertThat(carDetails.get(2).getText(), is("5/5/1995"));
    assertThat(carDetails.get(3).getText(), is("Ford"));
    assertThat(carDetails.get(4).getText(), is("Probe GT"));
    assertThat(carDetails.get(5).getText(), is("Old"));
    assertThat(carDetails.get(6).getText(), is("100.000,00 kr."));
}

From source file:DataLoadedTest.java

@Test
public void isDataLoadedTest() {
    WebElement table = driver.findElement(By.id("tbodycars"));
    List<WebElement> tableRows = table.findElements(By.tagName("tr"));
    // There should be five rows of data.
    assertThat(tableRows.size(), is(5));
}

From source file:FindByLinkText.java

public static void main(String[] args) throws Exception {
    String baseURL = "http://demostore.x-cart.com/";
    System.setProperty("webdriver.gecko.driver",
            "/Users/srijana/Documents/seleniumpractise notes/geckodriver 2");
    WebDriver driver = new FirefoxDriver();

    driver.get(baseURL);/*from  w  w w .  java2  s.  c o m*/

    //driver.findElement(By.xpath(".//*[@id='header-area']/div[1]/div/div[4]/div/ul/li[4]/a/span")).click();

    //driver.findElement(By.xpath(".//*[@id='header-area']/div[1]/div/div[4]/div/ul/li[7]/a/span")).click();

    driver.findElement(By.tagName("a")).click();

}

From source file:WebTestSelenium6.java

public void testElementsByTagName() {
    assertEquals(driver.findElements(By.tagName("input")).size(), 1);
}

From source file:WebTestSelenium2.java

public void testElementsByTagName() {
    assertEquals(driver.findElements(By.tagName("input")).size(), 4);
}

From source file:SortingCarsTest.java

@Test
public void sortingCarsTest() {
    WebElement sortByYear = driver.findElement(By.id("h_year"));
    sortByYear.click();//from   w  w w .  j  a  v  a  2  s . com
    // The table should by now have rendered and cars switched position
    WebElement tableOfCars = driver.findElement(By.id("tbodycars"));
    List<WebElement> sortedCars = tableOfCars.findElements(By.tagName("tr"));
    final String firstCar = sortedCars.get(0).findElements(By.tagName("td")).get(0).getText();
    final String lastCar = sortedCars.get(4).findElements(By.tagName("td")).get(0).getText();
    assertThat(firstCar, is("938"));
    assertThat(lastCar, is("940"));
}