use of org.openqa.selenium.ie.InternetExplorerDriver in project jmeter-plugins by undera.
the class InternetExplorerDriverConfigTest method shouldQuitWebDriverAndStopServiceWhenQuitBrowserIsInvoked.
@Test
public void shouldQuitWebDriverAndStopServiceWhenQuitBrowserIsInvoked() throws Exception {
InternetExplorerDriver mockInternetExplorerDriver = mock(InternetExplorerDriver.class);
InternetExplorerDriverService mockService = mock(InternetExplorerDriverService.class);
when(mockService.isRunning()).thenReturn(true);
config.getServices().put(config.currentThreadName(), mockService);
config.quitBrowser(mockInternetExplorerDriver);
verify(mockInternetExplorerDriver).quit();
assertThat(config.getServices(), is(Collections.<String, InternetExplorerDriverService>emptyMap()));
verify(mockService, times(1)).stop();
}
use of org.openqa.selenium.ie.InternetExplorerDriver in project browsermator by pcalkins.
the class RunASingleTest method RunSingleTest.
public void RunSingleTest(Procedure bugtorun, ProcedureView thisbugview, String TargetBrowser, String OSType) {
STAppFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
File thisDriver = new File(WEBDRIVERSDIR + "geckodriver-win32" + File.separator + "geckodriver.exe");
switch(TargetBrowser) {
case "Firefox-Marionette":
if ("Windows".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-win32" + File.separator + "geckodriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.gecko.driver", "lib"+File.separator+"geckodriver-win32"+File.separator+"geckodriver.exe");
}
if ("Windows32".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-win32" + File.separator + "geckodriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.gecko.driver", "lib"+File.separator+"geckodriver-win32"+File.separator+"geckodriver.exe");
}
if ("Windows64".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-win64" + File.separator + "geckodriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.gecko.driver", "lib"+File.separator+"geckodriver-win64"+File.separator+"geckodriver.exe");
}
if ("Mac".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-osx" + File.separator + "geckodriver");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.gecko.driver", "lib"+File.separator+"geckodriver-osx"+File.separator+"geckodriver");
}
if ("Linux-32".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-linux32" + File.separator + "geckodriver");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.gecko.driver", "lib"+File.separator+"geckodriver-linux32"+File.separator+"geckodriver");
}
if ("Linux-64".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-linux64" + File.separator + "geckodriver");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.gecko.driver", "lib"+File.separator+"geckodriver-linux64"+File.separator+"geckodriver");
}
if (firefox_path != null) {
System.setProperty("webdriver.firefox.bin", firefox_path);
}
try {
// FirefoxProfile profile = new FirefoxProfile();
// DesiredCapabilities cap = DesiredCapabilities.firefox();
// cap.setJavascriptEnabled(true);
// cap.setCapability("marionette", false);
// profile.setPreference("dom.max_script_run_time", 1);
driver = new FirefoxDriver();
// driver = new MarionetteDriver();
} catch (Exception ex) {
System.out.println("Exception launching Marionette driver... possibly XP or missing msvcr110.dll: " + ex.toString());
Prompter fallbackprompt = new Prompter("Driver Error", "Could not launch the Marionette driver, will fallback to HTMLUnitDriver", false, 0, 0);
FallbackDriver("HTMLUnit");
}
break;
case "Firefox":
if ("Windows".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-win32" + File.separator + "geckodriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
}
if ("Windows32".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-win32" + File.separator + "geckodriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
}
if ("Windows64".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-win64" + File.separator + "geckodriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.gecko.driver", BMPATH+File.separator+"lib"+File.separator+"geckodriver-win64"+File.separator+"geckodriver.exe");
}
if ("Mac".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-osx" + File.separator + "geckodriver");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.gecko.driver", BMPATH+File.separator+"lib"+File.separator+"geckodriver-osx"+File.separator+"geckodriver");
}
if ("Linux-32".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-linux32" + File.separator + "geckodriver");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.gecko.driver",BMPATH+File.separator+ "lib"+File.separator+"geckodriver-linux32"+File.separator+"geckodriver");
}
if ("Linux-64".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "geckodriver-linux64" + File.separator + "geckodriver");
setPermissions(thisDriver);
System.setProperty("webdriver.gecko.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.gecko.driver", BMPATH+File.separator+"lib"+File.separator+"geckodriver-linux64"+File.separator+"geckodriver");
}
if (firefox_path != null) {
System.setProperty("webdriver.firefox.bin", firefox_path);
}
try {
// DesiredCapabilities cap = DesiredCapabilities.firefox();
// cap.setJavascriptEnabled(false);
// FirefoxProfile profile = new FirefoxProfile();
// DesiredCapabilities cap = DesiredCapabilities.firefox();
// cap.setJavascriptEnabled(true);
// cap.setCapability("marionette", true);
// profile.setPreference("dom.max_script_run_time", 30);
driver = new FirefoxDriver();
// driver = new MarionetteDriver();
} catch (Exception ex) {
System.out.println("Exception launching Marionette driver... possibly XP or missing msvcr110.dll: " + ex.toString());
Prompter fallbackprompt = new Prompter("Driver Error", "Could not launch the Marionette driver, will fallback to HTMLUnitDriver", false, 0, 0);
FallbackDriver("HTMLUnit");
}
break;
case "Silent Mode (HTMLUnit)":
driver = new HtmlUnitDriver();
break;
case "Internet Explorer-32":
thisDriver = new File(WEBDRIVERSDIR + "iedriverserver_win32" + File.separator + "IEDriverServer.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.ie.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.ie.driver", BMPATH+File.separator+"lib"+File.separator+"iedriverserver_win32"+File.separator+"IEDriverServer.exe");
try {
driver = new InternetExplorerDriver();
} catch (Exception ex) {
System.out.println("Exception launching Internet Explorer driver: " + ex.toString());
Prompter fallbackprompt = new Prompter("Driver Error", "Could not launch the IEdriver, will fallback to HTMLUnitDriver", false, 0, 0);
FallbackDriver("HTMLUnit");
}
break;
case "Internet Explorer-64":
thisDriver = new File(WEBDRIVERSDIR + "iedriverserver_win64" + File.separator + "IEDriverServer.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.ie.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.ie.driver",BMPATH+File.separator+ "lib"+File.separator+"iedriverserver_win64"+File.separator+"IEDriverServer.exe");
try {
driver = new InternetExplorerDriver();
} catch (Exception ex) {
System.out.println("Exception launching Internet Explorer-64 driver: " + ex.toString());
Prompter fallbackprompt = new Prompter("Driver Error", "Could not launch the IEdriver, will fallback to HTMLUnitDriver", false, 0, 0);
FallbackDriver("HTMLUnit");
}
break;
case "Chrome":
// legacy support
ChromeOptions options = new ChromeOptions();
if (chrome_main_path != null) {
options.setBinary(chrome_main_path);
}
if ("Windows".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_win32" + File.separator + "chromedriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver", BMPATH+File.separator+"lib"+File.separator+"chromedriver_win32"+File.separator+"chromedriver.exe");
}
if ("Windows32".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_win32" + File.separator + "chromedriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver", BMPATH+File.separator+"lib"+File.separator+"chromedriver_win32"+File.separator+"chromedriver.exe");
}
if ("Windows64".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_win32" + File.separator + "chromedriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver", BMPATH+File.separator+"lib"+File.separator+"chromedriver_win32"+File.separator+"chromedriver.exe");
}
if ("Mac".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_mac64" + File.separator + "chromedriver");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver", BMPATH+File.separator+"lib"+File.separator+"chromedriver_mac64"+File.separator+"chromedriver");
}
if ("Linux-32".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_linux32" + File.separator + "chromedriver");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver",BMPATH+File.separator+ "lib"+File.separator+"chromedriver_linux32"+File.separator+"chromedriver");
}
if ("Linux-64".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_linux64" + File.separator + "chromedriver");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver", BMPATH+File.separator+"lib"+File.separator+"chromedriver_linux64"+File.separator+"chromedriver");
}
try {
driver = new ChromeDriver(options);
} catch (Exception ex) {
System.out.println("Problem launching Chromedriver: " + ex.toString());
Prompter fallbackprompt = new Prompter("Driver Error", "Could not launch the Chromedriver, will fallback to HTMLUnitDriver: " + ex.toString(), false, 0, 0);
FallbackDriver("HTMLUnit");
}
break;
case "Chrome 49":
ChromeOptions options49 = new ChromeOptions();
if (chrome_path != null) {
options49.setBinary(chrome_path);
}
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_win32" + File.separator + "chromedriver-winxp.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
try {
driver = new ChromeDriver(options49);
} catch (Exception ex) {
System.out.println("Problem launching Chromedriver 49: " + ex.toString());
Prompter fallbackprompt = new Prompter("Driver Error", "Could not launch the Chrome 49 driver, will fallback to HTMLUnitDriver: " + ex.toString(), false, 0, 0);
FallbackDriver("HTMLUnit");
}
break;
case "Edge":
thisDriver = new File(WEBDRIVERSDIR + "edgedriver" + File.separator + "MicrosoftWebDriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.edge.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.edge.driver", BMPATH+File.separator+"lib"+File.separator+"edgedriver"+File.separator+"MicrosoftWebDriver.exe");
try {
driver = new EdgeDriver();
} catch (Exception ex) {
System.out.println("Problem launching EdgeDriver: " + ex.toString());
Prompter fallbackprompt = new Prompter("Driver Error", "Could not launch the Edge Driver, will fallback to HTMLUnitDriver: " + ex.toString(), false, 0, 0);
FallbackDriver("HTMLUnit");
}
break;
default:
if ("Windows".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_win32" + File.separator + "chromedriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver",BMPATH+File.separator+ "lib"+File.separator+"chromedriver_win32"+File.separator+"chromedriver.exe");
}
if ("Windows32".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_win32" + File.separator + "chromedriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver", WEBDRIVERSDIR+"chromedriver_win32"+File.separator+"chromedriver.exe");
}
if ("Windows64".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_win32" + File.separator + "chromedriver.exe");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver",BMPATH+File.separator+ "lib"+File.separator+"chromedriver_win32"+File.separator+"chromedriver.exe");
}
if ("Mac".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_mac64" + File.separator + "chromedriver");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver", BMPATH+File.separator+"lib"+File.separator+"chromedriver_mac64"+File.separator+"chromedriver");
}
if ("Linux-32".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_linux32" + File.separator + "chromedriver");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver", BMPATH+File.separator+"lib"+File.separator+"chromedriver_linux32"+File.separator+"chromedriver");
}
if ("Linux-64".equals(OSType)) {
thisDriver = new File(WEBDRIVERSDIR + "chromedriver_linux64" + File.separator + "chromedriver");
setPermissions(thisDriver);
System.setProperty("webdriver.chrome.driver", thisDriver.getAbsolutePath());
// System.setProperty("webdriver.chrome.driver", BMPATH+File.separator+"lib"+File.separator+"chromedriver_linux64"+File.separator+"chromedriver");
}
try {
driver = new ChromeDriver();
} catch (Exception ex) {
System.out.println("Problem launching Chromedriver: " + ex.toString());
Prompter fallbackprompt = new Prompter("Driver Error", "Could not launch the Chromedriver, will fallback to HTMLUnit Driver: " + ex.toString(), false, 0, 0);
FallbackDriver("HTMLUnit");
}
}
int WaitTime = 0;
WaitTime = STAppData.getWaitTime();
// timeouts still buggy.. removed
// int Timeout = SiteTest.getTimeout();
// int Timeout = 5;
// driver.manage().timeouts().implicitlyWait(Timeout, TimeUnit.SECONDS);
// driver.manage().timeouts().pageLoadTimeout(Timeout, TimeUnit.SECONDS);
// driver.manage().timeouts().setScriptTimeout(Timeout, TimeUnit.SECONDS);
int totalpause = WaitTime * 1000;
if (!"Dataloop".equals(thisbugview.Type)) {
for (Action ThisAction : bugtorun.ActionsList) {
if (STAppData.cancelled) {
publish(bugtorun.index);
break;
}
if (!ThisAction.Locked) {
try {
if (totalpause > 0) {
try {
Thread.sleep(totalpause);
} catch (Exception ex) {
System.out.println("Exception when sleeping: " + ex.toString());
ThisAction.Pass = false;
break;
}
}
String varfieldname = "";
if (ThisAction.Variable2.contains("[stored_varname-start]")) {
varfieldname = ThisAction.Variable2;
int indexof_end_tag = varfieldname.indexOf("[stored_varname-end]");
// assuming name of "[stored_varname-start]" and "[stored_varname-end]"
String fieldname = varfieldname.substring(22, indexof_end_tag);
ThisAction.Variable2 = STAppData.GetStoredVariableValue(fieldname);
ThisAction.RunAction(driver);
ThisAction.Variable2 = "[stored_varname-start]" + fieldname + "[stored_varname-end]";
} else {
if ("Pause with Continue Button".equals(ThisAction.Type)) {
int nothing = ThisAction.RunAction(driver, "Actions Paused...", STAppData, 0, 0);
} else {
ThisAction.RunAction(driver);
}
}
if (!"".equals(ThisAction.tostore_varvalue)) {
STAppData.VarHashMap.put(ThisAction.tostore_varname, ThisAction.tostore_varvalue);
}
if (ThisAction.tostore_varlist.size() > 0) {
STAppData.VarLists.put(ThisAction.Variable2, ThisAction.tostore_varlist);
}
} catch (Exception ex) {
break;
}
} else {
ThisAction.Pass = true;
}
}
} else {
int number_of_rows = thisbugview.DataTable.getRowCount();
for (int x = 0; x < number_of_rows; x++) {
int changex = -1;
for (Action ThisAction : bugtorun.ActionsList) {
if (STAppData.cancelled) {
publish(bugtorun.index);
break;
}
String original_value1 = ThisAction.Variable1;
String original_value2 = ThisAction.Variable2;
if (!ThisAction.Locked) {
DataLoopVarParser var1Parser = new DataLoopVarParser(ThisAction.Variable1);
DataLoopVarParser var2Parser = new DataLoopVarParser(ThisAction.Variable2);
if (var1Parser.hasDataLoopVar == false && var2Parser.hasDataLoopVar == false) {
if ("Pause with Continue Button".equals(ThisAction.Type)) {
String pause_message = "Paused at record " + (x + 1) + " of " + number_of_rows;
changex = ThisAction.RunAction(driver, pause_message, STAppData, x, number_of_rows);
} else
try {
if (totalpause > 0) {
try {
Thread.sleep(totalpause);
} catch (Exception ex) {
System.out.println("Exception when sleeping: " + ex.toString());
ThisAction.Pass = false;
publish(bugtorun.index);
break;
}
}
String varfieldname = "";
if (ThisAction.Variable2.contains("[stored_varname-start]")) {
varfieldname = ThisAction.Variable2;
int indexof_end_tag = varfieldname.indexOf("[stored_varname-end]");
// assuming name of "[stored_varname-start]" and "[stored_varname-end]"
String fieldname = varfieldname.substring(22, indexof_end_tag);
ThisAction.Variable2 = STAppData.GetStoredVariableValue(fieldname);
ThisAction.RunAction(driver);
ThisAction.Variable2 = "[stored_varname-start]" + fieldname + "[stored_varname-end]";
} else {
ThisAction.RunAction(driver);
}
if (!"".equals(ThisAction.tostore_varvalue)) {
STAppData.VarHashMap.put(ThisAction.tostore_varname, ThisAction.tostore_varvalue);
}
} catch (Exception ex) {
ThisAction.Variable1 = original_value1;
ThisAction.Variable2 = original_value2;
break;
}
} else {
String concat_variable = "";
String concat_variable2 = "";
if ("urllist".equals(bugtorun.DataLoopSource)) {
concat_variable = var1Parser.GetFullValueFromURLList(x, bugtorun.URLListData);
}
if ("file".equals(bugtorun.DataLoopSource)) {
concat_variable = var1Parser.GetFullValueFromFile(x, bugtorun.RunTimeFileSet);
}
if (var1Parser.hasDataLoopVar) {
ThisAction.Variable1 = concat_variable;
if ("".equals(ThisAction.Variable1)) {
ThisAction.Variable1 = " ";
}
}
if ("urllist".equals(bugtorun.DataLoopSource)) {
concat_variable2 = var2Parser.GetFullValueFromURLList(x, bugtorun.URLListData);
}
if ("file".equals(bugtorun.DataLoopSource)) {
concat_variable2 = var2Parser.GetFullValueFromFile(x, bugtorun.RunTimeFileSet);
}
if (var2Parser.hasDataLoopVar) {
ThisAction.Variable2 = concat_variable2;
if ("".equals(ThisAction.Variable2)) {
ThisAction.Variable2 = " ";
}
}
try {
if (totalpause > 0) {
try {
Thread.sleep(totalpause);
} catch (Exception ex) {
System.out.println("Exception when sleeping: " + ex.toString());
ThisAction.Pass = false;
break;
}
}
ThisAction.RunAction(driver);
ThisAction.Variable1 = original_value1;
ThisAction.Variable2 = original_value2;
} catch (Exception ex) {
ThisAction.Variable1 = original_value1;
ThisAction.Variable2 = original_value2;
break;
}
}
} else {
ThisAction.Pass = true;
}
}
if (changex != x) {
if (changex == -1) {
} else {
x = changex - 1;
}
}
}
}
if (STAppData.getPromptToClose()) {
Prompter thisContinuePrompt = new Prompter(STAppData.short_filename + " - Prompt to close webdriver", "Close webdriver/browser?", false, 0, 0);
while (thisContinuePrompt.isVisible() == true) {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
System.out.println("pause exception: " + e.toString());
}
}
try {
driver.close();
} catch (Exception e) {
System.out.println(e.toString());
try {
driver.quit();
} catch (Exception ex) {
System.out.println(ex.toString());
}
}
driver.quit();
}
}
use of org.openqa.selenium.ie.InternetExplorerDriver in project selenium_java by sergueik.
the class BaseTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
// BasicConfigurator.configure();
if (hubUrl == null || hubUrl.trim().isEmpty()) {
// if no hubUrl specified, run the tests on localhost
if (browser == null || browser.trim().isEmpty()) {
// if no browser specified, use IE
driver = new InternetExplorerDriver();
} else {
if (browser.trim().equalsIgnoreCase("firefox")) {
driver = new FirefoxDriver();
} else if (browser.trim().equalsIgnoreCase("chrome")) {
driver = new ChromeDriver();
} else {
driver = new InternetExplorerDriver();
}
}
} else {
DesiredCapabilities capability = new DesiredCapabilities();
capability.setBrowserName(browser);
driver = new RemoteWebDriver(new URL(hubUrl), capability);
}
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
use of org.openqa.selenium.ie.InternetExplorerDriver in project archiva by apache.
the class WebdriverUtility method newWebDriver.
public static WebDriver newWebDriver(String seleniumBrowser, String seleniumHost, int seleniumPort, boolean seleniumRemote) {
log.info("WebDriver {}, {}, {}, {}", seleniumBrowser, seleniumHost, seleniumPort, seleniumRemote);
if (seleniumRemote && StringUtils.isEmpty(seleniumHost)) {
throw new IllegalArgumentException("seleniumHost must be set, when seleniumRemote=true");
}
try {
if (StringUtils.contains(seleniumBrowser, "chrome")) {
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
if (seleniumRemote) {
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), capabilities);
} else {
return new ChromeDriver(options);
}
}
if (StringUtils.contains(seleniumBrowser, "safari")) {
if (seleniumRemote) {
return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), DesiredCapabilities.safari());
} else {
return new SafariDriver();
}
}
if (StringUtils.contains(seleniumBrowser, "iexplore")) {
if (seleniumRemote) {
return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), DesiredCapabilities.internetExplorer());
} else {
new InternetExplorerDriver();
}
}
if (StringUtils.contains(seleniumBrowser, "firefox")) {
if (seleniumRemote) {
return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), DesiredCapabilities.firefox());
} else {
return new FirefoxDriver();
}
}
DesiredCapabilities capabilities = DesiredCapabilities.htmlUnit();
capabilities.setJavascriptEnabled(true);
capabilities.setVersion("firefox-52");
WebDriver driver;
if (seleniumRemote) {
driver = new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), capabilities);
} else {
driver = new HtmlUnitDriver(capabilities) {
@Override
protected WebClient modifyWebClient(WebClient client) {
client.getOptions().setThrowExceptionOnFailingStatusCode(false);
client.getOptions().setThrowExceptionOnScriptError(false);
client.getOptions().setCssEnabled(true);
return client;
}
};
}
return driver;
} catch (MalformedURLException e) {
throw new RuntimeException("Initializion of remote driver failed");
}
}
use of org.openqa.selenium.ie.InternetExplorerDriver in project wechat by dllwh.
the class SeleniumHandler method getIEDriver.
/**
* @方法描述: 获取IE驱动
* @return
*/
private WebDriver getIEDriver() {
String path = genPath + props.getProperty("ieDriver");
System.getProperties().setProperty("webdriver.ie.driver", path);
DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
InternetExplorerDriver driver = new InternetExplorerDriver(ieCapabilities);
return driver;
}
Aggregations