Java Code Examples for org.openqa.selenium.firefox.FirefoxOptions#setBinary()
The following examples show how to use
org.openqa.selenium.firefox.FirefoxOptions#setBinary() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FirefoxDevice.java From agent with MIT License | 6 votes |
@Override protected Capabilities newCaps(Capabilities capsToMerge) { FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.setAcceptInsecureCerts(true); // **** 以上capabilities可被传入的caps覆盖 **** firefoxOptions.merge(capsToMerge); // **** 以下capabilities具有更高优先级,将覆盖传入的caps **** if (!StringUtils.isEmpty(browser.getPath())) { firefoxOptions.setBinary(browser.getPath()); } return firefoxOptions; }
Example 2
Source File: WebDriverCreator.java From webtau with Apache License 2.0 | 6 votes |
private static FirefoxDriver createFirefoxDriver() { FirefoxOptions options = new FirefoxOptions(); if (BrowserConfig.getFirefoxBinPath() != null) { options.setBinary(BrowserConfig.getFirefoxBinPath()); } if (BrowserConfig.getFirefoxDriverPath() != null) { System.setProperty(FIREFOX_DRIVER_PATH_KEY, BrowserConfig.getChromeDriverPath().toString()); } if (BrowserConfig.isHeadless()) { options.setHeadless(true); } if (System.getProperty(FIREFOX_DRIVER_PATH_KEY) == null) { setupDriverManagerConfig(); downloadDriverMessage("firefox"); WebDriverManager.firefoxdriver().setup(); } return new FirefoxDriver(options); }
Example 3
Source File: FirefoxWebDriverProvider.java From submarine with Apache License 2.0 | 5 votes |
@Override public WebDriver createWebDriver(String webDriverPath) { FirefoxBinary ffox = new FirefoxBinary(); if ("true".equals(System.getenv("TRAVIS"))) { // xvfb is supposed to run with DISPLAY 99 ffox.setEnvironmentProperty("DISPLAY", ":99"); } ffox.addCommandLineOptions("--headless"); FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("browser.download.folderList", 2); profile.setPreference("browser.download.dir", FileUtils.getTempDirectory().toString() + "/firefox/"); profile.setPreference("browser.helperApps.alwaysAsk.force", false); profile.setPreference("browser.download.manager.showWhenStarting", false); profile.setPreference("browser.download.manager.showAlertOnComplete", false); profile.setPreference("browser.download.manager.closeWhenDone", true); profile.setPreference("app.update.auto", false); profile.setPreference("app.update.enabled", false); profile.setPreference("dom.max_script_run_time", 0); profile.setPreference("dom.max_chrome_script_run_time", 0); profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/x-ustar,application/octet-stream,application/zip,text/csv,text/plain"); profile.setPreference("network.proxy.type", 0); System.setProperty( GeckoDriverService.GECKO_DRIVER_EXE_PROPERTY, webDriverPath); System.setProperty( FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE, "true"); FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.setBinary(ffox); firefoxOptions.setProfile(profile); firefoxOptions.setLogLevel(FirefoxDriverLogLevel.TRACE); return new FirefoxDriver(firefoxOptions); }
Example 4
Source File: BotWorker.java From JYTB with GNU General Public License v3.0 | 5 votes |
/** * Sets the webdriver to FireFox. We set our optimal parameters here * to ensure our proxy is set correctly. */ private void setFirefoxDriver() { FirefoxOptions options = new FirefoxOptions(); FirefoxProfile profile = new FirefoxProfile(); FirefoxBinary binary = new FirefoxBinary(this.driverLocation); LoggingPreferences logPrefs = new LoggingPreferences(); System.setProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE,"true"); // hide firefox logs from console System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE,"/tmp/rust_"); profile.setPreference("media.volume_scale", "0.0"); profile.setPreference("general.useragent.override", userAgent.randomUA()); profile.setPreference("network.proxy.type", 1); profile.setPreference("network.proxy.http", this.proxies.getCurrentProxyModel().getIp()); profile.setPreference("network.proxy.http_port", this.proxies.getCurrentProxyModel().getPort()); profile.setPreference("network.proxy.ssl", this.proxies.getCurrentProxyModel().getIp()); profile.setPreference("network.proxy.ssl_port", this.proxies.getCurrentProxyModel().getPort()); logPrefs.enable(LogType.BROWSER, Level.ALL); logPrefs.enable(LogType.PERFORMANCE, Level.INFO); options.setCapability(CapabilityType.LOGGING_PREFS, logPrefs); options.setProfile(profile); options.setHeadless(true); options.setBinary(binary); // options.setProxy(this.proxies.getCurrentProxy()); options.setCapability("proxy", this.proxies.getCurrentProxy()); this.webDriver = new FirefoxDriver(options); Log.WINFO(this.workerName, this.workerColor, "Firefox Driver Set"); }
Example 5
Source File: SeleniumConfig.java From freeacs with MIT License | 5 votes |
public SeleniumConfig(long timeout) { FirefoxBinary firefoxBinary = new FirefoxBinary(); firefoxBinary.addCommandLineOptions("--headless"); FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.setBinary(firefoxBinary); driver = new FirefoxDriver(firefoxOptions); driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS); }
Example 6
Source File: WebDriverTestCase.java From htmlunit with Apache License 2.0 | 5 votes |
private static FirefoxDriver createFirefoxDriver(final String binary) { if (binary != null) { final FirefoxOptions options = new FirefoxOptions(); options.setBinary(binary); return new FirefoxDriver(options); } return new FirefoxDriver(); }
Example 7
Source File: DriverFactory.java From NoraUi with GNU Affero General Public License v3.0 | 5 votes |
/** * Generates a firefox webdriver. * * @return * A firefox webdriver * @throws TechnicalException * if an error occured when Webdriver setExecutable to true. */ private WebDriver generateFirefoxDriver() throws TechnicalException { final String pathWebdriver = DriverFactory.getPath(Driver.FIREFOX); if (!new File(pathWebdriver).setExecutable(true)) { throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_WEBDRIVER_SET_EXECUTABLE)); } log.info("Generating Firefox driver ({}) ...", pathWebdriver); System.setProperty(Driver.FIREFOX.getDriverName(), pathWebdriver); final FirefoxOptions firefoxOptions = new FirefoxOptions(); final FirefoxBinary firefoxBinary = new FirefoxBinary(); firefoxOptions.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true); firefoxOptions.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT); setLoggingLevel(firefoxOptions); // Proxy configuration if (Context.getProxy().getProxyType() != ProxyType.UNSPECIFIED && Context.getProxy().getProxyType() != ProxyType.AUTODETECT) { firefoxOptions.setCapability(CapabilityType.PROXY, Context.getProxy()); } if (Context.isHeadless()) { firefoxBinary.addCommandLineOptions("--headless"); firefoxOptions.setBinary(firefoxBinary); } firefoxOptions.setLogLevel(FirefoxDriverLogLevel.FATAL); return new FirefoxDriver(firefoxOptions); }
Example 8
Source File: DriverFactory.java From Insights with Apache License 2.0 | 5 votes |
@Override protected WebDriver initialValue() { System.setProperty("webdriver.gecko.driver", ApplicationConfigProvider.getInstance().getDriverLocation()); FirefoxBinary firefoxBinary = new FirefoxBinary(); firefoxBinary.addCommandLineOptions("--headless"); FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.setBinary(firefoxBinary); return new FirefoxDriver(firefoxOptions); // can be replaced with other browser drivers }
Example 9
Source File: HTMLLauncher.java From selenium with Apache License 2.0 | 5 votes |
private WebDriver createDriver(String browser) { String[] parts = browser.split(" ", 2); browser = parts[0]; switch (browser) { case "*chrome": case "*firefox": case "*firefoxproxy": case "*firefoxchrome": case "*pifirefox": FirefoxOptions options = new FirefoxOptions().setLegacy(false); if (parts.length > 1) { options.setBinary(parts[1]); } return new FirefoxDriver(options); case "*iehta": case "*iexplore": case "*iexploreproxy": case "*piiexplore": return new InternetExplorerDriver(); case "*googlechrome": return new ChromeDriver(); case "*MicrosoftEdge": return new EdgeDriver(); case "*opera": case "*operablink": return new OperaDriver(); case "*safari": case "*safariproxy": return new SafariDriver(); default: throw new RuntimeException("Unrecognized browser: " + browser); } }
Example 10
Source File: FirefoxDriverHandler.java From selenium-jupiter with Apache License 2.0 | 4 votes |
@Override public MutableCapabilities getOptions(Parameter parameter, Optional<Object> testInstance) throws IOException, IllegalAccessException { FirefoxOptions firefoxOptions = new FirefoxOptions(); if (parameter != null) { // @Arguments Arguments arguments = parameter.getAnnotation(Arguments.class); if (arguments != null) { stream(arguments.value()).forEach(firefoxOptions::addArguments); } // @Extensions Extensions extensions = parameter.getAnnotation(Extensions.class); if (extensions != null) { for (String extension : extensions.value()) { FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.addExtension(getExtension(extension)); firefoxOptions.setProfile(firefoxProfile); } } // @Binary Binary binary = parameter.getAnnotation(Binary.class); if (binary != null) { firefoxOptions.setBinary(binary.value()); } // @Preferences managePreferences(parameter, firefoxOptions); // @Options FirefoxOptions optionsFromAnnotatedField = annotationsReader .getFromAnnotatedField(testInstance, Options.class, FirefoxOptions.class); if (optionsFromAnnotatedField != null) { firefoxOptions = optionsFromAnnotatedField .merge(firefoxOptions); } } return firefoxOptions; }