List of usage examples for org.openqa.selenium By id
public static By id(String id)
From source file:TestWriteanArticle.java
@org.junit.Test public void positive() throws InterruptedException { System.setProperty("webdriver.gecko.driver", "C://Users/Mari/Downloads/geckodriver.exe"); WebDriver webDriver = new FirefoxDriver(); String page = "http://www.wikihow.com/Special:CreatePage"; webDriver.get(page);/*from ww w. ja va 2 s.c o m*/ WebElement title = webDriver.findElement(By.id("cp_title_input")); title.sendKeys("how to use selenium"); webDriver.findElement(By.id("cp_title_btn")).click(); Thread.sleep(10); WebDriverWait wait = new WebDriverWait(webDriver, 50); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("cpr_title_hdr"))); assertTrue(webDriver.getPageSource().contains("Are any of these topics the same as yours?")); webDriver.close(); }
From source file:TestWriteanArticle.java
@org.junit.Test public void negative() throws InterruptedException { System.setProperty("webdriver.gecko.driver", "C://Users/Mari/Downloads/geckodriver.exe"); WebDriver webDriver = new FirefoxDriver(); String page = "http://www.wikihow.com/Special:CreatePage"; webDriver.get(page);/*from w ww. ja v a 2 s . c o m*/ WebElement title = webDriver.findElement(By.id("cp_title_input")); title.sendKeys("how to use wikiHow"); webDriver.findElement(By.id("cp_title_btn")).click(); Thread.sleep(10); WebDriverWait wait = new WebDriverWait(webDriver, 50); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("cpr_title_hdr"))); assertTrue(webDriver.getPageSource().contains("That article already exists!")); webDriver.close(); }
From source file:WebTestSelenium6.java
public void testTagNameById() { assertEquals(driver.findElement(By.id("main")).getTagName(), "div"); }
From source file:WebTestSelenium6.java
public void testAttribute() { assertEquals(driver.findElement(By.id("main")).getAttribute("alt"), null); }
From source file:WebTestSelenium6.java
public void testIsEnabled() { assertEquals(driver.findElement(By.id("main")).isEnabled(), true); }
From source file:WebTestSelenium6.java
public void testIsSelected() { assertEquals(driver.findElement(By.id("main")).isSelected(), false); }
From source file:WebTestSelenium2.java
public void testTagNameById() { assertEquals(driver.findElement(By.id("block-system-main")).getTagName(), "div"); }
From source file:WebTestSelenium2.java
public void testIsEnabled() { assertEquals(driver.findElement(By.id("discover-more")).isEnabled(), true); }
From source file:IdXPATHDemo.java
public static void main(String[] args) { String baseURL = "http://www.google.com"; System.setProperty("webdriver.gecko.driver", "/Users/srijana/Documents/seleniumpractise notes/geckodriver 2"); WebDriver driver = new FirefoxDriver(); driver.get(baseURL);//from w ww .j a v a 2s .c o m driver.findElement(By.id("lst-ib")).sendKeys("letskodeit"); driver.findElement(By.xpath("//*[@id='sblsbb']/button")).click(); }
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 a2s.c o m // 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")); }