List of usage examples for org.openqa.selenium.firefox FirefoxDriver PROFILE
String PROFILE
To view the source code for org.openqa.selenium.firefox FirefoxDriver PROFILE.
Click Source Link
From source file:org.nuxeo.functionaltests.drivers.RemoteFirefoxDriverProvider.java
License:Open Source License
@Override public RemoteWebDriver init(DesiredCapabilities dc) throws Exception { FirefoxProfile profile = FirefoxDriverProvider.getProfile(); JavaScriptError.addExtension(profile); dc.setCapability(FirefoxDriver.PROFILE, profile); driver = new RemoteWebDriver(new java.net.URL(WEBDRIVER_URL), dc); driver.setFileDetector(new LocalFileDetector()); return driver; }
From source file:org.openqa.grid.selenium.SelfRegisteringSelenium.java
License:Apache License
@Override public void addFirefoxSupport(File profileDir) { DesiredCapabilities ff = new DesiredCapabilities(); ff.setBrowserName("*firefox"); if (profileDir != null && profileDir.exists()) { firefoxProfileDir = profileDir;/* www . ja v a 2s. c o m*/ ff.setCapability(FirefoxDriver.PROFILE, new FirefoxProfile(profileDir)); ff.setCapability("profilePath", profileDir.getPath()); } getCaps().add(ff); }
From source file:org.openqa.grid.selenium.SelfRegisteringWebDriver.java
License:Apache License
@Override public void addFirefoxSupport(File profile) { DesiredCapabilities ff = DesiredCapabilities.firefox(); if (profile != null) { ff.setCapability(FirefoxDriver.PROFILE, new FirefoxProfile(profile)); }/*from w w w . ja v a2s. c om*/ getCaps().add(ff); }
From source file:org.orcid.integration.blackbox.web.shibboleth.ShibbolethTest.java
License:Open Source License
private void createFireFoxDriverWithModifyHeaders() throws IOException { FirefoxProfile fireFoxProfile = new FirefoxProfile(); File modifyHeaders = new File( System.getProperty("user.dir") + "/src/test/resources/modify-headers-0.7.1.1.xpi"); fireFoxProfile.setEnableNativeEvents(false); fireFoxProfile.addExtension(modifyHeaders); fireFoxProfile.setPreference("modifyheaders.headers.count", 2); fireFoxProfile.setPreference("modifyheaders.headers.action0", "Add"); fireFoxProfile.setPreference("modifyheaders.headers.name0", "persistent-id"); fireFoxProfile.setPreference("modifyheaders.headers.value0", "integration-test-" + System.currentTimeMillis() + "@orcid.org"); fireFoxProfile.setPreference("modifyheaders.headers.enabled0", true); fireFoxProfile.setPreference("modifyheaders.headers.action1", "Add"); fireFoxProfile.setPreference("modifyheaders.headers.name1", "Shib-Identity-Provider"); fireFoxProfile.setPreference("modifyheaders.headers.value1", "https://integrationtest.orcid.org/idp/shibboleth"); fireFoxProfile.setPreference("modifyheaders.headers.enabled1", true); fireFoxProfile.setPreference("modifyheaders.config.active", true); fireFoxProfile.setPreference("modifyheaders.config.alwaysOn", true); DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setBrowserName("firefox"); capabilities.setPlatform(org.openqa.selenium.Platform.ANY); capabilities.setCapability(FirefoxDriver.PROFILE, fireFoxProfile); webDriver = new FirefoxDriver(capabilities); }
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
/** * Builds a remote WebDriver suitable for use on Selenium Grid, configured * by properties.//from w ww. j av a 2 s.c o m * * @param browser * @param platform * @param properties * @return RemoteWebDriver * @throws IOException */ protected WebDriver initRemoteWebDriver(Browser browser, String version, Platform platform, Properties properties) throws IOException { // determine browser capabilities DesiredCapabilities capabilities = null; String browserCapabilityKey = null; switch (browser) { case FIREFOX: default: capabilities = DesiredCapabilities.firefox(); FirefoxProfile profile = getFireFoxProfile(); // JavaScriptError.addExtension(profile); // TODO add JSErrorCollector to maven dependency capabilities.setCapability(FirefoxDriver.PROFILE, profile); browserCapabilityKey = FirefoxDriver.BINARY; break; case IEXPLORE: capabilities = DesiredCapabilities.internetExplorer(); /* * TODO determine how to access different version of IE on * remote server */ break; case HTMLUNIT: capabilities = DesiredCapabilities.htmlUnit(); break; case CHROME: capabilities = DesiredCapabilities.chrome(); browserCapabilityKey = "chrome.binary"; initChromeProfile(capabilities); break; } capabilities.setJavascriptEnabled(true); capabilities.setPlatform(platform); capabilities.setBrowserName(browser.toString().toLowerCase()); capabilities.setVersion(version); // determine the browser binary path key by version String browserBinaryPath = getBrowserBinaryPath(platform, browser, version, properties); if (browserBinaryPath != null) { capabilities.setCapability(browserCapabilityKey, browserBinaryPath); } // else use default /* * TODO remote grid system setup for setting IE and Chrome drivers * http://element34.ca/blog/iedriverserver-webdriver-and-python */ /* * TODO add safari support * http://code.google.com/p/selenium/wiki/SafariDriver */ // define a name to appear in SauceLabs for the activity of this driver // TODO investigate making this more configurable int timestamp = (int) (System.currentTimeMillis() / 1000); capabilities.setCapability("name", browser + "-" + version + " on " + platform + " time " + timestamp); // create remote web driver WebDriver remoteDriver = null; gridUrl = properties.getProperty(GRID_URL_PROP_KEY); if (gridUrl != null && !gridUrl.equals("")) { remoteDriver = OpenWebDriver.newRemoteWebDriver(gridUrl, capabilities); } else { // TODO remoteDriver = initSauceWebDriver(properties, capabilities); } return remoteDriver; }
From source file:org.safs.selenium.webdriver.lib.SelectBrowser.java
License:Open Source License
/** * /*from ww w .ja va2s . com*/ * @param browserName String, the browser name, such as "explorer" * @param extraParameters Map<String,Object>, can be used to pass more browser parameters, such as proxy settings. * @return DesiredCapabilities */ public static DesiredCapabilities getDesiredCapabilities(String browserName, Map<String, Object> extraParameters) { String debugmsg = StringUtils.debugmsg(false); DesiredCapabilities caps = null; if (browserName.equals(BROWSER_NAME_IE)) { System.setProperty(SYSTEM_PROPERTY_WEBDRIVER_IE, "IEDriverServer.exe"); caps = DesiredCapabilities.internetExplorer(); caps.setCapability("nativeEvents", true); caps.setCapability("requireWindowFocus", true); //caps.setCapability("browserName", BROWSER_NAME_IE); } else if (browserName.equals(BROWSER_NAME_CHROME)) { System.setProperty(SYSTEM_PROPERTY_WEBDRIVER_CHROME, "chromedriver.exe"); caps = DesiredCapabilities.chrome(); // Disable extensions to avoid popping up 'Disable developer mode extensions' message by default. if (!extraParameters.containsKey(KEY_CHROME_DISABLE_EXTENSIONS)) { // Only execute if no user's setting extraParameters.put(KEY_CHROME_DISABLE_EXTENSIONS, "true"); } //caps.setCapability("browserName", BROWSER_NAME_CHROME); } else if (browserName.equals(BROWSER_NAME_EDGE)) { System.setProperty(SYSTEM_PROPERTY_WEBDRIVER_EDGE, "MicrosoftWebDriver.exe"); caps = DesiredCapabilities.edge(); //caps.setCapability("browserName", BROWSER_NAME_EDGE); } else if (browserName.equals(BROWSER_NAME_ANDROID_CHROME)) { System.setProperty(SYSTEM_PROPERTY_WEBDRIVER_CHROME, "chromedriver.exe"); caps = DesiredCapabilities.chrome(); ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setExperimentalOption("androidPackage", "com.android.chrome"); caps.setCapability(ChromeOptions.CAPABILITY, chromeOptions); caps.setCapability(CapabilityType.BROWSER_NAME, BROWSER_NAME_CHROME); } else if (browserName.equals(BROWSER_NAME_IPAD_SIMULATOR_SAFARI)) { caps = new DesiredCapabilities(); caps.setCapability("device", "ipad"); caps.setCapability("simulator", "true"); caps.setCapability(CapabilityType.BROWSER_NAME, "safari"); } else { // default browser always caps = DesiredCapabilities.firefox(); caps.setCapability(CapabilityType.BROWSER_NAME, BROWSER_NAME_FIREFOX); } String unexpectedAlertBehaviour = Processor.getUnexpectedAlertBehaviour(); if (unexpectedAlertBehaviour == null) unexpectedAlertBehaviour = System .getProperty(DriverConstant.PROERTY_SAFS_TEST_UNEXPECTEDALERTBEHAVIOUR); if (unexpectedAlertBehaviour != null) { IndependantLog.debug(debugmsg + " Set '" + unexpectedAlertBehaviour + "' to '" + CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR + "'."); caps.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, unexpectedAlertBehaviour); } if (extraParameters != null && !extraParameters.isEmpty()) { //1. Add http proxy settings to Capabilities, if they exist Object proxysetting = extraParameters.get(KEY_PROXY_SETTING); if (proxysetting != null && proxysetting instanceof String) { org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy(); proxy.setHttpProxy(proxysetting.toString()); Object bypass = extraParameters.get(KEY_PROXY_BYPASS_ADDRESS); if (bypass != null && bypass instanceof String) { proxy.setNoProxy(bypass.toString()); } caps.setCapability(CapabilityType.PROXY, proxy); } //2 Add firefox profile setting to Capabilities. if (BROWSER_NAME_FIREFOX.equals(browserName)) { //2.1 Add firefox profile setting to Capabilities, if it exists FirefoxProfile firefoxProfile = null; Object firefoxProfileParam = extraParameters.get(KEY_FIREFOX_PROFILE); if (firefoxProfileParam != null && firefoxProfileParam instanceof String) { //Can be profile's name or profile's file name String profileNameOrPath = firefoxProfileParam.toString(); IndependantLog.debug( debugmsg + "Try to Set firefox profile '" + profileNameOrPath + "' to Capabilities."); firefoxProfile = getFirefoxProfile(profileNameOrPath); if (firefoxProfile != null) { caps.setCapability(KEY_FIREFOX_PROFILE, profileNameOrPath);//used to store in session file } else { IndependantLog.error(debugmsg + " Fail to set firefox profile to Capabilities."); } } //2.2 Add firefox profile preferences to Capabilities, if it exists Object prefsFileParam = extraParameters.get(KEY_FIREFOX_PROFILE_PREFERENCE); if (prefsFileParam != null && prefsFileParam instanceof String) { String preferenceFile = prefsFileParam.toString(); IndependantLog.debug(debugmsg + "Try to Set firefox preference file '" + preferenceFile + "' to Firefox Profile."); caps.setCapability(KEY_FIREFOX_PROFILE_PREFERENCE, preferenceFile);//used to store in session file Map<?, ?> firefoxPreference = Json.readJSONFileUTF8(preferenceFile); if (firefoxProfile == null) firefoxProfile = new FirefoxProfile(); addFireFoxPreference(firefoxProfile, firefoxPreference); } if (firefoxProfile != null) { caps.setCapability(FirefoxDriver.PROFILE, firefoxProfile); } } //3. Add chrome-options-settings to Capabilities. if (BROWSER_NAME_CHROME.equals(browserName) || BROWSER_NAME_ANDROID_CHROME.equals(browserName)) { setChromeCapabilities(caps, extraParameters); } //put extra grid-nodes information Object gridnodes = extraParameters.get(KEY_GRID_NODES_SETTING); if (gridnodes != null && gridnodes instanceof String) { caps.setCapability(KEY_GRID_NODES_SETTING, gridnodes); } } return caps; }
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.java 2s .com*/ 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.webtestingexplorer.driver.FirefoxWebDriverFactory.java
License:Open Source License
@Override public WebDriver createWebDriver(WebDriverProxy proxy) throws Exception { DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setCapability(FirefoxDriver.PROFILE, profile); if (shouldUseProxy) { capabilities.setCapability(CapabilityType.PROXY, proxy); }// ww w . j av a2s .c o m return new FirefoxDriver(capabilities); }
From source file:selenium.WebDriverBuilder.java
public EventFiringWebDriver getFirefoxDriver(Site site) { FirefoxProfile ffp = new FirefoxProfile(); ffp.setPreference("general.useragent.override", site.getUserAgent()); DesiredCapabilities caps = DesiredCapabilities.firefox(); caps.setJavascriptEnabled(true);/*from ww w . j av a 2s . c om*/ caps.setCapability(FirefoxDriver.PROFILE, ffp); caps.setCapability("takesScreenshot", true); // User Name & Password Settings webDriver = new FirefoxDriver(caps); if (site.getViewPortHeight() > 0 && site.getViewPortWidth() > 0) { Dimension s = new Dimension(site.getViewPortWidth(), site.getViewPortHeight()); webDriver.manage().window().setSize(s); } else { webDriver.manage().window().maximize(); } webDriver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver = new EventFiringWebDriver(webDriver); EventHandler handler = new EventHandler(); driver.register(handler); return driver; }