-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBrowserClass.java
More file actions
55 lines (48 loc) · 2.16 KB
/
BrowserClass.java
File metadata and controls
55 lines (48 loc) · 2.16 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
package com.Centurylink.PWCM;
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.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
public class BrowserClass {
static WebDriver driver;
static String chromepath=".\\lib\\chromedriver.exe";
static String iepath=".\\lib\\IEDriverServer64.exe";
public static WebDriver browserSelection(String browserName) throws InterruptedException
{
if(browserName.equalsIgnoreCase("firefox"))
{
driver=new FirefoxDriver();
}
else if(browserName.equalsIgnoreCase("chrome"))
{
System.setProperty("webdriver.chrome.driver",chromepath);
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-extensions");
driver = new ChromeDriver(options);
}
else if(browserName.equalsIgnoreCase("ie"))
{
System.setProperty("webdriver.ie.driver",iepath);
DesiredCapabilities cap = new DesiredCapabilities().internetExplorer();//.internetExplorer();
cap.setCapability("ignoreZoomSetting", true);
cap.setCapability("ie.forceCreateProcessApi", true);
cap.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
cap.setJavascriptEnabled(true);
cap.setCapability(InternetExplorerDriver.FORCE_CREATE_PROCESS, true);
cap.setCapability(InternetExplorerDriver.IE_SWITCHES, "-private");
cap.setCapability("ie.browserCommandLineSwitches", "-private");
//cap.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL, URL);
// cap.internetExplorer().setCapability("ignoreProtectedModeSettings", true);
// cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
cap.setCapability("requireWindowFocus", true);
// cap.setCapability("enablePersistentHover", false);
cap.setCapability("ie.ensureCleanSession", true);
// cap.setCapability("nativeEvents", false);
driver = new InternetExplorerDriver(cap);
}
return driver;
}
}