-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeb99BottlesTest.java
More file actions
31 lines (23 loc) · 969 Bytes
/
Copy pathWeb99BottlesTest.java
File metadata and controls
31 lines (23 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.List;
public class Web99BottlesTest {
@Test(invocationCount = 10)
public void test99Bottles() {
WebDriver driver = new ChromeDriver();
int expectedResult = 100;
driver.get("https://www.99-bottles-of-beer.net");
driver.findElement(By.xpath("//ul[@id='menu']//a[@href='/']")).click();
driver.findElement(By.linkText("Song Lyrics")).click();
/* partial locator can be used as well
driver.findElement(By.partialLinkText("Song")).click(); */
List<WebElement> elements = driver.findElements(By.xpath("//div[@id='main']//p"));
int actualResult = elements.size();
Assert.assertEquals(actualResult, expectedResult);
driver.quit();
}
}