Search in sources :

Example 21 with FirefoxProfile

use of org.openqa.selenium.firefox.FirefoxProfile in project ORCID-Source by ORCID.

the class ShibbolethTest method createFireFoxDriverWithModifyHeaders.

private WebDriver createFireFoxDriverWithModifyHeaders(List<Pair<String, String>> headers) throws IOException {
    FirefoxProfile fireFoxProfile = new FirefoxProfile();
    File modifyHeaders = new File(System.getProperty("user.dir") + "/src/test/resources/modify_headers-0.7.1.1-fx.xpi");
    fireFoxProfile.addExtension(modifyHeaders);
    fireFoxProfile.setPreference("modifyheaders.headers.count", headers.size());
    for (int i = 0; i < headers.size(); i++) {
        fireFoxProfile.setPreference("modifyheaders.headers.action" + i, "Add");
        fireFoxProfile.setPreference("modifyheaders.headers.name" + i, headers.get(i).getLeft());
        fireFoxProfile.setPreference("modifyheaders.headers.value" + i, headers.get(i).getRight());
        fireFoxProfile.setPreference("modifyheaders.headers.enabled" + i, true);
    }
    fireFoxProfile.setPreference("modifyheaders.config.active", true);
    fireFoxProfile.setPreference("modifyheaders.config.alwaysOn", true);
    FirefoxOptions options = new FirefoxOptions();
    options.setCapability(FirefoxDriver.PROFILE, fireFoxProfile);
    // Marionette does not allow untrusted certs yet
    options.setCapability(FirefoxDriver.MARIONETTE, false);
    WebDriver webDriver = new FirefoxDriver(options);
    webDriver.manage().timeouts().setScriptTimeout(5, TimeUnit.SECONDS);
    return webDriver;
}
Also used : WebDriver(org.openqa.selenium.WebDriver) FirefoxOptions(org.openqa.selenium.firefox.FirefoxOptions) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile) File(java.io.File)

Example 22 with FirefoxProfile

use of org.openqa.selenium.firefox.FirefoxProfile in project jmeter-plugins by undera.

the class FirefoxDriverConfig method createProfile.

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;
}
Also used : FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile)

Example 23 with FirefoxProfile

use of org.openqa.selenium.firefox.FirefoxProfile in project jmeter-plugins by undera.

the class RemoteDesiredCapabilitiesFactory method build.

public static DesiredCapabilities build(RemoteCapability capability) {
    DesiredCapabilities desiredCapabilities;
    if (RemoteCapability.CHROME.equals(capability)) {
        ChromeOptions options = new ChromeOptions();
        desiredCapabilities = DesiredCapabilities.chrome();
        desiredCapabilities.setCapability(ChromeOptions.CAPABILITY, options);
        return desiredCapabilities;
    } else if (RemoteCapability.FIREFOX.equals(capability)) {
        FirefoxProfile profile = new FirefoxProfile();
        desiredCapabilities = DesiredCapabilities.firefox();
        desiredCapabilities.setCapability(FirefoxDriver.PROFILE, profile);
        return desiredCapabilities;
    } else if (RemoteCapability.INTERNET_EXPLORER.equals(capability)) {
        desiredCapabilities = DesiredCapabilities.internetExplorer();
        return desiredCapabilities;
    } else if (RemoteCapability.PHANTOMJS.equals(capability)) {
        desiredCapabilities = DesiredCapabilities.phantomjs();
        return desiredCapabilities;
    }
    throw new IllegalArgumentException("No such capability");
}
Also used : DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) ChromeOptions(org.openqa.selenium.chrome.ChromeOptions) FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile)

Example 24 with FirefoxProfile

use of org.openqa.selenium.firefox.FirefoxProfile in project xwiki-platform by xwiki.

the class WebDriverFactory method createWebDriver.

public XWikiWebDriver createWebDriver(String browserName) {
    WebDriver driver;
    if (browserName.startsWith("*firefox")) {
        // Native events are disabled by default for Firefox on Linux as it may cause tests which open many windows
        // in parallel to be unreliable. However, native events work quite well otherwise and are essential for some
        // of the new actions of the Advanced User Interaction. We need native events to be enable especially for
        // testing the WYSIWYG editor. See http://code.google.com/p/selenium/issues/detail?id=2331 .
        FirefoxProfile profile = new FirefoxProfile();
        profile.setEnableNativeEvents(true);
        // Make sure Firefox doesn't upgrade automatically on CI agents.
        profile.setPreference("app.update.auto", false);
        profile.setPreference("app.update.enabled", false);
        profile.setPreference("app.update.silent", false);
        driver = new FirefoxDriver(profile);
        // Hide the Add-on bar (from the bottom of the window, with "WebDriver" written on the right) because it can
        // prevent buttons or links from being clicked when they are beneath it and native events are used.
        // See https://groups.google.com/forum/#!msg/selenium-users/gBozOynEjs8/XDxxQNmUSCsJ
        // We need to load a page before sending the keys otherwise WebDriver throws ElementNotVisible exception.
        driver.get("data:text/plain;charset=utf-8,XWiki");
        driver.switchTo().activeElement().sendKeys(Keys.chord(Keys.CONTROL, "/"));
    } else if (browserName.startsWith("*iexplore")) {
        driver = new InternetExplorerDriver();
    } else if (browserName.startsWith("*chrome")) {
        driver = new ChromeDriver();
    } else if (browserName.startsWith("*phantomjs")) {
        DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
        capabilities.setCapability("handlesAlerts", true);
        try {
            driver = new PhantomJSDriver(ResolvingPhantomJSDriverService.createDefaultService(), capabilities);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    } else {
        throw new RuntimeException("Unsupported browser name [" + browserName + "]");
    }
    // Maximize the browser window by default so that the page has a standard layout. Individual tests can resize
    // the browser window if they want to test how the page layout adapts to limited space. This reduces the
    // probability of a test failure caused by an unexpected layout (nested scroll bars, floating menu over links
    // and buttons and so on).
    driver.manage().window().maximize();
    return new XWikiWebDriver((RemoteWebDriver) driver);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) PhantomJSDriver(org.openqa.selenium.phantomjs.PhantomJSDriver) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) InternetExplorerDriver(org.openqa.selenium.ie.InternetExplorerDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) IOException(java.io.IOException) FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver)

Example 25 with FirefoxProfile

use of org.openqa.selenium.firefox.FirefoxProfile in project carina by qaprosoft.

the class FirefoxCapabilities method getDefaultFirefoxProfile.

public FirefoxProfile getDefaultFirefoxProfile() {
    FirefoxProfile profile = new FirefoxProfile();
    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);
    }
    LOGGER.debug(firefoxPorts);
    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", ReportContext.getArtifactsFolder().getAbsolutePath());
        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);
    return profile;
}
Also used : FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile)

Aggregations

FirefoxProfile (org.openqa.selenium.firefox.FirefoxProfile)46 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)25 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)20 File (java.io.File)16 ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)10 ChromeOptions (org.openqa.selenium.chrome.ChromeOptions)10 FirefoxOptions (org.openqa.selenium.firefox.FirefoxOptions)9 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)9 IOException (java.io.IOException)7 WebDriverException (org.openqa.selenium.WebDriverException)7 Actions (org.openqa.selenium.interactions.Actions)7 HashMap (java.util.HashMap)6 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)6 URL (java.net.URL)5 Dimension (org.openqa.selenium.Dimension)5 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)5 WebDriver (org.openqa.selenium.WebDriver)5 TakesScreenshot (org.openqa.selenium.TakesScreenshot)3 FirefoxBinary (org.openqa.selenium.firefox.FirefoxBinary)3 InternetExplorerDriver (org.openqa.selenium.ie.InternetExplorerDriver)3