forked from Sonal0409/8PMJulyBatchJava-SeleniumPrograms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinksDemo.java
More file actions
58 lines (23 loc) · 1.25 KB
/
LinksDemo.java
File metadata and controls
58 lines (23 loc) · 1.25 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package seleniumScripts;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class LinksDemo {
// Links , LinkText locator
// isEnabled(), isDisplayed, clear() , isSelected()
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "C:\\Users\\vishal mittal\\Downloads\\chromedriver_win32 (12)\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize(); // maximize the browser window
driver.manage().deleteAllCookies(); // delete cookies on the browser
driver.get("https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&returnto=Selenium+%28software%29");
// Links: basic action on link: click, if we click on a link we will be redirected to a new page
// in order to find a link we will use a linkText locator
driver.findElement(By.linkText("Main page")).click();
// to check if we have landed on the correct page or not?
System.out.println(driver.getTitle());
// partialLinkText -- is also applicable to links
driver.findElement(By.partialLinkText("anyone")).click();
}
}