Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berkdulger/38efc3dcd9aa4e8df528077f6974a02f to your computer and use it in GitHub Desktop.
Save berkdulger/38efc3dcd9aa4e8df528077f6974a02f to your computer and use it in GitHub Desktop.
static String theTestPageURL = "http://www.keytorc.com/seleniumTraining/findByPlayground.php";
static WebDriver driver;
@BeforeClass
public static void createDriverAndVisitTestPage(){
System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir")
+"//chromedriver" );
driver = new ChromeDriver();
driver.get(theTestPageURL);
}
@Test
public void pathNavigation(){
WebElement element = driver.findElement(By.xpath("//div[@id='div18']//a[@name='aName26']"));
assertEquals("Expected matching id", "a26", element.getAttribute("id"));
}
@Test
public void assertNumberOfParagraphs(){
List<WebElement> elements = driver.findElements(By.xpath("//p"));
int nestedCount = 0;
for(WebElement e : elements){
if(e.getText().contains("nested para")){
nestedCount++;
}
}
assertEquals(16,nestedCount);
assertEquals(41, elements.size());
}
@AfterClass
public static void closeBrowser(){
//driver.quit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment