-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTest2.java
More file actions
36 lines (27 loc) · 958 Bytes
/
Test2.java
File metadata and controls
36 lines (27 loc) · 958 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
32
33
34
35
36
package javascriptexecutor;
import java.io.IOException;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
import io.github.bonigarcia.wdm.WebDriverManager;
public class Test2 {
@Test
public void demo() {
WebDriverManager.chromedriver().setup();
WebDriver driver=new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.naukri.com/");
//To refresh the page
JavascriptExecutor js=(JavascriptExecutor) driver;
js.executeScript("history.go(0)");
//To get the title of the page
String title = js.executeScript("return document.title;").toString();
System.out.println(title);
//To get the url of the page
String url = js.executeScript("return document.URL;").toString();
System.out.println(url);
//To navigate
js.executeScript("window.location='https://skillrary.com/");
}
}