Search in sources :

Example 16 with FirefoxProfile

use of org.openqa.selenium.firefox.FirefoxProfile in project charts by vaadin.

the class ChartsBrowserFactory method createFirefox.

private DesiredCapabilities createFirefox() {
    DesiredCapabilities desiredCapabilities = create(Browser.FIREFOX, "45", Platform.WINDOWS);
    desiredCapabilities.setCapability("marionette", "false");
    // Configuring an empty Firefox profile fixes tests
    // where a data point is clicked.
    // - pointClick, select and unselect in ServerSideEvents tests
    FirefoxProfile firefoxProfile = new FirefoxProfile();
    desiredCapabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
    return desiredCapabilities;
}
Also used : DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile)

Example 17 with FirefoxProfile

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

the class DesktopCapabilitiesTest method getFirefoxCapabilityWithDefaultFirefoxProfileTest.

@Test(groups = { "DesktopCapabilitiesTestClass" })
public static void getFirefoxCapabilityWithDefaultFirefoxProfileTest() {
    String testName = "firefox - getFirefoxDefaultCapabilityTest";
    FirefoxCapabilities firefoxCapabilities = new FirefoxCapabilities();
    DesiredCapabilities capabilities = firefoxCapabilities.getCapability(testName);
    Assert.assertEquals(capabilities.getBrowserName(), BrowserType.FIREFOX, "Returned browser name is not valid!");
    Assert.assertEquals(capabilities.getCapability("name"), testName, "Returned test name is not valid!");
    Assert.assertFalse((Boolean) capabilities.getCapability(CapabilityType.TAKES_SCREENSHOT), "Returned capability value is not valid!");
    boolean actualMediaEmeEnabled = ((FirefoxProfile) capabilities.getCapability("firefox_profile")).getBooleanPreference("media.eme.enabled", false);
    Assert.assertEquals(actualMediaEmeEnabled, MEDIA_EME_ENABLED, "Returned firefox profile preference is not valid!");
    boolean actualMediaGmpManagerUpdateEnabled = ((FirefoxProfile) capabilities.getCapability("firefox_profile")).getBooleanPreference("media.gmp-manager.updateEnabled", false);
    Assert.assertEquals(actualMediaGmpManagerUpdateEnabled, MEDIA_GMP_MANAGER_UPDATE_ENABLED, "Returned firefox profile preference is not valid!");
}
Also used : DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile) Test(org.testng.annotations.Test)

Example 18 with FirefoxProfile

use of org.openqa.selenium.firefox.FirefoxProfile in project Asqatasun by Asqatasun.

the class ProfileFactory method getProfile.

/**
     * 
     * @return 
     *      a set-up Firefox profile
     */
private FirefoxProfile getProfile(boolean loadImage) {
    if (StringUtils.isNotBlank(pathToPreSetProfile)) {
        File presetProfileDir = new File(pathToPreSetProfile);
        if (presetProfileDir.exists() && presetProfileDir.canRead() && presetProfileDir.canExecute() && presetProfileDir.canWrite()) {
            Logger.getLogger(this.getClass()).debug("Start firefox profile with path " + presetProfileDir.getAbsolutePath());
            return new FirefoxProfile(presetProfileDir);
        } else {
            Logger.getLogger(this.getClass()).debug("The profile with path " + presetProfileDir.getAbsolutePath() + " doesn't exist or don't have permissions");
        }
    }
    Logger.getLogger(this.getClass()).debug("Start firefox with fresh new profile");
    FirefoxProfile firefoxProfile = new FirefoxProfile();
    setUpPreferences(firefoxProfile, loadImage);
    //        setUpExtensions(firefoxProfile);
    setUpProxy(firefoxProfile);
    return firefoxProfile;
}
Also used : FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile) File(java.io.File)

Example 19 with FirefoxProfile

use of org.openqa.selenium.firefox.FirefoxProfile in project iTest by e-government-ua.

the class SetupAndTeardown method SetUp.

@BeforeMethod(alwaysRun = true)
public void SetUp() throws IOException {
    //        driver = new FirefoxDriver(profileFF);
    if (null == driver) {
        /**
             * ******* Для локального тестирования установить switch ("chrome")
             * для jenkins switch ("firefox") **********
             */
        switch("firefox") {
            case "firefox":
                /**
                     * ******* Закоментить для для запуска на своем профиле и
                     * откоментить для запуска на дефолтном **********
                     */
                //Save the path of the XPI files as per your saved location
                String cryptopluginPath = "src/test/resources/files/cryptoplugin_ext_id@privatbank.ua.xpi";
                File cryptoplugin = new File(cryptopluginPath);
                FirefoxProfile profile = new FirefoxProfile();
                //                    profile.addExtension(cryptoplugin);
                profile.setEnableNativeEvents(true);
                profile.setAcceptUntrustedCertificates(true);
                //                    profile.addExtension(cryptoplugin);
                /**
                     * ******* Раскомментить для запуска на своем профиле и
                     * закоментить для дефолтного **********
                     */
                //   ProfilesIni allProfiles = new ProfilesIni();
                //   FirefoxProfile profile = allProfiles.getProfile("default");
                profile.setPreference("extensions.cryptoplugin_ext_id@privatbank.currentVersion", "9.9.9");
                profile.setEnableNativeEvents(true);
                profile.setAcceptUntrustedCertificates(true);
                profile.setAssumeUntrustedCertificateIssuer(true);
                profile.setPreference("javascript.enabled", true);
                profile.setPreference("geo.enabled", false);
                profile.setPreference("extensions.cryptoplugin_ext_id@privatbank.ua.currentVersion", "999.999.999");
                capabilities = DesiredCapabilities.firefox();
                capabilities.setCapability(FirefoxDriver.PROFILE, profile);
                capabilities.setCapability("unexpectedAlertBehaviour", "ignore");
                System.out.println("Tests will be run (or rerun) in Firefox with custom profile...");
                driver = WebDriverFactory.getDriver(capabilities);
                /**
                     * ******* Для локального тестирования **********
                     */
                //                  case "chrome":
                //                    System.setProperty("webdriver.chrome.driver", "src\\test\\resources\\files\\chromedriver.exe");
                //                  capabilities = DesiredCapabilities.chrome();
                //                options = new ChromeOptions();
                //              System.out.println("Tests will be run (or rerun) in Chrome with custom profile...");
                //            break;
                //      default:
                this.driver = new FirefoxDriver();
                System.out.println("Tests will be run (or rerun) in Firefox...");
                break;
        }
        driver = WebDriverFactory.getDriver(capabilities);
        this.driver.manage().timeouts().implicitlyWait(CV.implicitTimeWait, TimeUnit.SECONDS);
        this.driver.manage().window().maximize();
        this.driver.manage().deleteAllCookies();
    }
}
Also used : FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile) File(java.io.File)

Example 20 with FirefoxProfile

use of org.openqa.selenium.firefox.FirefoxProfile in project SneakerBot by Penor.

the class Adidas method splash.

@SuppressWarnings("deprecation")
public void splash() {
    try {
        WebDriverWait wait = new WebDriverWait(driver, 60L);
        print("Loading webpage: " + url);
        driver.get(url);
        wait.until(new Function<WebDriver, Boolean>() {

            public Boolean apply(WebDriver d) {
                // + String.valueOf(((JavascriptExecutor) d).executeScript("return document.readyState")));
                return String.valueOf(((JavascriptExecutor) d).executeScript("return document.readyState")).equals("complete");
            }
        });
        // TODO: Get to splash page.
        boolean displayed = wait.until(x -> x.findElement(By.className("sk-fading-circle"))).isDisplayed();
        if (displayed) {
            print(proxy != null ? ("[" + proxy.getPassword() + ":" + proxy.getPort() + "] -> ") : "" + "waiting at splash page!");
            while (driver.findElements(By.className("g-recaptcha")).size() == 0) Thread.sleep(5000L);
            print(proxy != null ? ("[" + proxy.getPassword() + ":" + proxy.getPort() + "] -> ") : "" + "passed splash page!");
            driver.manage().getCookies().stream().forEach(c -> {
                if (c.getValue().contains("hmac")) {
                    hmac = c.getValue();
                    hmacExpiration = c.getExpiry();
                }
            });
            if (driver.findElements(By.className("g-recaptcha")).size() > 0)
                siteKey = driver.findElement(By.className("g-recaptcha")).getAttribute("data-sitekey");
            if (driver.findElements(By.id("flashproductform")).size() > 0)
                clientId = driver.findElement(By.id("flashproductform")).getAttribute("action").split("clientId=")[1];
            Date timeLeft = new Date(hmacExpiration.getTime() - System.currentTimeMillis());
            print("[Success] -> SiteKey: " + siteKey + " Client ID: " + clientId + " HMAC: " + hmac + " Time Left: " + timeLeft.getMinutes() + "m" + timeLeft.getSeconds() + "s");
        } else
            print("Error, Element displayed: " + displayed);
        if (manual) {
            FirefoxProfile profile = new FirefoxProfile();
            if (proxy != null) {
                profile.setPreference("network.proxy.type", 1);
                profile.setPreference("network.proxy.http", proxy.getAddress());
                profile.setPreference("network.proxy.http_port", proxy.getPort());
                profile.setPreference("network.proxy.ssl", proxy.getAddress());
                profile.setPreference("network.proxy.ssl_port", proxy.getPort());
            }
            // profile.setPreference("general.useragent.override", driver.set);
            WebDriver checkout = new FirefoxDriver(profile);
            for (Cookie cookie : driver.manage().getCookies()) checkout.manage().addCookie(cookie);
            checkout.get(driver.getCurrentUrl());
        } else
            while (!carted && hmacExpiration.getTime() > System.currentTimeMillis()) atc();
    } catch (Exception e) {
        String name = e.getClass().getName();
        print("[Exception] -> " + name);
        carted = true;
        if (name.equals("org.openqa.selenium.TimeoutException"))
            carted = false;
    } finally {
        print(carted ? "Closing driver, and ending" : "Failed, Retrying...");
        if (carted) {
            driver.quit();
            Thread.currentThread().interrupt();
        }
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) ProxyConfig(com.machinepublishers.jbrowserdriver.ProxyConfig) CredentialObject(main.java.sneakerbot.loaders.Credentials.CredentialObject) Settings(com.machinepublishers.jbrowserdriver.Settings) ExpectedConditions(org.openqa.selenium.support.ui.ExpectedConditions) Date(java.util.Date) JBrowserDriver(com.machinepublishers.jbrowserdriver.JBrowserDriver) By(org.openqa.selenium.By) WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) Random(java.util.Random) Type(com.machinepublishers.jbrowserdriver.ProxyConfig.Type) Function(java.util.function.Function) Builder(com.machinepublishers.jbrowserdriver.Settings.Builder) Level(java.util.logging.Level) TimeUnit(java.util.concurrent.TimeUnit) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) UserAgent(com.machinepublishers.jbrowserdriver.UserAgent) Cookie(org.openqa.selenium.Cookie) ProxyObject(main.java.sneakerbot.loaders.Proxy.ProxyObject) Cookie(org.openqa.selenium.Cookie) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile) Date(java.util.Date)

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