Java Code Examples for org.openqa.selenium.firefox.FirefoxProfile#setPreference()
The following examples show how to use
org.openqa.selenium.firefox.FirefoxProfile#setPreference() .
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: FirefoxDriverConfig.java From jmeter-plugins-webdriver with Apache License 2.0 | 6 votes |
FirefoxProfile createProfile() { FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("app.update.enabled", false); String userAgentOverride = getUserAgentOverride(); if (StringUtils.isNotEmpty(userAgentOverride)) { profile.setPreference("general.useragent.override", userAgentOverride); } String ntlmOverride = getNtlmSetting(); if (StringUtils.isNotEmpty(ntlmOverride)) { profile.setPreference("network.negotiate-auth.allow-insecure-ntlm-v1", true); } addExtensions(profile); setPreferences(profile); return profile; }
Example 2
Source File: FirefoxDriverConfig.java From jmeter-plugins-webdriver with Apache License 2.0 | 6 votes |
private void setPreferences(FirefoxProfile profile) { JMeterProperty property = getProperty(PREFERENCES); if (property instanceof NullProperty) { return; } CollectionProperty rows = (CollectionProperty) property; for (int i = 0; i < rows.size(); i++) { ArrayList row = (ArrayList) rows.get(i).getObjectValue(); String name = ((JMeterProperty) row.get(0)).getStringValue(); String value = ((JMeterProperty) row.get(1)).getStringValue(); switch (value) { case "true": profile.setPreference(name, true); break; case "false": profile.setPreference(name, false); break; default: profile.setPreference(name, value); break; } } }
Example 3
Source File: FireFoxProxyViaProfile.java From at.info-knowledge-base with MIT License | 6 votes |
@BeforeMethod public void setUpProxy() throws Exception { DesiredCapabilities capabilities = new DesiredCapabilities(); FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("network.proxy.type", 1); profile.setPreference("network.proxy.http", proxyIp); profile.setPreference("network.proxy.http_port", port); capabilities.setCapability(FirefoxDriver.PROFILE, profile); driver = new FirefoxDriver(capabilities); //or //driver = new FirefoxDriver(profile); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); }
Example 4
Source File: DefaultSessionFactory.java From JTAF-ExtWebDriver with Apache License 2.0 | 5 votes |
/** * * @param ffp * for use in setting the firefox profile for the tests to use * when running firefox */ private static void addPreferences(FirefoxProfile ffp) { 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"); }
Example 5
Source File: FirefoxCapabilitiesFactory.java From seleniumtestsframework with Apache License 2.0 | 5 votes |
protected void configProfile(final FirefoxProfile profile, final DriverConfig webDriverConfig) { profile.setAcceptUntrustedCertificates(webDriverConfig.isSetAcceptUntrustedCertificates()); profile.setAssumeUntrustedCertificateIssuer(webDriverConfig.isSetAssumeUntrustedCertificateIssuer()); if (webDriverConfig.getFirefoxBinPath() != null) { System.setProperty("webdriver.firefox.bin", webDriverConfig.getFirefoxBinPath()); } if (webDriverConfig.getUserAgentOverride() != null) { profile.setPreference("general.useragent.override", webDriverConfig.getUserAgentOverride()); } if (webDriverConfig.getNtlmAuthTrustedUris() != null) { profile.setPreference("network.automatic-ntlm-auth.trusted-uris", webDriverConfig.getNtlmAuthTrustedUris()); } if (webDriverConfig.getBrowserDownloadDir() != null) { profile.setPreference("browser.download.dir", webDriverConfig.getBrowserDownloadDir()); profile.setPreference("browser.download.folderList", 2); profile.setPreference("browser.download.manager.showWhenStarting", false); profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream,text/plain,application/pdf,application/zip,text/csv,text/html"); } if (!webDriverConfig.isEnableJavascript()) { profile.setPreference("javascript.enabled", false); } // fix permission denied issues profile.setPreference("capability.policy.default.Window.QueryInterface", "allAccess"); profile.setPreference("capability.policy.default.Window.frameElement.get", "allAccess"); profile.setPreference("capability.policy.default.HTMLDocument.compatMode.get", "allAccess"); profile.setPreference("capability.policy.default.Document.compatMode.get", "allAccess"); profile.setPreference("dom.max_chrome_script_run_time", 0); profile.setPreference("dom.max_script_run_time", 0); }
Example 6
Source File: ProfileFactory.java From Asqatasun with GNU Affero General Public License v3.0 | 5 votes |
/** * * @param firefoxProfile */ private void setUpPreferences(FirefoxProfile firefoxProfile, boolean loadImage) { // to have a blank page on start-up firefoxProfile.setPreference("browser.startup.page", 0); firefoxProfile.setPreference("browser.cache.disk.capacity", 0); firefoxProfile.setPreference("browser.cache.disk.enable", false); firefoxProfile.setPreference("browser.cache.disk.smart_size.enabled", false); firefoxProfile.setPreference("browser.cache.disk.smart_size.first_run", false); firefoxProfile.setPreference("browser.cache.disk.smart_size_cached_value", 0); firefoxProfile.setPreference("browser.cache.memory.enable", false); firefoxProfile.setPreference("browser.shell.checkDefaultBrowser", false); firefoxProfile.setPreference("browser.startup.homepage_override.mstone", "ignore"); firefoxProfile.setPreference("browser.preferences.advanced.selectedTabIndex", 0); firefoxProfile.setPreference("browser.privatebrowsing.autostart", false); firefoxProfile.setPreference("browser.link.open_newwindow", 2); firefoxProfile.setPreference("Network.cookie.cookieBehavior", 1); firefoxProfile.setPreference("signon.autologin.proxy", true); // to disable the update of search engines firefoxProfile.setPreference("browser.search.update", false); if (loadImage) { // To enable the load of images firefoxProfile.setPreference("permissions.default.image", 1); }else { // To disable the load of images firefoxProfile.setPreference("permissions.default.image", 2); } }
Example 7
Source File: BotStyleTest.java From adf-selenium with Apache License 2.0 | 5 votes |
@Before public void setup() { final FirefoxProfile profile = new FirefoxProfile(); profile.setEnableNativeEvents(true); profile.setPreference("app.update.enabled", false); driver = new FirefoxDriver(profile); DialogManager.init(driver, TIMEOUT_MSECS); dialogManager = DialogManager.getInstance(); }
Example 8
Source File: FirefoxUser.java From full-teaching with Apache License 2.0 | 5 votes |
public FirefoxUser(String userName, int timeOfWaitInSeconds) { super(userName, timeOfWaitInSeconds); DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("acceptInsecureCerts", true); FirefoxProfile profile = new FirefoxProfile(); // This flag avoids granting the access to the camera profile.setPreference("media.navigator.permission.disabled", true); // This flag force to use fake user media (synthetic video of multiple color) profile.setPreference("media.navigator.streams.fake", true); capabilities.setCapability(FirefoxDriver.PROFILE, profile); String eusApiURL = System.getenv("ET_EUS_API"); if(eusApiURL == null) { this.driver = new FirefoxDriver(capabilities); } else { try { capabilities.setBrowserName("firefox"); this.driver = new RemoteWebDriver(new URL(eusApiURL), capabilities); } catch (MalformedURLException e) { throw new RuntimeException("Exception creaing eusApiURL",e); } } this.driver.manage().timeouts().setScriptTimeout(this.timeOfWaitInSeconds, TimeUnit.SECONDS); this.configureDriver(); }
Example 9
Source File: FirefoxUser.java From openvidu with Apache License 2.0 | 5 votes |
public FirefoxUser(String userName, int timeOfWaitInSeconds) { super(userName, timeOfWaitInSeconds); DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setAcceptInsecureCerts(true); capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE); FirefoxProfile profile = new FirefoxProfile(); // This flag avoids granting the access to the camera profile.setPreference("media.navigator.permission.disabled", true); // This flag force to use fake user media (synthetic video of multiple color) profile.setPreference("media.navigator.streams.fake", true); capabilities.setCapability(FirefoxDriver.PROFILE, profile); String REMOTE_URL = System.getProperty("REMOTE_URL_FIREFOX"); if (REMOTE_URL != null) { log.info("Using URL {} to connect to remote web driver", REMOTE_URL); try { this.driver = new RemoteWebDriver(new URL(REMOTE_URL), capabilities); } catch (MalformedURLException e) { e.printStackTrace(); } } else { log.info("Using local web driver"); this.driver = new FirefoxDriver(capabilities); } this.configureDriver(); }
Example 10
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 11
Source File: SeleniumWrapper.java From SeleniumBestPracticesBook with Apache License 2.0 | 5 votes |
public SeleniumWrapper(String browser) { if (browser.equals("firefox")) { FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("network.proxy.type", 1); profile.setPreference("network.proxy.http", "127.0.0.1"); profile.setPreference("network.proxy.http_port", 9999); profile .setPreference("network.proxy.no_proxies_on", "localhost, 127.0.0.1, *awful-valentine.com"); selenium = new FirefoxDriver(profile); } }
Example 12
Source File: FirefoxSettingPreferences.java From Selenium-WebDriver-3-Practical-Guide-Second-Edition with MIT License | 5 votes |
public static void main(String... args) { System.setProperty("webdriver.gecko.driver", "./src/test/resources/drivers/geckodriver 2"); FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("general.useragent.override", "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) " + "AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 " + " Mobile/15A356 Safari/604.1"); FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.setProfile(profile); FirefoxDriver driver = new FirefoxDriver(firefoxOptions); driver.get("http://facebook.com"); }
Example 13
Source File: BrowserDriver.java From SWET with MIT License | 4 votes |
@SuppressWarnings("deprecation") private static DesiredCapabilities capabilitiesFirefox() { final String geckoDriverPath = (applicationGeckoDriverPath == null) ? osName.toLowerCase().startsWith("windows") ? "c:/java/selenium/geckodriver.exe" : "/var/run/geckodriver" : applicationGeckoDriverPath; // firefox.browser.path final String firefoxBrowserPath = (applicationFirefoxBrowserPath == null) ? osName.toLowerCase().startsWith("windows") ? "c:/Program Files (x86)/Mozilla Firefox/firefox.exe" : osName.toLowerCase().startsWith("mac") ? "/Applications/Firefox.app/Contents/MacOS/firefox.bin" : "/usr/bin/firefox/firefox" : applicationFirefoxBrowserPath; System.setProperty("webdriver.gecko.driver", new File(geckoDriverPath).getAbsolutePath()); System.setProperty("webdriver.firefox.bin", new File(firefoxBrowserPath).getAbsolutePath()); System.setProperty("webdriver.reap_profile", "false"); DesiredCapabilities capabilities = DesiredCapabilities.firefox(); // TODO: switch to Selenium 3.X+ /* FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.setBinary(new File(firefoxBrowserPath).getAbsolutePath()); capabilities.setCapability("moz:firefoxOptions", firefoxOptions); */ capabilities.setCapability("firefox_binary", new File(firefoxBrowserPath).getAbsolutePath()); capabilities.setCapability("marionette", false); FirefoxProfile profile = new FirefoxProfile(); // no longer exists in Selenium // profile.setEnableNativeEvents(true); profile.setAcceptUntrustedCertificates(true); profile.setAssumeUntrustedCertificateIssuer(false); // Disable Firefox Auto-Updating profile.setPreference("app.update.auto", false); profile.setPreference("app.update.enabled", false); capabilities.setCapability(FirefoxDriver.PROFILE, profile); capabilities.setCapability("elementScrollBehavior", 1); capabilities.setBrowserName(DesiredCapabilities.firefox().getBrowserName()); return capabilities; }
Example 14
Source File: BrowserUtils.java From jlineup with Apache License 2.0 | 4 votes |
private FirefoxProfile getFirefoxProfileWithDisabledAnimatedGifs() { FirefoxProfile firefoxProfileHeadless = new FirefoxProfile(); firefoxProfileHeadless.setPreference("image.animation_mode", "none"); return firefoxProfileHeadless; }
Example 15
Source File: ProfileFactory.java From Asqatasun with GNU Affero General Public License v3.0 | 4 votes |
/** * Add entension * @param firefoxProfile */ private void setUpExtensions(FirefoxProfile firefoxProfile) { for (String extensionPath : extensionPathList) { try { firefoxProfile.addExtension(new File(extensionPath)); } catch (IOException ex) { Logger.getLogger(this.getClass()).error(ex); } } //---------------------------------------------------------------------- // Firebug options //---------------------------------------------------------------------- firefoxProfile.setPreference("extensions.firebug.allPagesActivation", "on"); firefoxProfile.setPreference("extensions.firebug.defaultPanelName", "net"); firefoxProfile.setPreference("extensions.firebug.net.enableSites", true); firefoxProfile.setPreference("extensions.firebug.script.enableSites", true); firefoxProfile.setPreference("extensions.firebug.onByDefault",true); firefoxProfile.setPreference("extensions.firebug.currentVersion", firebugVersion); //---------------------------------------------------------------------- //---------------------------------------------------------------------- // NetExport options //---------------------------------------------------------------------- // Auto export feature is enabled by default. firefoxProfile.setPreference("extensions.firebug.netexport.alwaysEnableAutoExport", true); // Auto export feature stores results into a local file firefoxProfile.setPreference("extensions.firebug.netexport.autoExportToFile", true); // Auto export feature sends results to the server (default is false) firefoxProfile.setPreference("extensions.firebug.netexport.autoExportToServer", false); // Show preview of exported data by default. firefoxProfile.setPreference("extensions.firebug.netexport.showPreview", false); // Displaye confirmation before uploading collecetd data to the server yes/no. firefoxProfile.setPreference("extensions.firebug.netexport.sendToConfirmation", false); // Number of milliseconds to wait after the last page request to declare the page loaded. // We don't wast time // firefoxProfile.setPreference("extensions.firebug.netexport.pageLoadedTimeout", pageLoadedTimeout); // Number of milliseconds to wait after the page is exported even if not loaded yet. // Set to zero to switch off this feature. // firefoxProfile.setPreference("extensions.firebug.netexport.timeout", timeout); // firefoxProfile.setPreference("extensions.firebug.netexport.Automation", true); // Default log directory for auto-exported HAR files. firefoxProfile.setPreference("extensions.firebug.netexport.defaultLogDir", createRandomNetExportPath(firefoxProfile)); }
Example 16
Source File: WebDriverCapabilities.java From QVisual with Apache License 2.0 | 4 votes |
private void setupFirefox() { FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.setPreference("dom.webnotifications.enabled", false); firefoxProfile.setAcceptUntrustedCertificates(true); firefoxProfile.setPreference("app.update.enabled", false); firefoxProfile.setPreference("devtools.devedition.promo.url", ""); firefoxProfile.setPreference("xpinstall.signatures.required", false); firefoxProfile.setPreference("browser.startup.homepage;about:home", "about:blank"); firefoxProfile.setPreference("browser.startup.homepage_override.mstone", "ignore"); firefoxProfile.setPreference("browser.usedOnWindows10", false); firefoxProfile.setPreference("browser.usedOnWindows10.introURL", "about:blank"); firefoxProfile.setPreference("startup.homepage_welcome_url", "about:blank"); firefoxProfile.setPreference("startup.homepage_welcome_url.additional", "about:blank"); firefoxProfile.setPreference("browser.helperApps.alwaysAsk.force", false); firefoxProfile.setPreference("browser.download.folderList", 2); firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false); firefoxProfile.setPreference("browser.download.manager.useWindow", false); firefoxProfile.setPreference("browser.download.manager.alertOnEXEOpen", false); firefoxProfile.setPreference("browser.download.dir", DOWNLOAD_DIRECTORY); firefoxProfile.setPreference("browser.download.manager.focusWhenStarting", false); firefoxProfile.setPreference("browser.download.useDownloadDir", true); firefoxProfile.setPreference("browser.download.manager.closeWhenDone", true); firefoxProfile.setPreference("browser.download.manager.showAlertOnComplete", false); firefoxProfile.setPreference("browser.download.panel.shown", false); firefoxProfile.setPreference("services.sync.prefs.sync.browser.download.manager.showWhenStarting", false); firefoxProfile.setPreference("pdfjs.disabled", true); firefoxProfile.setPreference("plugin.scan.Acrobat", "99.0"); firefoxProfile.setPreference("plugin.scan.plid.all", false); firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/x-msdownload," + "application/AppleLink," + "application/x-newton-compatible-pkg," + "image/png," + "application/ris," + "text/csv," + "text/xml," + "text/html," + "text/plain," + "application/xml," + "application/zip," + "application/x-zip," + "application/x-zip-compressed," + "application/download," + "application/octet-stream," + "application/excel," + "application/vnd.ms-excel," + "application/x-excel," + "application/x-msexcel," + "application/vnd.openxmlformats-officedocument.spreadsheetml.template," + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet," + "application/msword," + "application/csv," + "application/pdf," + "application/vnd.openxmlformats-officedocument.wordprocessingml.document," + "application/vnd.openxmlformats-officedocument.wordprocessingml.template"); FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.setProfile(firefoxProfile); firefoxOptions.setHeadless(BROWSER_HEADLESS); capabilities.merge(firefoxOptions); }
Example 17
Source File: CreateDriver.java From Selenium-Framework-Design-in-Data-Driven-Testing with MIT License | 4 votes |
/** * setDriver method to create driver instance * * @param browser * @param environment * @param platform * @param optPreferences * @throws Exception */ @SafeVarargs public final void setDriver(String browser, String platform, String environment, Map<String, Object>... optPreferences) throws Exception { DesiredCapabilities caps = null; String getPlatform = null; props.load(new FileInputStream(Global_VARS.SE_PROPS)); switch (browser) { case "firefox": caps = DesiredCapabilities.firefox(); FirefoxOptions ffOpts = new FirefoxOptions(); FirefoxProfile ffProfile = new FirefoxProfile(); ffProfile.setPreference("browser.autofocus", true); ffProfile.setPreference("browser.tabs.remote.autostart.2", false); caps.setCapability(FirefoxDriver.PROFILE, ffProfile); caps.setCapability("marionette", true); // then pass them to the local WebDriver if ( environment.equalsIgnoreCase("local") ) { System.setProperty("webdriver.gecko.driver", props.getProperty("gecko.driver.windows.path")); webDriver.set(new FirefoxDriver(ffOpts.merge(caps))); } break; case "chrome": caps = DesiredCapabilities.chrome(); ChromeOptions chOptions = new ChromeOptions(); Map<String, Object> chromePrefs = new HashMap<String, Object>(); chromePrefs.put("credentials_enable_service", false); chOptions.setExperimentalOption("prefs", chromePrefs); chOptions.addArguments("--disable-plugins", "--disable-extensions", "--disable-popup-blocking"); caps.setCapability(ChromeOptions.CAPABILITY, chOptions); caps.setCapability("applicationCacheEnabled", false); if ( environment.equalsIgnoreCase("local") ) { System.setProperty("webdriver.chrome.driver", props.getProperty("chrome.driver.windows.path")); webDriver.set(new ChromeDriver(chOptions.merge(caps))); } break; case "internet explorer": caps = DesiredCapabilities.internetExplorer(); InternetExplorerOptions ieOpts = new InternetExplorerOptions(); ieOpts.requireWindowFocus(); ieOpts.merge(caps); caps.setCapability("requireWindowFocus", true); if ( environment.equalsIgnoreCase("local") ) { System.setProperty("webdriver.ie.driver", props.getProperty("ie.driver.windows.path")); webDriver.set(new InternetExplorerDriver(ieOpts.merge(caps))); } break; } getEnv = environment; getPlatform = platform; sessionId.set(((RemoteWebDriver) webDriver.get()).getSessionId().toString()); sessionBrowser.set(caps.getBrowserName()); sessionVersion.set(caps.getVersion()); sessionPlatform.set(getPlatform); System.out.println("\n*** TEST ENVIRONMENT = " + getSessionBrowser().toUpperCase() + "/" + getSessionPlatform().toUpperCase() + "/" + getEnv.toUpperCase() + "/Selenium Version=" + props.getProperty("selenium.revision") + "/Session ID=" + getSessionId() + "\n"); getDriver().manage().timeouts().implicitlyWait(IMPLICIT_TIMEOUT, TimeUnit.SECONDS); getDriver().manage().window().maximize(); }
Example 18
Source File: Section18_Lecture120_WebDriverWaitCustomExpectedConditions.java From webDriverExperiments with MIT License | 4 votes |
@BeforeClass public static void setUp(){ FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("network.proxy.type", 0); driver = new FirefoxDriver(profile); }
Example 19
Source File: AbstractCapabilities.java From carina with Apache License 2.0 | 4 votes |
/** * Generate default default Carina FirefoxProfile. * * @return Firefox profile. */ // keep it public to be bale to get default and override on client layerI public FirefoxProfile getDefaultFirefoxProfile() { FirefoxProfile profile = new FirefoxProfile(); // update browser language String browserLang = Configuration.get(Parameter.BROWSER_LANGUAGE); if (!browserLang.isEmpty()) { LOGGER.info("Set Firefox lanaguage to: " + browserLang); profile.setPreference("intl.accept_languages", browserLang); } boolean generated = false; int newPort = 7055; int i = 100; while (!generated && (--i > 0)) { newPort = PortProber.findFreePort(); generated = firefoxPorts.add(newPort); } if (!generated) { newPort = 7055; } if (firefoxPorts.size() > 20) { firefoxPorts.remove(0); } profile.setPreference(FirefoxProfile.PORT_PREFERENCE, newPort); LOGGER.debug("FireFox profile will use '" + newPort + "' port number."); profile.setPreference("dom.max_chrome_script_run_time", 0); profile.setPreference("dom.max_script_run_time", 0); if (Configuration.getBoolean(Configuration.Parameter.AUTO_DOWNLOAD) && !(Configuration.isNull(Configuration.Parameter.AUTO_DOWNLOAD_APPS) || "".equals(Configuration.get(Configuration.Parameter.AUTO_DOWNLOAD_APPS)))) { profile.setPreference("browser.download.folderList", 2); profile.setPreference("browser.download.dir", getAutoDownloadFolderPath()); profile.setPreference("browser.helperApps.neverAsk.saveToDisk", Configuration.get(Configuration.Parameter.AUTO_DOWNLOAD_APPS)); profile.setPreference("browser.download.manager.showWhenStarting", false); profile.setPreference("browser.download.saveLinkAsFilenameTimeout", 1); profile.setPreference("pdfjs.disabled", true); profile.setPreference("plugin.scan.plid.all", false); profile.setPreference("plugin.scan.Acrobat", "99.0"); } else if (Configuration.getBoolean(Configuration.Parameter.AUTO_DOWNLOAD) && Configuration.isNull(Configuration.Parameter.AUTO_DOWNLOAD_APPS) || "".equals(Configuration.get(Configuration.Parameter.AUTO_DOWNLOAD_APPS))) { LOGGER.warn( "If you want to enable auto-download for FF please specify '" + Configuration.Parameter.AUTO_DOWNLOAD_APPS.getKey() + "' param"); } profile.setAcceptUntrustedCertificates(true); profile.setAssumeUntrustedCertificateIssuer(true); // TODO: implement support of custom args if any return profile; }
Example 20
Source File: Section18_Lecture120_WebDriverWaitCustomExpectedConditions.java From webDriverExperiments with MIT License | 4 votes |
@BeforeClass public static void setUp(){ FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("network.proxy.type", 0); driver = new FirefoxDriver(profile); }