List of usage examples for org.openqa.selenium.firefox FirefoxProfile setPreference
public void setPreference(String key, Object value)
From source file:io.github.bonigarcia.wdm.test.WebRtcRemoteFirefoxTest.java
License:Apache License
@Before public void setup() throws MalformedURLException { DesiredCapabilities capabilities = firefox(); FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("media.navigator.permission.disabled", true); profile.setPreference("media.navigator.streams.fake", true); capabilities.setCapability(PROFILE, profile); driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities); }
From source file:io.openvidu.test.browsers.FirefoxUser.java
License:Apache License
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 {/*from www.j a v a2s.c o m*/ 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(); }
From source file:io.spring.initializr.web.project.ProjectGenerationSmokeTests.java
License:Apache License
@Before public void setup() throws IOException { Assume.assumeTrue("Smoke tests disabled (set System property 'smoke.test')", Boolean.getBoolean("smoke.test")); downloadDir = folder.newFolder();// w w w .j av a 2 s.c om FirefoxProfile fxProfile = new FirefoxProfile(); fxProfile.setPreference("browser.download.folderList", 2); fxProfile.setPreference("browser.download.manager.showWhenStarting", false); fxProfile.setPreference("browser.download.dir", downloadDir.getAbsolutePath()); fxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/zip,application/x-compress,application/octet-stream"); FirefoxOptions options = new FirefoxOptions().setProfile(fxProfile); driver = new FirefoxDriver(options); ((JavascriptExecutor) driver).executeScript("window.focus();"); Actions actions = new Actions(driver); enterAction = actions.sendKeys(Keys.ENTER).build(); }
From source file:jp.co.nssol.h5.test.selenium.base.DriverFactory.java
License:Apache License
/** * FireFox????//from ww w. ja v a 2 s . c o m * * @return */ private static WebDriver setupFireFoxDriver() { FirefoxProfile profile = null; try { File file = new File(SettingsReader.getProperty(PKEY_FIREBUG_PATH)); profile = new FirefoxProfile(); profile.addExtension(file); profile.setAcceptUntrustedCertificates(true); profile.setAssumeUntrustedCertificateIssuer(false); profile.setPreference("extensions.firebug.currentVersion", "1.9.1"); } catch (IOException e) { e.printStackTrace(); } return new FirefoxDriver(profile) { @Override public String toString() { return "FireFox"; } }; }
From source file:lenguajes.project.GUI.java
/** * Creates new form GUI//from ww w. j ava 2 s .c o m */ public GUI() { initComponents(); output.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SQL); output.setCodeFoldingEnabled(true); input.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); input.setCodeFoldingEnabled(true); setKeyBindings(); if (cond) { System.setProperty("webdriver.gecko.driver", Config.WEB_DRIVER_PATH); //Create object of FirefoxProfile in built class to access Its properties. FirefoxProfile fprofile = new FirefoxProfile(); //Set Location to store files after downloading. fprofile.setPreference("browser.download.dir", property + Config.DOWNLOAD_DIR); fprofile.setPreference("browser.download.folderList", 2); //Set Preference to not show file download confirmation dialogue using MIME types Of different file extension types. fprofile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;"//MIME types Of MS Excel File. + "application/pdf;" //MIME types Of PDF File. + "application/vnd.openxmlformats-officedocument.wordprocessingml.document;" //MIME types Of MS doc File. + "text/plain;" //MIME types Of text File. + "image/png;" //MIME types Of png Files. + "text/csv"); //MIME types Of CSV File. fprofile.setPreference("browser.download.manager.showWhenStarting", false); fprofile.setPreference("pdfjs.disabled", true); //Pass fprofile parameter In webdriver to use preferences to download file. driver = new FirefoxDriver(fprofile); driver = new FirefoxDriver(fprofile); baseUrl = "http://localhost:7474"; driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); driver.get(baseUrl + "/browser/"); WebDriverWait wait = new WebDriverWait(driver, 10); WebElement element = wait .until(ExpectedConditions.visibilityOfElementLocated(By.id("connect_password"))); element.clear(); element.sendKeys(Config.NEO4J_PASSWORD); driver.findElement(By.id("connect_button")).click(); } drawComponents(); }
From source file:net.continuumsecurity.web.drivers.BurpFirefoxDriver.java
License:Open Source License
public BurpFirefoxDriver() { log.debug("Constructing BurpFirefoxDriver"); //DesiredCapabilities capabilities = new DesiredCapabilities(); //capabilities.setCapability(CapabilityType.PROXY, getBurpProxy()); FirefoxProfile ffProfile = new FirefoxProfile(); ffProfile.setPreference("permissions.default.image", 2); ffProfile.setProxyPreferences(getBurpProxy()); ffDriver = new FirefoxDriver(ffProfile); }
From source file:net.continuumsecurity.web.drivers.DriverFactory.java
License:Open Source License
public WebDriver createFirefoxDriver(DesiredCapabilities capabilities) { if (capabilities != null) { return new FirefoxDriver(capabilities); }/*from ww w . j ava2s . 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:nz.co.testamation.core.WebIntegrationTestAutoConfiguration.java
License:Apache License
@Bean @Autowired// ww w . j a va 2 s. c o m public WebDriver webDriver(@Value("${web.driver:firefox}") String webDriver, @Value("${web.driver.autoDownload.mimeTypes:application/pdf}") String autoDownloadMimeTypes, @Qualifier("webDriverDownloadDir") File downloadDir) { if ("htmlunit".equals(webDriver)) { return new HtmlUnitDriver(); } if ("chrome".equals(webDriver)) { return new ChromeDriver(); } if ("firefox".equals(webDriver)) { FirefoxBinary firefoxBinary = new FirefoxBinary(); if (System.getenv("DISPLAY") == null) { firefoxBinary.setEnvironmentProperty("DISPLAY", ":99"); } FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("browser.download.folderList", 2); // Download to: 0 desktop, 1 default download location, 2 custom folder profile.setPreference("browser.download.dir", downloadDir.getAbsolutePath()); profile.setPreference("browser.download.manager.showWhenStarting", false); profile.setPreference("browser.helperApps.alwaysAsk.force", false); profile.setPreference("browser.helperApps.neverAsk.saveToDisk", autoDownloadMimeTypes); profile.setPreference("plugin.disable_full_page_plugin_for_types", "application/pdf"); profile.setPreference("pdfjs.disabled", true); return new FirefoxDriver(firefoxBinary, profile); } if ("ie".equals(webDriver)) { return new InternetExplorerDriver(); } if ("safari".equals(webDriver)) { return new SafariDriver(); } if ("opera".equals(webDriver)) { return new OperaDriver(); } throw new IllegalArgumentException(format("Web driver %s not supported.", webDriver)); }
From source file:org.ado.picasa.Main.java
License:Apache License
public static void main(String[] args) throws Exception { final Options options = new Options(); options.addOption(new Option("a", "album", true, "Album name")); options.addOption("v", "verification-code", true, "Verification code"); options.addOption("o", "output", true, "Albums output directory"); options.addOption("h", "help", false, "Prints this help"); final CommandLine cmd = new DefaultParser().parse(options, args); if (cmd.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("picasa-crawler", options); System.exit(0);// w w w. java 2 s . co m } validateEnvironmentVariables(); final File outputDirectory; if (cmd.hasOption("o")) { outputDirectory = new File(cmd.getOptionValue("o")); } else { outputDirectory = DEFAULT_OUTPUT_DIR; } FileUtils.forceMkdir(outputDirectory); long start = System.currentTimeMillis(); final FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("browser.download.folderList", 2); profile.setPreference("browser.download.dir", outputDirectory.getAbsolutePath()); profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "image/jpeg,image/png"); final FirefoxDriver driver = new FirefoxDriver(profile); loginIntoPicasa(cmd.getOptionValue("v"), driver); driver.navigate().to("https://picasaweb.google.com/home?showall=true"); TimeUnit.SECONDS.sleep(2); final List<WebElement> albumLinks = driver .findElements(By.xpath("//p[@class='gphoto-album-cover-title']/a")); if (cmd.hasOption("a")) { final String albumName = cmd.getOptionValue("a").trim(); System.out.println(String.format("Album: %s", albumName)); downloadAlbum(driver, albumLinks.stream().filter(al -> al.getText().equals(albumName)).findFirst().get() .getAttribute("href"), outputDirectory); } else { final Set<String> albumHrefs = albumLinks.stream().map(a -> a.getAttribute("href")) .collect(Collectors.toSet()); albumHrefs.forEach(a -> downloadAlbum(driver, a, outputDirectory)); } TimeUnit.SECONDS.sleep(10); System.out.println("done"); long end = System.currentTimeMillis(); System.out.println(String.format("execution took %d minutes.", Math.min(TimeUnit.MILLISECONDS.toMinutes(end - start), 1))); driver.close(); }
From source file:org.alfresco.grid.WebDriverFactory.java
License:Open Source License
public WebDriver getObject(Browser browser) { switch (browser) { case FireFox: return getFireFox(false); case Chrome:/* w ww. ja va 2s . c o m*/ return getChromeDriver(); case HtmlUnit: return new HtmlUnitDriver(true); case IE: return getInternetExplorerDriver(); case Safari: return getSafariDriver(); case RemoteFireFox: DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setBrowserName(BrowserType.FIREFOX); capabilities.setJavascriptEnabled(true); FirefoxProfile profile = createProfile(); //The below two preferences added to disable the firefox auto update profile.setPreference("app.update.auto", false); profile.setPreference("app.update.enabled", false); profile.setEnableNativeEvents(true); capabilities.setCapability(FirefoxDriver.PROFILE, profile); return getRemoteDriver(capabilities); case RemoteChrome: DesiredCapabilities chromeCapabilities = DesiredCapabilities.chrome(); ChromeOptions options = new ChromeOptions(); options.addArguments("--kiosk"); chromeCapabilities.setCapability(ChromeOptions.CAPABILITY, options); return getRemoteDriver(chromeCapabilities); case RemoteIE: DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer(); ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); return getRemoteDriver(ieCapabilities); case FireFoxDownloadToDir: return getFireFox(true); default: throw new IllegalArgumentException("Invalid browser specified"); } }