Created
April 2, 2021 09:03
-
-
Save berkdulger/38efc3dcd9aa4e8df528077f6974a02f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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