FirefoxProfile p = new FirefoxProfile(); p.setPreference("javascript.enabled", false); driver = new FirefoxDriver(p);
private FirefoxOptions transferFirefoxProfileFromSystemProperties(FirefoxOptions currentFirefoxOptions) { String prefix = "firefoxprofile."; FirefoxProfile profile = Optional.ofNullable(currentFirefoxOptions.getProfile()) .orElseGet(FirefoxProfile::new); for (String key : System.getProperties().stringPropertyNames()) { if (key.startsWith(prefix)) { String capability = key.substring(prefix.length()); String value = System.getProperties().getProperty(key); log.config("Use " + key + "=" + value); if (value.equals("true") || value.equals("false")) { profile.setPreference(capability, Boolean.valueOf(value)); } else if (value.matches("^-?\\d+$")) { //if integer profile.setPreference(capability, Integer.parseInt(value)); } else { profile.setPreference(capability, value); } } } return currentFirefoxOptions.setProfile(profile); } }
@BeforeEach public void setup(@TempDirectory.TempDir Path folder) throws IOException { Assumptions.assumeTrue(Boolean.getBoolean("smoke.test"), "Smoke tests disabled (set System property 'smoke.test')"); this.downloadDir = folder.toFile(); FirefoxProfile fxProfile = new FirefoxProfile(); fxProfile.setPreference("browser.download.folderList", 2); fxProfile.setPreference("browser.download.manager.showWhenStarting", false); fxProfile.setPreference("browser.download.dir", this.downloadDir.getAbsolutePath()); fxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/zip,application/x-compress,application/octet-stream"); FirefoxOptions options = new FirefoxOptions().setProfile(fxProfile); this.driver = new FirefoxDriver(options); ((JavascriptExecutor) this.driver).executeScript("window.focus();"); Actions actions = new Actions(this.driver); this.enterAction = actions.sendKeys(Keys.ENTER).build(); }
FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("network.proxy.type", 1); profile.setPreference("network.proxy.socks", "127.0.0.1"); profile.setPreference("network.proxy.socks_port", 9150); FirefoxDriver = new FirefoxDriver(profile);
FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("permissions.default.stylesheet", 2); profile.setPreference("permissions.default.image", 2); FirefoxDriver browser = new FirefoxDriver(profile);
FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("javascript.enabled", false); WebDriver driver = new FirefoxDriver(profile);
File torProfileDir = new File( "...\\Tor Browser\\Data\\Browser\\profile.default"); FirefoxBinary binary = new FirefoxBinary(new File( "...\\Tor Browser\\Start Tor Browser.exe")); FirefoxProfile torProfile = new FirefoxProfile(torProfileDir); torProfile.setPreference("webdriver.load.strategy", "unstable"); try { binary.startProfile(torProfile, torProfileDir, ""); } catch (IOException e) { e.printStackTrace(); }
private RemoteWebDriver webDriver(final String seleniumBrowser) { if ("chrome".equals(seleniumBrowser)) { return new ChromeDriver(); } if ("safari".equals(seleniumBrowser)) { return new SafariDriver(); } FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("focusmanager.testmode", true); return new FirefoxDriver(profile); } }
profile.setPreference("browser.download.panel.shown", false); profile.setPreference("browser.helperApps.neverAsk.openFile", "text/csv,application/vnd.ms-excel"); profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "text/csv,application/vnd.ms-excel"); profile.setPreference("browser.download.folderList", 2); profile.setPreference("browser.download.dir", System.getProperty("java.io.tmpdir"));
public void activateProxy(final FirefoxProfile profile, String proxyUrl, String proxyPort) { profile.setPreference(FIREFOX_NETWORK_PROXY_HTTP, proxyUrl); profile.setPreference(FIREFOX_NETWORK_PROXY_HTTP_PORT, proxyPort); profile.setPreference(FIREFOX_NETWORK_PROXY_TYPE, "1"); }
public void applyTo(FirefoxProfile profile) { if (value instanceof Boolean) { profile.setPreference(key, (Boolean) value); } else if (value instanceof Integer) { profile.setPreference(key, (Integer) value); } else { profile.setPreference(key, value.toString()); } } }
FirefoxProfile fxProfile = new FirefoxProfile(); fxProfile.setPreference("browser.download.folderList", 2); fxProfile.setPreference("browser.download.manager.showWhenStarting", false); fxProfile.setPreference("browser.download.dir","c:\\tmp"); fxProfile.setPreference("browser.helperApps.alwaysAsk.force", false); fxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream"); setDriver(TestBench.createDriver(new FirefoxDriver(fxProfile)));
FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.setPreference("browser.download.folderList",2); firefoxProfile.setPreference("browser.download.manager.showWhenStarting",false); firefoxProfile.setPreference("browser.download.dir","c:\\downloads"); firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","text/csv"); WebDriver driver = new FirefoxDriver(firefoxProfile);
FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("browser.download.folderList", 2); profile.setPreference("browser.download.dir", "C:\\Windows\\temp"); profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/vnd.ms-excel"); profile.setPreference("pdfjs.disabled", true); // disable the built-in PDF viewer WebDriver driver = new FirefoxDriver(profile); driver.get("http://www.exinfm.com/free_spreadsheets.html"); driver.findElement(By.linkText("Capital Budgeting Analysis")).click();
public FirefoxProfileBuilder withRandomPort() { firefoxProfile .setPreference(FirefoxProfile.PORT_PREFERENCE, new Random().nextInt(64510) + 1024); return this; }
public void addFirebugsTo(final FirefoxProfile profile) { try { profile.addExtension(this.getClass(), FIREBUGS_XPI_FILE); profile.setPreference("extensions.firebug.currentVersion", MAX_FIREBUGS_VERSION); // Avoid startup screen profile.addExtension(this.getClass(), FIREFINDER_XPI_FILE); profile.setPreference("extensions.firebug.currentVersion", MAX_FIREFINDER_VERSION); // Avoid startup screen } catch (IOException e) { LOGGER.warn("Failed to add Firebugs extension to Firefox"); } }
public static FirefoxProfile createFirefoxProfile(String locales) { File tmpDir = new File(System.getProperty("java.io.tmpdir"), "wt-ffprofile"); tmpDir.mkdirs(); FirefoxProfile profile = new FirefoxProfile(tmpDir); if (locales !=null) { profile.setPreference("intl.accept_languages", locales); } return profile; } }
File file = new File("firebug-1.8.1.xpi"); FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.addExtension(file); firefoxProfile.setPreference("extensions.firebug.currentVersion", "1.8.1"); // Avoid startup screen WebDriver driver = new FirefoxDriver(firefoxProfile);
ProfilesIni allProfiles = new ProfilesIni(); FirefoxProfile profile = allProfiles.getProfile("Your-profile-name"); profile.setPreference( "intl.accept_languages", "no,en-us,en" ); FirefoxDriver driver = new FirefoxDriver(profile); driver.get("http://www.mysite.com/");
protected FirefoxProfile createNewFirefoxProfile() { FirefoxProfile profile; if (Thucydides.getFirefoxProfile() != null) { profile = Thucydides.getFirefoxProfile(); } else { profile = new FirefoxProfile(); profile.setPreference("network.proxy.socks_port",9999); profile.setAlwaysLoadNoFocusLib(true); profile.setEnableNativeEvents(true); } return profile; }