List of usage examples for org.openqa.selenium By id
public static By id(String id)
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 o m }); }
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 w ww .j av a 2 s. com (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();//from w w w .j a v a2s.co 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 w w w . j a v a2s . c o m*/ 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_6() { driver.findElement(By.id("new")).click(); driver.findElement(By.id("save")).click(); int size = driver.findElement(By.id("tbodycars")).findElements(By.cssSelector("tr")).size(); String errorMsg = driver.findElement(By.id("submiterr")).getText(); assertThat(errorMsg, is("All fields are required")); assertThat(size, is(5));// ww w . ja v a 2 s .c o m }
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));//w w w . j a v a 2s.co m 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:WebTestSelenium1.java
public void testTagNameById() { assertEquals(driver.findElement(By.id("p10500896")).getTagName(), "img"); }
From source file:WebTestSelenium1.java
public void testAttribute() { assertEquals(driver.findElement(By.id("p10500896")).getAttribute("alt"), "gil fried"); }
From source file:WebTestSelenium1.java
public void testIsEnabled() { assertEquals(driver.findElement(By.id("p10500896")).isEnabled(), true); }
From source file:WebTestSelenium1.java
public void testIsSelected() { assertEquals(driver.findElement(By.id("p8065520")).isSelected(), false); }