List of usage examples for org.openqa.selenium By tagName
public static By tagName(String tagName)
From source file:testTheClient.java
@Test public void sortByYear() { WebElement sort = (new WebDriverWait(driver, WAIT_MAX)) .until((ExpectedCondition<WebElement>) (WebDriver d) -> { return driver.findElement(By.xpath("//*[@id=\"h_year\"]")); });/*from w ww. ja v a 2 s . c o m*/ sort.click(); WebElement table = driver.findElement(By.tagName("tbody")); List<WebElement> sortedRows = table.findElements(By.tagName("tr")); Assert.assertThat(sortedRows.get(0).findElements(By.tagName("td")).get(0).getText(), is("938")); Assert.assertThat(sortedRows.get(4).findElements(By.tagName("td")).get(0).getText(), is("940")); }
From source file:testTheClient.java
@Test public void verifyAlterations() throws Exception { WebElement editButton = null;/* ww w. ja va2s.co m*/ List<WebElement> rows = (new WebDriverWait(driver, WAIT_MAX)) .until((ExpectedCondition<WebElement>) (WebDriver d) -> { return d.findElement(By.tagName("tbody")); }).findElements(By.tagName("tr")); ; for (int i = 0; i < rows.size(); i++) { if (rows.get(i).findElements(By.tagName("td")).get(0).getText().equalsIgnoreCase("938")) { editButton = rows.get(i); break; } } editButton = editButton.findElements(By.tagName("td")).get(7).findElements(By.tagName("a")).get(0); //click the edit button editButton.click(); //clear description field and type coolscars WebElement element = driver.findElement(By.id("description")); element.clear(); element.sendKeys("cool cars"); driver.findElement(By.xpath("//*[@id=\"save\"]")).click(); List<WebElement> updatedRows = (new WebDriverWait(driver, WAIT_MAX)) .until((ExpectedCondition<WebElement>) (WebDriver d) -> { return d.findElement(By.tagName("tbody")); }).findElements(By.tagName("tr")); ; String newDescr = null; for (int i = 0; i < updatedRows.size(); i++) { if (updatedRows.get(i).findElements(By.tagName("td")).get(0).getText().equalsIgnoreCase("938")) { newDescr = updatedRows.get(i).findElements(By.tagName("td")).get(5).getText(); break; } } assertThat(newDescr, is("cool cars")); }
From source file:testTheClient.java
@Test public void zCreateNewCarEntry() throws Exception { (new WebDriverWait(driver, WAIT_MAX)).until((ExpectedCondition<String>) (WebDriver d) -> { return d.findElement(By.xpath("//*[@id=\"new\"]")).getText(); });/* ww w. j a v a 2 s .c om*/ //populate fields driver.findElement(By.id("new")).click(); driver.findElement(By.id("year")).sendKeys("2008"); driver.findElement(By.id("registered")).sendKeys("2002-5-5"); driver.findElement(By.id("make")).sendKeys("Kia"); driver.findElement(By.id("model")).sendKeys("Rio"); driver.findElement(By.id("description")).sendKeys("As new"); driver.findElement(By.id("price")).sendKeys("31000"); //save driver.findElement(By.id("save")).click(); List<WebElement> updatedRows = (new WebDriverWait(driver, WAIT_MAX)) .until((ExpectedCondition<WebElement>) (WebDriver d) -> { return d.findElement(By.tagName("tbody")); }).findElements(By.tagName("tr")); assertThat(updatedRows.size(), is(6)); assertThat(updatedRows.get(5).findElements(By.tagName("td")).get(1).getText(), is("2008")); assertThat(updatedRows.get(5).findElements(By.tagName("td")).get(4).getText(), is("Rio")); }
From source file:WebTestSelenium5.java
public void testElementsByTagName() { assertEquals(driver.findElements(By.tagName("input")).size(), 5); }
From source file:NewCarTest.java
private String getCarFieldValue(WebElement rowElement, int fieldNo) { return rowElement.findElements(By.tagName("td")).get(fieldNo).getText(); }
From source file:NewCarTest.java
private List<WebElement> getRowsOfCars() { WebElement table = driver.findElement(By.id("tbodycars")); return table.findElements(By.tagName("tr")); }
From source file:Filter2002Test.java
@Test public void test_1() { WebElement filter = driver.findElement(By.id("filter")); filter.sendKeys("2002"); List<WebElement> tableRows = driver.findElements(By.tagName("tr")); // asserting that if content is filtered the amount of table rows must // be three including the table header's row. assertThat(tableRows.size(), is(3)); }
From source file:Filter2002Test.java
@Test public void test_2() { WebElement filter = driver.findElement(By.id("filter")); filter.sendKeys(Keys.BACK_SPACE);/*w w w .j a v a 2 s. c o m*/ 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:WebTestSelenium10.java
public void testElementsByTagName() { assertEquals(driver.findElements(By.tagName("input")).size(), 3); }
From source file:seleniumTester.java
@Test public void test1() { (new WebDriverWait(driver, WAIT_MAX)).until((ExpectedCondition<Boolean>) (WebDriver d) -> { WebElement e = d.findElement(By.tagName("tbody")); List<WebElement> rows = e.findElements(By.tagName("tr")); return rows.size() == 5; });/*www . j a v a 2 s .c o m*/ }