List of usage examples for org.openqa.selenium.firefox FirefoxProfile setPreference
public void setPreference(String key, Object value)
From source file:com.yufei.dataget.dataretriver.HttpDataRetriverUsingFirefoxDriver.java
@Override public void connect() { FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("permissions.default.stylesheet", 2); profile.setPreference("permissions.default.image", 2); profile.setPreference("dom.ipc.plugins.enabled.libflashplayer.so", "false"); //profile.setPreference("DISPLAY", ":10"); FirefoxBinary fb = new FirefoxBinary(); fb.setEnvironmentProperty("DISPLAY", ":10"); // sudo Xvfb :10 -ac driver = new FirefoxDriver(fb, profile); driver.get(this.url.toString()); }
From source file:com.zaizi.automation.alfresco.drivers.FirefoxDriverStore.java
License:Open Source License
/** * @return/*w w w . j av a2 s.c o m*/ */ public FirefoxDriver createWebDriver() { FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.setPreference("browser.download.folderList", 2); firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false); firefoxProfile.setPreference("browser.download.dir", TestCaseProperties.DEFAULT_DOWNLOAD_PATH); firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/pdf"); firefoxProfile.setPreference("pdfjs.disabled", true); driver = new FirefoxDriver(firefoxProfile); return driver; }
From source file:com.zutubi.pulse.acceptance.SeleniumBrowser.java
License:Apache License
private static WebDriver createWebDriver() { if (SystemUtils.IS_WINDOWS) { return new InternetExplorerDriver(); } else {// w ww .j a va2s .c om FirefoxProfile profile = new FirefoxProfile(); String logFile = System.getProperty("selenium.firefox.log"); if (logFile != null) { profile.setPreference("webdriver.log.file", logFile); } profile.setEnableNativeEvents(true); return new FirefoxDriver(profile); } }
From source file:de.akquinet.devops.test.ui.generic.AbstractUITest.java
License:Apache License
/** * starts a gitblit server instance in a separate thread before test cases * of concrete, non-abstract child-classes are executed *///from w w w. ja va 2s . c om @BeforeClass public static void setUpClass() { Runnable gitblitRunnable = new GitblitRunnable(HTTP_PORT, HTTPS_PORT, SHUTDOWN_PORT, GITBLIT_PROPERTIES_PATH, USERS_PROPERTIES_PATH); serverThread = new Thread(gitblitRunnable); serverThread.start(); FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.setPreference("startup.homepage_welcome_url", "https://www.google.de"); firefoxProfile.setPreference("browser.download.folderList", 2); firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false); String downloadDir = System.getProperty("java.io.tmpdir"); firefoxProfile.setPreference("browser.download.dir", downloadDir); firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "text/csv,text/plain,application/zip,application/pdf"); firefoxProfile.setPreference("browser.helperApps.alwaysAsk.force", false); System.out.println("Saving all attachments to: " + downloadDir); driver = new FirefoxDriver(firefoxProfile); }
From source file:de.ppi.selenium.browser.DefaultWebDriverFactory.java
License:Apache License
/** * * @param ffp for use in setting the firefox profile for the tests to use * when running firefox//ww w . j a v a 2s .c o m */ private static void addPreferences(FirefoxProfile ffp, ClientProperties properties) { ffp.setPreference("capability.policy.default.HTMLDocument.readyState", "allAccess"); ffp.setPreference("capability.policy.default.HTMLDocument.compatMode", "allAccess"); ffp.setPreference("capability.policy.default.Document.compatMode", "allAccess"); ffp.setPreference("capability.policy.default.Location.href", "allAccess"); ffp.setPreference("capability.policy.default.Window.pageXOffset", "allAccess"); ffp.setPreference("capability.policy.default.Window.pageYOffset", "allAccess"); ffp.setPreference("capability.policy.default.Window.frameElement", "allAccess"); ffp.setPreference("capability.policy.default.Window.frameElement.get", "allAccess"); ffp.setPreference("capability.policy.default.Window.QueryInterface", "allAccess"); ffp.setPreference("capability.policy.default.Window.mozInnerScreenY", "allAccess"); ffp.setPreference("capability.policy.default.Window.mozInnerScreenX", "allAccess"); if (properties.getAcceptedLanguages() != null) { ffp.setPreference("intl.accept_languages", properties.getAcceptedLanguages()); } }
From source file:de.ppi.selenium.browser.DefaultWebDriverFactory.java
License:Apache License
/** * * @param ffp the firefox profile you are using * @param propertiesFile the properties you want to add to the profile *//* ww w .ja v a2s . c om*/ private static void addPreferences(FirefoxProfile ffp, String propertiesFile) { Properties firefoxProfile = new Properties(); try { firefoxProfile.load(new FileInputStream(propertiesFile)); } catch (Throwable th) { throw new RuntimeException("Could not load firefox profile", th); } for (Object o : firefoxProfile.keySet()) { String key = (String) o; String getVal = null; if (key.endsWith(".type")) { getVal = key.substring(0, key.lastIndexOf(".")); } if (getVal != null) { String type = firefoxProfile.getProperty(key); String value = firefoxProfile.getProperty(getVal + ".value"); if (value.contains("${PROJECT_PATH}")) { String projectPath = (new File("")).getAbsolutePath(); value = projectPath + value.replaceAll("\\$\\{PROJECT_PATH\\}", ""); } if (type.equalsIgnoreCase("BOOLEAN")) { ffp.setPreference(getVal, Boolean.parseBoolean(value)); } else if (type.equalsIgnoreCase("STRING")) { ffp.setPreference(getVal, value); } else if (type.equalsIgnoreCase("INTEGER") || type.equalsIgnoreCase("INT")) { ffp.setPreference(getVal, Integer.parseInt(value)); } } } }
From source file:dk.netarkivet.systemtest.SeleniumTest.java
License:Open Source License
private void initialiseSelenium() { FirefoxProfile fxProfile = new FirefoxProfile(); fxProfile.setPreference("browser.download.folderList", 2); fxProfile.setPreference("browser.download.manager.showWhenStarting", false); try {//from www . j a va2s . co m fxProfile.setPreference("browser.download.dir", (File.createTempFile("aaaa", "bbbb")).getParentFile().getAbsolutePath()); } catch (IOException e) { throw new RuntimeException(e); } fxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "text/csv"); fxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "text/xml"); fxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "binary/octet-stream"); driver = new FirefoxDriver(fxProfile); driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS); baseUrl = testController.ENV.getGuiHost() + ":" + testController.ENV.getGuiPort(); PageHelper.initialize(driver, baseUrl); TestGUIController.waitForGUIToStart(60); TestEventManager.getInstance().addFixture("Selecting English as language"); driver.findElement(By.linkText("English")).click(); }
From source file:edu.uga.cs.clickminer.ClickminerCLI.java
License:Open Source License
private static void setUnstableLoadingConfig(FirefoxProfile profile) { profile.setPreference("webdriver.load.strategy", "unstable"); }
From source file:edu.uga.cs.clickminer.ClickminerCLI.java
License:Open Source License
private static void setBrowserLoggingConfig(String outLog, String driverLog, DesiredCapabilities cap, FirefoxProfile profile) { if (outLog != null || driverLog != null) { if (driverLog != null) { LoggingPreferences logs = new LoggingPreferences(); logs.enable(LogType.BROWSER, Level.ALL); logs.enable(LogType.DRIVER, Level.ALL); logs.enable(LogType.CLIENT, Level.ALL); logs.enable(LogType.SERVER, Level.ALL); logs.enable(LogType.PROFILER, Level.ALL); cap.setCapability(CapabilityType.LOGGING_PREFS, logs); profile.setPreference("webdriver.log.file", driverLog); }/* w ww. jav a2s . co m*/ if (outLog != null) { System.setProperty("webdriver.firefox.logfile", outLog); } } }
From source file:edu.umd.cs.guitar.crawljax.browser.WebDriverBrowserWrapperBuilder.java
License:Open Source License
/** * Build a new WebDriver based EmbeddedBrowser. * * @see EmbeddedBrowserBuilder#buildEmbeddedBrowser(CrawljaxConfigurationReader) * @param configuration the configuration object to read the config values from * @return the new build WebDriver based embeddedBrowser *///from www . ja va 2 s .c o m @Override public EmbeddedBrowser buildEmbeddedBrowser(CrawljaxConfigurationReader configuration) { // Retrieve the config values used List<String> filterAttributes = configuration.getFilterAttributeNames(); int crawlWaitReload = configuration.getCrawlSpecificationReader().getWaitAfterReloadUrl(); int crawlWaitEvent = configuration.getCrawlSpecificationReader().getWaitAfterEvent(); EmbeddedBrowser internalBrowser; // Determine the requested browser type switch (configuration.getBrowser()) { case firefox: if (configuration.getProxyConfiguration() != null) { FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("network.proxy.http", configuration.getProxyConfiguration().getHostname()); profile.setPreference("network.proxy.http_port", configuration.getProxyConfiguration().getPort()); profile.setPreference("network.proxy.type", configuration.getProxyConfiguration().getType().toInt()); profile.setPreference("network.proxy.no_proxies_on", ""); internalBrowser = WebDriverBackedEmbeddedBrowser.withDriver(new FirefoxDriver(profile), filterAttributes, crawlWaitReload, crawlWaitEvent); break; } else { internalBrowser = WebDriverBackedEmbeddedBrowser.withDriver(new FirefoxDriver(), configuration.getFilterAttributeNames(), configuration.getCrawlSpecificationReader().getWaitAfterEvent(), configuration.getCrawlSpecificationReader().getWaitAfterReloadUrl()); break; } case ie: internalBrowser = WebDriverBackedEmbeddedBrowser.withDriver(new InternetExplorerDriver(), configuration.getFilterAttributeNames(), configuration.getCrawlSpecificationReader().getWaitAfterEvent(), configuration.getCrawlSpecificationReader().getWaitAfterReloadUrl()); break; case chrome: internalBrowser = WebDriverBackedEmbeddedBrowser.withDriver(new ChromeDriver(), configuration.getFilterAttributeNames(), configuration.getCrawlSpecificationReader().getWaitAfterEvent(), configuration.getCrawlSpecificationReader().getWaitAfterReloadUrl()); break; case remote: internalBrowser = WebDriverBackedEmbeddedBrowser.withRemoteDriver(configuration.getRemoteHubUrl(), configuration.getFilterAttributeNames(), configuration.getCrawlSpecificationReader().getWaitAfterEvent(), configuration.getCrawlSpecificationReader().getWaitAfterReloadUrl()); break; case htmlunit: internalBrowser = WebDriverBackedEmbeddedBrowser.withDriver(new HtmlUnitDriver(true), configuration.getFilterAttributeNames(), configuration.getCrawlSpecificationReader().getWaitAfterEvent(), configuration.getCrawlSpecificationReader().getWaitAfterReloadUrl()); break; default: internalBrowser = WebDriverBackedEmbeddedBrowser.withDriver(new FirefoxDriver(), configuration.getFilterAttributeNames(), configuration.getCrawlSpecificationReader().getWaitAfterEvent(), configuration.getCrawlSpecificationReader().getWaitAfterReloadUrl()); break; } WebDriverBackedEmbeddedBrowserWraper browserWrapper = new WebDriverBackedEmbeddedBrowserWraper( internalBrowser); for (CJBrowserMonitor monitor : browserMonitorList) { browserWrapper.addMonitor(monitor); } return browserWrapper; }