forked from TalhaBinAshraf1/SeleniumTestingInternetHerokuApp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeadlessDriverTest.java
More file actions
44 lines (34 loc) · 1.29 KB
/
Copy pathHeadlessDriverTest.java
File metadata and controls
44 lines (34 loc) · 1.29 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
package allTests;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import utility.FrameworkConstants;
public class HeadlessDriverTest {
public static void main(String[] args) {
// usingHtmlUnitDriver();
// usingChromeHeadless();
usingFireFoxHeadless();
}
public static void usingChromeHeadless() {
System.setProperty(FrameworkConstants.CHROME_DRIVER_KEY,FrameworkConstants.CHROME_DRIVER_PATH);
ChromeOptions options = new ChromeOptions();
options.setHeadless(true);
WebDriver driver = new ChromeDriver(options);
driver.get("https://www.google.co.in");
System.out.println(driver.getCurrentUrl());
driver.quit();
}
public static void usingFireFoxHeadless() {
System.setProperty(FrameworkConstants.FIREFOX_DRIVER_KEY,FrameworkConstants.FIREFOX_DRIVER_PATH);
FirefoxOptions options = new FirefoxOptions();
// options.addArguments("--headless");
options.setHeadless(true);
WebDriver driver = new FirefoxDriver(options);
driver.get("https://www.google.co.in");
System.out.println(driver.getCurrentUrl());
driver.quit();
}
}