Java Code Examples for org.openqa.selenium.firefox.FirefoxOptions#addPreference()
The following examples show how to use
org.openqa.selenium.firefox.FirefoxOptions#addPreference() .
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: WebRtcRemoteFirefoxTest.java From webdrivermanager-examples with Apache License 2.0 | 5 votes |
@Before public void setup() throws MalformedURLException { DesiredCapabilities capabilities = new DesiredCapabilities(); FirefoxOptions options = new FirefoxOptions(); options.addPreference("media.navigator.permission.disabled", true); options.addPreference("media.navigator.streams.fake", true); capabilities.setCapability(FIREFOX_OPTIONS, options); driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities); }
Example 2
Source File: WebRtcFirefoxTest.java From webdrivermanager-examples with Apache License 2.0 | 5 votes |
@Before public void setupTest() { FirefoxOptions options = new FirefoxOptions(); // This flag avoids granting the access to the camera options.addPreference("media.navigator.permission.disabled", true); // This flag force to use fake user media (synthetic video of multiple // color) options.addPreference("media.navigator.streams.fake", true); driver = new FirefoxDriver(options); }
Example 3
Source File: TestUtils.java From enmasse with Apache License 2.0 | 5 votes |
public static RemoteWebDriver getFirefoxDriver() throws Exception { Endpoint endpoint = SystemtestsKubernetesApps.getFirefoxSeleniumAppEndpoint(Kubernetes.getInstance()); FirefoxOptions options = new FirefoxOptions(); // https://github.com/mozilla/geckodriver/issues/330 enable the emission of console.info(), warn() // etc // to stdout of the browser process. Works around the fact that Firefox logs are not available // through // WebDriver.manage().logs(). options.addPreference("devtools.console.stdout.content", true); options.addPreference("browser.tabs.unloadOnLowMemory", false); return getRemoteDriver(endpoint.getHost(), endpoint.getPort(), options); }
Example 4
Source File: Browser.java From kurento-java with Apache License 2.0 | 5 votes |
private void createFirefoxBrowser(DesiredCapabilities capabilities) throws MalformedURLException { if (scope == BrowserScope.LOCAL) { WebDriverManager.firefoxdriver().setup(); } FirefoxOptions firefoxOptions = new FirefoxOptions(); // This flag avoids granting the access to the camera firefoxOptions.addPreference("media.navigator.permission.disabled", true); // This flag force to use fake user media (synthetic video of multiple color) firefoxOptions.addPreference("media.navigator.streams.fake", true); // This allows to load pages with self-signed certificates capabilities.setCapability("acceptInsecureCerts", true); firefoxOptions.setAcceptInsecureCerts(true); capabilities.setCapability(FIREFOX_OPTIONS, firefoxOptions); capabilities.setBrowserName(firefoxOptions.getBrowserName()); // Firefox extensions if (extensions != null && !extensions.isEmpty()) { for (Map<String, String> extension : extensions) { InputStream is = getExtensionAsInputStream(extension.values().iterator().next()); if (is != null) { try { File xpi = File.createTempFile(extension.keySet().iterator().next(), ".xpi"); FileUtils.copyInputStreamToFile(is, xpi); firefoxOptions.getProfile().addExtension(xpi); } catch (Throwable t) { log.error("Error loading Firefox extension {} ({} : {})", extension, t.getClass(), t.getMessage()); } } } } createDriver(capabilities, firefoxOptions); }
Example 5
Source File: AbstractCapabilities.java From carina with Apache License 2.0 | 5 votes |
private DesiredCapabilities addFirefoxOptions(DesiredCapabilities caps) { FirefoxProfile profile = getDefaultFirefoxProfile(); FirefoxOptions options = new FirefoxOptions().setProfile(profile); caps.setCapability(FirefoxOptions.FIREFOX_OPTIONS, options); // add all custom firefox args for (String arg : Configuration.get(Parameter.FIREFOX_ARGS).split(",")) { if (arg.isEmpty()) { continue; } options.addArguments(arg.trim()); } // add all custom firefox preferences for (String preference : Configuration.get(Parameter.CHROME_EXPERIMENTAL_OPTS).split(",")) { if (preference.isEmpty()) { continue; } // TODO: think about equal sign inside name or value later preference = preference.trim(); String name = preference.split("=")[0].trim(); String value = preference.split("=")[1].trim(); // TODO: test approach with numbers if ("true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value)) { options.addPreference(name, Boolean.valueOf(value)); } else { options.addPreference(name, value); } } return caps; }