List of usage examples for org.openqa.selenium.firefox FirefoxProfile setPreference
public void setPreference(String key, Object value)
From source file:org.pentaho.ctools.suite.CToolsTestSuite.java
License:Open Source License
@BeforeClass public static void setUpClass() throws IOException { System.out.println("Master setup"); //System.setProperty("webdriver.log.file", "/dev/stdout"); //System.setProperty("webdriver.firefox.logfile", "/dev/stdout"); //Setting log preferences LoggingPreferences logs = new LoggingPreferences(); logs.enable(LogType.BROWSER, Level.ALL); logs.enable(LogType.SERVER, Level.ALL); logs.enable(LogType.DRIVER, Level.ALL); logs.enable(LogType.PROFILER, Level.ALL); logs.enable(LogType.CLIENT, Level.ALL); logs.enable(LogType.PERFORMANCE, Level.ALL); DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setCapability(CapabilityType.LOGGING_PREFS, logs); //Inicialize DRIVER FirefoxProfile ffProfile = new FirefoxProfile(); ffProfile.setPreference("intl.accept_languages", "en-us"); capabilities.setCapability(FirefoxDriver.PROFILE, ffProfile); JavaScriptError.addExtension(ffProfile); driver = new FirefoxDriver(capabilities); driver.manage().window().maximize(); driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); //Inicialize WAIT wait = new FluentWait<WebDriver>(driver).withTimeout(30, TimeUnit.SECONDS).pollingEvery(1, TimeUnit.SECONDS) .ignoring(org.openqa.selenium.NoSuchElementException.class); //Inicialize BASEURL baseUrl = "http://localhost:8080/pentaho/"; }
From source file:org.qe4j.web.OpenWebDriver.java
License:Open Source License
/** * Construct a new fire fox profile to set auto download to desktop. * * @return FirefoxProfile//from w w w.ja v a2s . c om */ protected FirefoxProfile getFireFoxProfile() { FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("browser.download.dir", getDownloadDir()); profile.setPreference("browser.download.folderList", 0); // desktop profile.setPreference("browser.download.manager.showWhenStarting", false); profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream,application/zip"); return profile; }
From source file:org.safs.selenium.webdriver.lib.SelectBrowser.java
License:Open Source License
/** * Set firefox preference to firefox Profile.<br> * /* w w w . j ava2 s. co m*/ * @param firefoxProfile FirefoxProfile, the firefox Profile object. * @param firefoxPreference Map, the firefox preference to set. */ private static void addFireFoxPreference(FirefoxProfile firefoxProfile, Map<?, ?> firefoxPreference) { try { //profile.setPreference("media.navigator.permission.disabled", true); boolean //profile.setPreference("browser.download.folderList",2); int //profile.setPreference("intl.accept_languages", "en-us" ); String String[] keys = firefoxPreference.keySet().toArray(new String[0]); Object value = null; for (String key : keys) { value = firefoxPreference.get(key); if (value instanceof Boolean) { firefoxProfile.setPreference(key, ((Boolean) value).booleanValue()); } else if (value instanceof Number) { firefoxProfile.setPreference(key, ((Number) value).intValue()); } else { firefoxProfile.setPreference(key, value.toString()); } } } catch (Exception e) { IndependantLog.error(StringUtils.debugmsg(false) + " failed set preference to firefox profile, due to " + StringUtils.debugmsg(e)); } }
From source file:org.securitytests.cisecurity.drivers.DriverFactory.java
License:Open Source License
public WebDriver createFirefoxDriver(DesiredCapabilities capabilities) { if (capabilities != null) { return new FirefoxDriver(capabilities); }//from w ww . jav a2 s . c o m ProfilesIni allProfiles = new ProfilesIni(); FirefoxProfile myProfile = allProfiles.getProfile("WebDriver"); if (myProfile == null) { File ffDir = new File(System.getProperty("user.dir") + File.separator + "ffProfile"); if (!ffDir.exists()) { ffDir.mkdir(); } myProfile = new FirefoxProfile(ffDir); } myProfile.setAcceptUntrustedCertificates(true); myProfile.setAssumeUntrustedCertificateIssuer(true); myProfile.setPreference("webdriver.load.strategy", "unstable"); if (capabilities == null) { capabilities = new DesiredCapabilities(); } capabilities.setCapability(FirefoxDriver.PROFILE, myProfile); return new FirefoxDriver(capabilities); }
From source file:org.sugarcrm.voodoodriver.Firefox.java
License:Apache License
/** * Create a new firefox browser instance. *//*from ww w .j a va2s . com*/ public void newBrowser() { FirefoxBinary b = new FirefoxBinary(); FirefoxProfile p = null; if (this.profile == null) { p = new FirefoxProfile(); } else { p = new FirefoxProfile(new java.io.File(this.profile)); } if (this.downloadDirectory != null) { try { p.setPreference("browser.download.dir", this.downloadDirectory); } catch (java.lang.IllegalArgumentException e) { System.err.println("Ill-formed downloaddir '" + this.downloadDirectory + "'"); System.exit(1); } p.setPreference("browser.download.manager.closeWhenDone", true); p.setPreference("browser.download.manager.retention", 0); p.setPreference("browser.download.manager.showAlertOnComplete", false); p.setPreference("browser.download.manager.scanWhenDone", false); p.setPreference("browser.download.manager.skipWinSecurityPolicyChecks", true); p.setPreference("browser.startup.page", 0); p.setPreference("browser.download.manager.alertOnEXEOpen", false); p.setPreference("browser.download.manager.focusWhenStarting", false); p.setPreference("browser.download.useDownloadDir", true); } if (this.webDriverLogDirectory != null) { File wdl = makeLogfileName(this.webDriverLogDirectory, "webdriver"); File fl = makeLogfileName(this.webDriverLogDirectory, "firefox"); System.out.println("(*) Creating WebDriver log " + wdl); p.setPreference("webdriver.log.file", wdl.toString()); System.out.println("(*) Creating Firefox log " + fl); p.setPreference("webdriver.firefox.logfile", fl.toString()); } DesiredCapabilities c = new DesiredCapabilities(); c.setCapability("unexpectedAlertBehaviour", "ignore"); FirefoxDriver ff = new FirefoxDriver(b, p, c); this.setDriver(ff); this.setBrowserOpened(); }
From source file:org.suren.autotest.web.framework.selenium.CapabilityConfig.java
License:Apache License
/** * firefox/* w w w . j a v a 2 s. co m*/ * @param profile */ private void fireFoxPreSet(FirefoxProfile profile) { BrowserUtil browserUtil = new BrowserUtil(); Map<String, Boolean> boolMap = browserUtil.getFirefoxPreBoolMap(); Iterator<String> boolIt = boolMap.keySet().iterator(); while (boolIt.hasNext()) { String key = boolIt.next(); profile.setPreference(key, boolMap.get(key)); } Map<String, Integer> intMap = browserUtil.getFirefoxPreIntMap(); Iterator<String> intIt = intMap.keySet().iterator(); while (intIt.hasNext()) { String key = intIt.next(); profile.setPreference(key, intMap.get(key)); } Map<String, Integer> strMap = browserUtil.getFirefoxPreIntMap(); Iterator<String> strIt = intMap.keySet().iterator(); while (strIt.hasNext()) { String key = strIt.next(); profile.setPreference(key, strMap.get(key)); } }
From source file:org.terasoluna.gfw.functionaltest.app.FirefoxDriverFactoryBean.java
License:Apache License
@Override public FirefoxDriver getObject() { FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("browser.startup.homepage_override.mstone", "ignore"); profile.setPreference("network.proxy.type", 0); return new FirefoxDriver(profile); }
From source file:org.terasoluna.gfw.tutorial.selenium.FirefoxDriverFactoryBean.java
License:Apache License
@Override public FirefoxDriver getObject() { FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("brouser.startup.homepage_override.mstone", "ignore"); profile.setPreference("network.proxy.type", 0); profile.setPreference("intl.accept_languages", "en-us,en"); return new FirefoxDriver(profile); }
From source file:org.terasoluna.gfw.tutorial.selenium.FunctionTestSupport.java
License:Apache License
private WebDriver newWebDriver() { WebDriver driver = null;/*from w w w . jav a2s .c o m*/ for (String activeProfile : getApplicationContext().getEnvironment().getActiveProfiles()) { if ("chrome".equals(activeProfile)) { driver = new ChromeDriver(); break; } else if ("firefox".equals(activeProfile)) { break; } else if ("ie".equals(activeProfile)) { driver = new InternetExplorerDriver(); break; } } if (driver == null) { FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("brouser.startup.homepage_override.mstone", "ignore"); profile.setPreference("network.proxy.type", 0); driver = new FirefoxDriver(profile); } webDrivers.add(driver); return driver; }
From source file:org.terasoluna.gfw.tutorial.selenium.WebDriverCreator.java
License:Apache License
/** * Create a WebDriver with any locale enabled. * <p>//from w w w . j a v a2s . c o m * Supports FireFox and Chrome only<br> * If you specify "en" as an argument, it starts in the English locale.<br> * If "" is specified as an argument, it starts without a locale. * </p> * @param localeStr * @return WebDriver Operation target browser */ public WebDriver createLocaleSpecifiedDriver(String localeStr) { for (String activeProfile : getApplicationContext().getEnvironment().getActiveProfiles()) { if ("chrome".equals(activeProfile)) { ChromeOptions options = new ChromeOptions(); options.addArguments("--lang=" + localeStr); return new ChromeDriver(options); } else if ("firefox".equals(activeProfile)) { break; } else if ("ie".equals(activeProfile)) { throw new UnsupportedOperationException( "It is not possible to start locale specified browser using InternetExplorer."); } else if ("phantomJs".equals(activeProfile)) { throw new UnsupportedOperationException( "It is not possible to launch locale specified browser using PhantomJS."); } } // The default browser is Firefox FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("intl.accept_languages", localeStr); profile.setPreference("brouser.startup.homepage_override.mstone", "ignore"); profile.setPreference("network.proxy.type", 0); return new FirefoxDriver(profile); }