List of usage examples for org.openqa.selenium.firefox FirefoxDriver FirefoxDriver
public FirefoxDriver(FirefoxDriverService service)
From source file:com.hpe.nv.samples.advanced.AdvAllTestClassMethods.java
License:Apache License
public static void buildSeleniumWebDriver() { logDebugMessage("Building the Selenium WebDriver for " + browser); if (proxySetting != null) { Proxy proxy = new Proxy(); proxy.setHttpProxy(proxySetting).setFtpProxy(proxySetting).setSslProxy(proxySetting) .setSocksProxy(proxySetting); DesiredCapabilities cap = new DesiredCapabilities(); cap.setCapability(CapabilityType.PROXY, proxy); if (browser.equalsIgnoreCase("Firefox")) { driver = new FirefoxDriver(cap); } else {//w w w . ja v a2 s. c om driver = new ChromeDriver(cap); } } else { if (browser.equalsIgnoreCase("Firefox")) { driver = new FirefoxDriver(); } else { driver = new ChromeDriver(); } } }
From source file:com.huangyunkun.jviff.service.WebDriverManager.java
License:Apache License
private static WebDriver createWebDriver() { FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.setPreference("app.update.auto", false); firefoxProfile.setPreference("app.update.enabled", false); //TODO:Disable proxy first, will add a proxy setting option later firefoxProfile.setPreference("network.proxy.type", 0); WebDriver driver = new FirefoxDriver(firefoxProfile); return driver; }
From source file:com.jaeksoft.searchlib.crawler.web.browser.FirefoxBrowserDriver.java
License:Open Source License
@Override public FirefoxDriver initialize() { FirefoxProfile profile = new FirefoxProfile(); // profile.setPreference("network.http.phishy-userpass-length", 255); profile.setEnableNativeEvents(false); return new FirefoxDriver(profile); }
From source file:com.kurento.kmf.test.client.BrowserClient.java
License:Open Source License
private void initDriver(String hostAddress) { Class<? extends WebDriver> driverClass = browser.getDriverClass(); int hubPort = getProperty("test.hub.port", GridBrowserMediaApiTest.DEFAULT_HUB_PORT); try {/*from w ww . j ava 2 s.c o m*/ if (driverClass.equals(FirefoxDriver.class)) { FirefoxProfile profile = new FirefoxProfile(); // This flag avoids granting the access to the camera profile.setPreference("media.navigator.permission.disabled", true); if (remoteNode != null) { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(FirefoxDriver.PROFILE, profile); capabilities.setBrowserName(DesiredCapabilities.firefox().getBrowserName()); driver = new RemoteWebDriver(new URL("http://" + hostAddress + ":" + hubPort + "/wd/hub"), capabilities); } else { driver = new FirefoxDriver(profile); } if (!usePhysicalCam && video != null) { launchFakeCam(); } } else if (driverClass.equals(ChromeDriver.class)) { String chromedriver = null; if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_LINUX) { chromedriver = "chromedriver"; } else if (SystemUtils.IS_OS_WINDOWS) { chromedriver = "chromedriver.exe"; } System.setProperty("webdriver.chrome.driver", new File("target/webdriver/" + chromedriver).getAbsolutePath()); ChromeOptions options = new ChromeOptions(); // This flag avoids grant the camera options.addArguments("--use-fake-ui-for-media-stream"); // This flag avoids warning in chrome. See: // https://code.google.com/p/chromedriver/issues/detail?id=799 options.addArguments("--test-type"); if (!usePhysicalCam) { // This flag makes using a synthetic video (green with // spinner) in webrtc. Or it is needed to combine with // use-file-for-fake-video-capture to use a file faking the // cam options.addArguments("--use-fake-device-for-media-stream"); if (video != null) { options.addArguments("--use-file-for-fake-video-capture=" + video); // Alternative: lauch fake cam also in Chrome // launchFakeCam(); } } if (remoteNode != null) { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(ChromeOptions.CAPABILITY, options); capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName()); driver = new RemoteWebDriver(new URL("http://" + hostAddress + ":" + hubPort + "/wd/hub"), capabilities); } else { driver = new ChromeDriver(options); } } driver.manage().timeouts().setScriptTimeout(timeout, TimeUnit.SECONDS); } catch (MalformedURLException e) { log.error("MalformedURLException in BrowserClient.initDriver", e); } }
From source file:com.lazerycode.ebselen.EbselenCore.java
License:Apache License
/** * Set the driver type based upon settings scraped from Env.properties * run function to get release number of website being tested * * @param driverObject - object to instantiate * @return WebDriver/*from w w w . j av a 2 s. c o m*/ */ public WebDriver setBrowser(WebDriver driverObject) { try { switch (browserDetails.getBrowser()) { case FIREFOX: driverObject = new FirefoxDriver(generateFirefoxProfile()); logger.debug("Using FIREFOX Driver..."); break; case IE6: case IE7: case IE8: case IE9: driverObject = new InternetExplorerDriver(); logger.debug("Using INTERNET EXPLORER Driver..."); break; case GOOGLECHROME: System.setProperty("webdriver.chrome.driver", settings.chromeDriverLocation()); driverObject = new ChromeDriver(); logger.debug("Using GOOGLECHROME Driver..."); break; case HTMLUNIT: driverObject = new HtmlUnitDriver(setHTMLUnitCapabilities(browserDetails.getHTMLUnitEmulation())); logger.debug("Using HTMLUNIT Driver..."); break; case SAFARI: //FUTURE break; case OPERA: driverObject = new OperaDriver(); logger.debug("Using Opera Driver..."); break; case IPHONE: driverObject = new IPhoneDriver(); logger.debug("Using IPhone Driver..."); break; case ANDROID: driverObject = new AndroidDriver(); logger.debug("Using Android Driver..."); break; } getReleaseVersion(); } catch (Exception x) { logger.error("Error in EbselenCore.setBrowser: {}", x.getMessage()); return driverObject; } return driverObject; }
From source file:com.liferay.faces.test.selenium.browser.internal.BrowserDriverFactoryImpl.java
License:Open Source License
@Override public BrowserDriver getBrowserDriverImplementation(String browserName, boolean browserHeadless, boolean browserSimulateMobile) { WebDriver webDriver;// w w w . ja v a 2 s. c om if ("chrome".equals(browserName)) { ChromeOptions chromeOptions = new ChromeOptions(); String chromeBinaryPath = TestUtil.getSystemPropertyOrDefault("webdriver.chrome.bin", null); if (chromeBinaryPath != null) { chromeOptions.setBinary(chromeBinaryPath); logger.info("Chrome Binary: {}", chromeBinaryPath); } if (browserHeadless) { // The start-maximized argument does not work correctly in headless mode, so set the window size to // 1920x1200 (resolution of a 15.4 inch screen). chromeOptions.addArguments("headless", "disable-gpu", "window-size=1920,1200"); } else { chromeOptions.addArguments("start-maximized"); } if (browserSimulateMobile) { chromeOptions.addArguments("user-agent=\"" + IPHONE_7_IOS_10_0_USER_AGENT + "\""); } webDriver = new ChromeDriver(chromeOptions); } else if ("firefox".equals(browserName)) { // The value of this property is obtained automatically by FirefoxDriver. String firefoxBinaryPath = TestUtil.getSystemPropertyOrDefault("webdriver.firefox.bin", null); if (firefoxBinaryPath != null) { logger.info("Firefox Binary: {}", firefoxBinaryPath); } FirefoxProfile firefoxProfile = new FirefoxProfile(); if (browserHeadless) { throw new UnsupportedOperationException("Headless mode is not yet supported for Firefox"); } if (browserSimulateMobile) { firefoxProfile.setPreference("general.useragent.override", IPHONE_7_IOS_10_0_USER_AGENT); } webDriver = new FirefoxDriver(firefoxProfile); } else if ("phantomjs".equals(browserName)) { // The value of this property is obtained automatically by PhantomJSDriver. String phantomJSBinaryPath = TestUtil.getSystemPropertyOrDefault("phantomjs.binary.path", null); if (phantomJSBinaryPath != null) { logger.info("PhantomJS Binary: {}", phantomJSBinaryPath); } DesiredCapabilities desiredCapabilities = new DesiredCapabilities(); if (!browserHeadless) { throw new UnsupportedOperationException("Non-headless mode is not yet supported for PhantomJS"); } if (browserSimulateMobile) { desiredCapabilities.setCapability( PhantomJSDriverService.PHANTOMJS_PAGE_SETTINGS_PREFIX + "userAgent", IPHONE_7_IOS_10_0_USER_AGENT); desiredCapabilities.setCapability( PhantomJSDriverService.PHANTOMJS_PAGE_CUSTOMHEADERS_PREFIX + "User-Agent", IPHONE_7_IOS_10_0_USER_AGENT); } // Set the Accept-Language header to "en-US,en;q=0.8" to ensure that it isn't set to "en-US," (the default). desiredCapabilities.setCapability( PhantomJSDriverService.PHANTOMJS_PAGE_CUSTOMHEADERS_PREFIX + "Accept-Language", "en-US,en;q=0.8"); String phantomJSLogLevel; if (logger.isDebugEnabled()) { phantomJSLogLevel = "DEBUG"; } else if (logger.isInfoEnabled()) { phantomJSLogLevel = "INFO"; } else if (logger.isWarnEnabled()) { phantomJSLogLevel = "WARN"; } else if (logger.isErrorEnabled()) { phantomJSLogLevel = "ERROR"; } else { phantomJSLogLevel = "NONE"; } String[] phantomArgs = new String[1]; phantomArgs[0] = "--webdriver-loglevel=" + phantomJSLogLevel; desiredCapabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, phantomArgs); webDriver = new PhantomJSDriver(desiredCapabilities); } else if ("htmlunit".equals(browserName)) { if (!browserHeadless) { throw new UnsupportedOperationException("Non-headless mode is not yet supported for HtmlUnit"); } if (browserSimulateMobile) { webDriver = new HtmlUnitDriverLiferayFacesImpl(IPHONE_7_IOS_10_0_USER_AGENT); } else { webDriver = new HtmlUnitDriverLiferayFacesImpl(); } } else if ("jbrowser".equals(browserName)) { if (!browserHeadless) { throw new UnsupportedOperationException("Non-headless mode is not yet supported for JBrowser"); } if (browserSimulateMobile) { throw new UnsupportedOperationException("Mobile simulation is not yet supported for JBrowser."); } webDriver = new JBrowserDriver(); } else { throw new UnsupportedOperationException("Browser with not supported: " + browserName); } if (!"chrome".equals(browserName)) { webDriver.manage().window().maximize(); } return getBrowserDriverImplementation(webDriver, browserHeadless, browserSimulateMobile); }
From source file:com.mgmtp.jfunk.web.FirefoxDriverProvider.java
License:Apache License
@Override protected WebDriver createWebDriver(final DesiredCapabilities capabilities) { return new FirefoxDriver(capabilities); }
From source file:com.monstrenyatko.desert.util.WebDriverFactory.java
License:MIT License
private static WebDriver createLocalDriver(Capabilities capabilities) { String browserType = capabilities.getBrowserName(); if (browserType.equals(BrowserType.FIREFOX)) return new FirefoxDriver(capabilities); if (browserType.equals(BrowserType.IE)) return new InternetExplorerDriver(capabilities); if (browserType.equals(BrowserType.CHROME)) return new ChromeDriver(capabilities); if (browserType.equals(BrowserType.SAFARI)) return new SafariDriver(capabilities); throw new Error("Unsupported browser type: " + browserType); }
From source file:com.moodle.test.SeleniumManager.java
License:GNU General Public License
/** * Run tests using the Firefox driver./* ww w .j a v a 2s. c o m*/ * @throws MalformedURLException Catches an exception caused by a malformed URL. All URL's are malformed so this much be caught. */ //Firefox Driver public void startFirefoxDriver() throws MalformedURLException { FirefoxProfile profile = new FirefoxProfile(); profile.setEnableNativeEvents(true); firefoxdriver = new FirefoxDriver(profile); }
From source file:com.mycompany.newseleniumtest.TestScript.java
public void startDriver(String browser) { switch (browser) { case "firefox": FirefoxProfile fp = new FirefoxProfile(); fp.setPreference("browser.startup.homepage", "about:blank"); fp.setPreference("startup.homepage_welcome_url", "about:blank"); fp.setPreference("startup.homepage_welcome_url.additional", "about:blank"); this.driver = new FirefoxDriver(fp); this.driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); driver.manage().window().maximize(); break;// w w w. j ava2 s . co m case "chrome": System.setProperty("webdriver.chrome.driver", "/Users/rahmatzailani/Documents/chromedriver"); this.driver = new ChromeDriver(); this.driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); break; default: break; } }