-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindByLinkTextDemo.java
More file actions
40 lines (32 loc) · 1.03 KB
/
FindByLinkTextDemo.java
File metadata and controls
40 lines (32 loc) · 1.03 KB
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
32
33
34
35
36
37
38
39
40
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class FindByLinkTextDemo {
private WebDriver driver;
@Before
public void setUp() {
System.setProperty("webdriver.chrome.driver", "./drivers/chromedriver");
driver = new ChromeDriver();
}
@After
public void tearDown() {
driver.quit();
}
@Test
public void testFindLinkByText() {
driver.get("http://localhost:8080/workspace/links.html");
WebElement link = driver.findElement(By.linkText("Facebook"));
assertEquals("https://www.facebook.com/", link.getAttribute("href"));
}
@Test
public void testFindLinkByPartialText() {
driver.get("http://localhost:8080/workspace/links.html");
WebElement link = driver.findElement(By.partialLinkText("Digg"));
assertEquals("http://www.digg.com/", link.getAttribute("href"));
}
}