List of usage examples for org.openqa.selenium.ie InternetExplorerDriver InternetExplorerDriver
public InternetExplorerDriver()
From source file:br.ufmg.dcc.saotome.beholder.selenium.SeleniumController.java
License:Apache License
/** * This method starts the selenium remote control using the parameters * informed by testng.xml file/*from w ww . jav a 2s .c o m*/ * @param parameters * @throws Exception */ @BeforeSuite(alwaysRun = true) @Parameters(value = { "parameters" }) public static void startSelenium(String parameters) { parametersMap = parameterScanner(parameters); parametersInfo(); String browserName = parametersMap.get("browser"), profile = parametersMap.get("profile"), chromeDriverBin = parametersMap.get("chromeDriverBin"), ieDriverBin = parametersMap.get("ieDriverBin"), chromeBin = parametersMap.get("chromeBin"), languages = parametersMap.get("languages"); if (browserName == null) { throw new IllegalArgumentException( String.format(ErrorMessages.ERROR_TEMPLATE_VARIABLE_NULL, "browser")); } if (driver == null) { if (BrowsersList.FIREFOX.equalsString(browserName)) { FirefoxProfile fp = new FirefoxProfile(); fp.setPreference("dom.max_script_run_time", 0); fp.setPreference("dom.max_chrome_script_run_time", 0); if (profile != null && !profile.isEmpty()) { fp.setPreference("webdriver.firefox.profile", profile); } if (languages != null && !languages.isEmpty()) { fp.setPreference("intl.accept_languages", languages); } driver = new WebDriverAdapter(new FirefoxDriver(fp)); } else if (BrowsersList.CHROME.equalsString(browserName)) { if (chromeBin == null) { throw new IllegalArgumentException( String.format(ErrorMessages.ERROR_TEMPLATE_VARIABLE_NULL, "chromeBin")); } // Optional, if not specified, WebDriver will search your path for chromedriver // in the system environment. (OBS: To evade problems, webdriver.chrome.driver MUST have a value. if (System.getProperty("webdriver.chrome.driver") == null || System.getProperty("webdriver.chrome.driver").isEmpty()) { if (chromeDriverBin == null) { throw new IllegalArgumentException( String.format(ErrorMessages.ERROR_TEMPLATE_VARIABLE_NULL, "chromeDriverBin")); } System.setProperty("webdriver.chrome.driver", chromeDriverBin); } ChromeOptions co = new ChromeOptions(); // Get the chrome binary directory path from System Envionment. co.setBinary(new File(chromeBin)); driver = new WebDriverAdapter(new ChromeDriver(co)); } else if (BrowsersList.IE.equalsString(browserName)) { if (ieDriverBin == null) { throw new IllegalArgumentException( String.format(ErrorMessages.ERROR_TEMPLATE_VARIABLE_NULL, "ieDriverBin")); } System.setProperty("webdriver.ie.driver", ieDriverBin); driver = new WebDriverAdapter(new InternetExplorerDriver()); } else if (BrowsersList.HTML_UNIT.equalsString(browserName)) { driver = new HtmlUnitDriver(true); } else { throw new IllegalArgumentException(ErrorMessages.ERROR_BROWSER_INVALID); } } /* Sets to all driver methods the global timeout of 1 second. * To tests, Timeouts must be specified on the components. */ SeleniumController.driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS); SeleniumController.builder = new SeleniumBuilder(driver); SeleniumController.browser = new SeleniumBrowser(); ListenerGateway.setWebDriver(driver); ListenerGateway.setParameters(parametersMap); }
From source file:browsermator.com.RunASingleTest.java
public void RunSingleTest(Procedure bugtorun, ProcedureView thisbugview, String TargetBrowser, String OSType) { SiteTest.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); switch (TargetBrowser) { // legacy file support case "Firefox-Marionette": // legacy file support if ("Windows".equals(OSType)) { System.setProperty("webdriver.gecko.driver", "lib\\geckodriver-0.11.1-win32\\geckodriver.exe"); }// www . j a v a2s .c o m if ("Windows32".equals(OSType)) { System.setProperty("webdriver.gecko.driver", "lib\\geckodriver-0.11.1-win32\\geckodriver.exe"); } if ("Windows64".equals(OSType)) { System.setProperty("webdriver.gecko.driver", "lib\\geckodriver-0.11.1-win64\\geckodriver.exe"); } if ("Mac".equals(OSType)) { System.setProperty("webdriver.gecko.driver", "lib\\geckodriver-0.11.1-osx\\geckodriver"); } if ("Linux-32".equals(OSType)) { System.setProperty("webdriver.gecko.driver", "lib\\geckodriver-0.11.1-linux32\\geckodriver"); } if ("Linux-64".equals(OSType)) { System.setProperty("webdriver.gecko.driver", "lib\\geckodriver-0.11.1-linux64\\geckodriver"); } if (firefox_path != null) { System.setProperty("webdriver.firefox.bin", firefox_path); } try { DesiredCapabilities cap = DesiredCapabilities.firefox(); cap.setJavascriptEnabled(true); cap.setCapability("marionette", true); driver = new FirefoxDriver(cap); // 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( "We could not launch the Marionette driver, will fallback to HTMLUnitDriver", false); SiteTest.setTargetBrowser("Silent Mode (HTMLUnit)"); } break; case "Firefox": //legacy support if ("Windows".equals(OSType)) { System.setProperty("webdriver.gecko.driver", "lib\\geckodriver-0.11.1-win32\\geckodriver.exe"); } if ("Windows32".equals(OSType)) { System.setProperty("webdriver.gecko.driver", "lib\\geckodriver-0.11.1-win32\\geckodriver.exe"); } if ("Windows64".equals(OSType)) { System.setProperty("webdriver.gecko.driver", "lib\\geckodriver-0.11.1-win64\\geckodriver.exe"); } if ("Mac".equals(OSType)) { System.setProperty("webdriver.gecko.driver", "lib\\geckodriver-0.11.1-osx\\geckodriver"); } if ("Linux-32".equals(OSType)) { System.setProperty("webdriver.gecko.driver", "lib\\geckodriver-0.11.1-linux32\\geckodriver"); } if ("Linux-64".equals(OSType)) { System.setProperty("webdriver.gecko.driver", "lib\\geckodriver-0.11.1-linux64\\geckodriver"); } if (firefox_path != null) { System.setProperty("webdriver.firefox.bin", firefox_path); } try { DesiredCapabilities cap = DesiredCapabilities.firefox(); cap.setJavascriptEnabled(true); cap.setCapability("marionette", true); driver = new FirefoxDriver(cap); // 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( "We could not launch the Marionette driver, will fallback to HTMLUnitDriver", false); SiteTest.setTargetBrowser("Silent Mode (HTMLUnit)"); } break; case "Silent Mode (HTMLUnit)": driver = new HtmlUnitDriver(); break; case "Internet Explorer-32": System.setProperty("webdriver.ie.driver", "lib\\iedriverserver_win32\\IEDriverServer.exe"); try { driver = new InternetExplorerDriver(); } catch (Exception ex) { System.out.println("Exception launching Internet Explorer driver: " + ex.toString()); Prompter fallbackprompt = new Prompter( "We could not launch the Internet Explorer driver, will fallback to HTMLUnitDriver", false); SiteTest.setTargetBrowser("Silent Mode (HTMLUnit)"); } break; case "Internet Explorer-64": System.setProperty("webdriver.ie.driver", "lib\\iedriverserver_win64\\IEDriverServer.exe"); try { driver = new InternetExplorerDriver(); } catch (Exception ex) { System.out.println("Exception launching Internet Explorer-64 driver: " + ex.toString()); Prompter fallbackprompt = new Prompter( "We could not launch the Internet Explorer 64 driver, will fallback to HTMLUnitDriver", false); SiteTest.setTargetBrowser("Silent Mode (HTMLUnit)"); } break; case "Chrome": if ("Windows32".equals(OSType)) { System.setProperty("webdriver.chrome.driver", "lib\\chromedriver_win32\\chromedriver.exe"); } if ("Windows64".equals(OSType)) { System.setProperty("webdriver.chrome.driver", "lib\\chromedriver_win32\\chromedriver.exe"); } if ("Mac".equals(OSType)) { System.setProperty("webdriver.chrome.driver", "lib\\chromedriver_mac64\\chromedriver"); } if ("Linux-32".equals(OSType)) { System.setProperty("webdriver.chrome.driver", "lib\\chromedriver_linux32\\chromedriver-linux32"); } if ("Linux-64".equals(OSType)) { System.setProperty("webdriver.chrome.driver", "lib\\chromedriver_linux64\\chromedriver-linux64"); } try { driver = new ChromeDriver(); } catch (Exception ex) { System.out.println("Problem launching Chromedriver: " + ex.toString()); Prompter fallbackprompt = new Prompter( "We could not launch the Chrome driver, will fallback to HTMLUnitDriver", false); SiteTest.setTargetBrowser("Silent Mode (HTMLUnit)"); } break; case "Chrome (WinXP)": if (chrome_path != null) { System.setProperty("webdriver.chrome.bin", chrome_path); } System.setProperty("webdriver.chrome.driver", "lib\\chromedriver_win32\\chromedriver-winxp.exe"); try { driver = new ChromeDriver(); } catch (Exception ex) { System.out.println("Problem launching Chromedriver for XP: " + ex.toString()); Prompter fallbackprompt = new Prompter( "We could not launch the Chrome WinXP driver, will fallback to HTMLUnitDriver", false); SiteTest.setTargetBrowser("Silent Mode (HTMLUnit)"); } break; default: driver = new ChromeDriver(); break; } int WaitTime = SiteTest.GetWaitTime(); // driver.manage().timeouts().implicitlyWait(WaitTime, TimeUnit.SECONDS); int totalpause = WaitTime * 1000; if (!"Dataloop".equals(thisbugview.Type)) { for (Action ThisAction : bugtorun.ActionsList) { if (!ThisAction.Locked) { try { try { Thread.sleep(totalpause); } catch (Exception ex) { System.out.println("Exception when sleeping: " + ex.toString()); } 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 = SiteTest.GetStoredVariableValue(fieldname); ThisAction.RunAction(driver); ThisAction.Variable2 = "[stored_varname-start]" + fieldname + "[stored_varname-end]"; } else { ThisAction.RunAction(driver); } if (!"".equals(ThisAction.tostore_varvalue)) { SiteTest.VarHashMap.put(ThisAction.tostore_varname, ThisAction.tostore_varvalue); } } catch (Exception ex) { SiteTest.setCursor(Cursor.getDefaultCursor()); driver.close(); driver.quit(); break; } } else { ThisAction.Pass = true; } } } else { int number_of_rows = thisbugview.myTable.DataTable.getRowCount(); for (int x = 0; x < number_of_rows; x++) { for (Action ThisAction : bugtorun.ActionsList) { 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; ThisAction.RunAction(driver, pause_message, this.SiteTest); } try { Thread.sleep(totalpause); } catch (Exception ex) { System.out.println("Exception when sleeping: " + ex.toString()); } try { 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 = SiteTest.GetStoredVariableValue(fieldname); ThisAction.RunAction(driver); ThisAction.Variable2 = "[stored_varname-start]" + fieldname + "[stored_varname-end]"; } else { ThisAction.RunAction(driver); } if (!"".equals(ThisAction.tostore_varvalue)) { SiteTest.VarHashMap.put(ThisAction.tostore_varname, ThisAction.tostore_varvalue); } } catch (Exception ex) { driver.close(); driver.quit(); ThisAction.Variable1 = original_value1; ThisAction.Variable2 = original_value2; SiteTest.setCursor(Cursor.getDefaultCursor()); break; } } else { String concat_variable; String concat_variable2; concat_variable = var1Parser.GetFullValue(x, thisbugview.myTable); if (var1Parser.hasDataLoopVar) { ThisAction.Variable1 = concat_variable; if ("".equals(ThisAction.Variable1)) { ThisAction.Variable1 = " "; } } concat_variable2 = var2Parser.GetFullValue(x, thisbugview.myTable); if (var2Parser.hasDataLoopVar) { ThisAction.Variable2 = concat_variable2; if ("".equals(ThisAction.Variable2)) { ThisAction.Variable2 = " "; } } try { try { Thread.sleep(totalpause); } catch (Exception ex) { System.out.println("Exception when sleeping: " + ex.toString()); } ThisAction.RunAction(driver); ThisAction.Variable1 = original_value1; ThisAction.Variable2 = original_value2; } catch (Exception ex) { ThisAction.Variable1 = original_value1; ThisAction.Variable2 = original_value2; driver.close(); driver.quit(); SiteTest.setCursor(Cursor.getDefaultCursor()); break; } } } else { ThisAction.Pass = true; } } } } driver.close(); driver.quit(); ArrayList<ActionView> ActionView = thisbugview.ActionsViewList; int ActionIndex = 0; for (ActionView TheseActionViews : ActionView) { LocalDateTime stringtime = bugtorun.ActionsList.get(ActionIndex).TimeOfTest; boolean TestState = bugtorun.ActionsList.get(ActionIndex).Pass; if (TestState == true) { thisbugview.ActionsViewList.get(ActionIndex).JLabelPassFail.setText("Passed at " + stringtime); } else { thisbugview.ActionsViewList.get(ActionIndex).JLabelPassFail.setText("Fail at " + stringtime); } ActionIndex++; } }
From source file:ch.vorburger.vaadin.designer.tests.web.DesignerWebDriverTest.java
License:Apache License
/** * Returns a WebDriver suitable for this Platform. * // w w w . j a v a 2 s. com * On Windows we use IE, and else FF, because these are the two browser * which the embedded SWT Browser widget which the Designer uses support. * * The SWT Browser widget does not support Chrome; also ChromeDriver is * needs a separate chromedriver.exe/... to be available, which we would * have to package along and get from classpath and set * webdriver.chrome.driver to as in https://gist.github.com/3463203 for this * to work out-of-the-box for anybody. I've also had some chromedriver.exe * left hanging; may be simply didn't close() properly.) */ private static WebDriver newWebDriver() { String os = System.getProperty("os.name").toLowerCase(); if (os.contains("windows")) { return new InternetExplorerDriver(); } else { return new FirefoxDriver(); } }
From source file:ch.vorburger.vaadin.designer.tests.web.VaadinServerTest.java
License:Apache License
@Test @Ignore // TODO reactivate when http://dev.vaadin.com/ticket/9386 is fixed? public void testStartVaadinServer() throws Exception { VaadinServer server = new VaadinServer() { @Override//w w w . j a v a 2s. co m protected Class<? extends Application> getVaadinApplicationClass() { return VaadinTestApplication.class; } }; try { server.start(); // Check if "Saluton!" button shows up: WebDriver driver = new InternetExplorerDriver(); driver.get(server.getURL()); WebElement button = driver.findElement(By.id(HTML_ID)); String text = button.getText(); Assert.assertEquals("Saluton!", text); driver.quit(); } finally { server.stop(); } }
From source file:cn.hxh.springside.test.functional.WebDriverFactory.java
License:Apache License
/** * ?driverName??WebDriver./*from w ww. java2s.c o m*/ * * ????Windows, IE?XWindows, ?remote dirverWindows. * drivernameremote:192.168.0.2:3000:firefox, ??http://192.168.0.2:3000/wd?selnium remote?. * @throws MalformedURLException */ public static WebDriver createDriver(String driverName) { WebDriver driver = null; if (BrowserType.firefox.name().equals(driverName)) { driver = new FirefoxDriver(); } else if (BrowserType.ie.name().equals(driverName)) { driver = new InternetExplorerDriver(); } else if (driverName.startsWith(BrowserType.remote.name())) { String[] params = driverName.split(":"); Assert.isTrue(params.length == 4, "Remote driver is not right, accept format is \"remote:localhost:3000:firefox\", but the input is\"" + driverName + "\""); String remoteHost = params[1]; String remotePort = params[2]; String driverType = params[3]; DesiredCapabilities cap = null; if (BrowserType.firefox.name().equals(driverType)) { cap = DesiredCapabilities.firefox(); } else if (BrowserType.ie.name().equals(driverType)) { cap = DesiredCapabilities.internetExplorer(); } try { driver = new RemoteWebDriver(new URL("http://" + remoteHost + ":" + remotePort + "/wd"), cap); } catch (MalformedURLException e) { throw ExceptionUtils.unchecked(e); } } Assert.notNull(driver, "Driver could be found by name:" + driverName); return driver; }
From source file:cn.newtouch.util.test.utils.SeleniumUtils.java
License:Apache License
/** * ?driverName??WebDriver./*from w w w . j a v a 2 s . c om*/ * * ????Windows, IE?XWindows, ?remote dirverWindows. * drivernameremote:192.168.0.2:3000:firefox, ??http://192.168.0.2:3000/wd?selnium remote?. */ public static WebDriver buildDriver(String driverName) throws Exception { WebDriver driver = null; if (HTMLUNIT.equals(driverName)) { driver = new HtmlUnitDriver(); ((HtmlUnitDriver) driver).setJavascriptEnabled(true); } if (FIREFOX.equals(driverName)) { driver = new FirefoxDriver(); } if (IE.equals(driverName)) { driver = new InternetExplorerDriver(); } if (driverName.startsWith(REMOTE)) { String[] params = driverName.split(":"); Assert.isTrue(params.length == 4, "Remote driver is not right, accept format is \"remote:localhost:3000:firefox\", but the input is\"" + driverName + "\""); String remoteHost = params[1]; String remotePort = params[2]; String driverType = params[3]; DesiredCapabilities cap = null; if (FIREFOX.equals(driverType)) { cap = DesiredCapabilities.firefox(); } if (IE.equals(driverType)) { cap = DesiredCapabilities.internetExplorer(); } driver = new RemoteWebDriver(new URL("http://" + remoteHost + ":" + remotePort + "/wd"), cap); } Assert.notNull(driver, "No driver could be found by name:" + driverName); return driver; }
From source file:co.flexmod.selenium.example.integration.framework.WebDriverFactory.java
License:Apache License
public static WebDriver create(String browser) { if (browser.equalsIgnoreCase("firefox")) { return new FirefoxDriver(); } else if (browser.equalsIgnoreCase("chrome")) { return new ChromeDriver(); } else if (browser.equalsIgnoreCase("ie")) { return new InternetExplorerDriver(); } else if (browser.equalsIgnoreCase("html")) { HtmlUnitDriver htmlUnitDriver = new HtmlUnitDriver(BrowserVersion.FIREFOX_24); htmlUnitDriver.setJavascriptEnabled(true); return htmlUnitDriver; } else {//w ww. j a v a 2s .c o m throw new IllegalArgumentException("The Browser Type is Undefined"); } }
From source file:com.androidwhy.modules.test.selenium.WebDriverFactory.java
License:Apache License
/** * ?driverName??WebDriver./* ww w. ja v a2s. c o m*/ * * ????Windows, IE?XWindows, ?remote driverWindows. * drivernameremote:192.168.0.2:4444:firefox, ??http://192.168.0.2:4444/wd/hub?selenium remote?. * @throws MalformedURLException */ public static WebDriver createDriver(String driverName) { WebDriver driver = null; if (BrowserType.firefox.name().equals(driverName)) { driver = new FirefoxDriver(); } else if (BrowserType.ie.name().equals(driverName)) { driver = new InternetExplorerDriver(); } else if (BrowserType.chrome.name().equals(driverName)) { driver = new ChromeDriver(); } else if (BrowserType.htmlunit.name().equals(driverName)) { driver = new HtmlUnitDriver(true); } else if (driverName.startsWith(BrowserType.remote.name())) { String[] params = driverName.split(":"); Assert.isTrue(params.length == 4, "Remote driver is not right, accept format is \"remote:localhost:4444:firefox\", but the input is\"" + driverName + "\""); String remoteHost = params[1]; String remotePort = params[2]; String driverType = params[3]; DesiredCapabilities cap = null; if (BrowserType.firefox.name().equals(driverType)) { cap = DesiredCapabilities.firefox(); } else if (BrowserType.ie.name().equals(driverType)) { cap = DesiredCapabilities.internetExplorer(); } else if (BrowserType.chrome.name().equals(driverType)) { cap = DesiredCapabilities.chrome(); } try { driver = new RemoteWebDriver(new URL("http://" + remoteHost + ":" + remotePort + "/wd/hub"), cap); } catch (MalformedURLException e) { throw new RuntimeException(e); } } Assert.notNull(driver, "Driver could be found by name:" + driverName); return driver; }
From source file:com.asiainfo.tfsPlatform.modules.test.selenium.WebDriverFactory.java
License:Apache License
/** * ?driverName??WebDriver./*from w w w . j a va2s .co m*/ * * ??firefox,ie,chrome??. * * ????Windows, IE?XWindows, ???remote driverWindows. * drivernameremote:192.168.0.2:4444:firefox, ??http://192.168.0.2:4444/wd/hub?selenium remote?. */ public static WebDriver createDriver(String driverName) { WebDriver driver = null; if (BrowserType.firefox.name().equals(driverName)) { driver = new FirefoxDriver(); } else if (BrowserType.ie.name().equals(driverName)) { driver = new InternetExplorerDriver(); } else if (BrowserType.chrome.name().equals(driverName)) { driver = new ChromeDriver(); } else if (driverName.startsWith(BrowserType.remote.name())) { String[] params = driverName.split(":"); Validate.isTrue(params.length == 4, "Remote driver is not right, accept format is \"remote:localhost:4444:firefox\", but the input is\"" + driverName + "\""); String remoteHost = params[1]; String remotePort = params[2]; String driverType = params[3]; String remoteUrl = "http://" + remoteHost + ":" + remotePort + "/wd/hub"; DesiredCapabilities cap = null; if (BrowserType.firefox.name().equals(driverType)) { cap = DesiredCapabilities.firefox(); } else if (BrowserType.ie.name().equals(driverType)) { cap = DesiredCapabilities.internetExplorer(); } else if (BrowserType.chrome.name().equals(driverType)) { cap = DesiredCapabilities.chrome(); } try { driver = new RemoteWebDriver(new URL(remoteUrl), cap); } catch (MalformedURLException e) { throw new RuntimeException(e); } } Validate.notNull(driver, "Driver could be found by name:" + driverName); return driver; }
From source file:com.atf.webtest.factory.BrowserFactory.java
public static WebDriver getIEBrowser() { System.setProperty("webdriver.InternetExplorer.driver", EnviConfig.getIEPath()); driver = new InternetExplorerDriver(); return driver; }