Example usage for org.openqa.selenium.firefox FirefoxProfile FirefoxProfile

List of usage examples for org.openqa.selenium.firefox FirefoxProfile FirefoxProfile

Introduction

In this page you can find the example usage for org.openqa.selenium.firefox FirefoxProfile FirefoxProfile.

Prototype

public FirefoxProfile() 

Source Link

Usage

From source file:evaluation.ExperimentRunner.java

License:Apache License

private void setup() throws Exception {
    System.out.println("xxx1");
    DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();
    LoggingPreferences loggingPreferences = new LoggingPreferences();
    System.out.println("xxx2");
    loggingPreferences.enable(LogType.BROWSER, Level.ALL);
    desiredCapabilities.setCapability(CapabilityType.LOGGING_PREFS, loggingPreferences);
    FirefoxBinary binary = new FirefoxBinary(new File(firefoxBinary));
    FirefoxProfile profile = new FirefoxProfile();
    System.out.println("xxx3");
    System.setProperty("webdriver.firefox.logfile", firefoxLogFile);
    profile.setPreference("webdriver.log.file", javascriptLogFile);
    profile.setPreference("dom.max_script_run_time", maxWaitTime);
    // Do not divert any links (browser.link.open_newwindow will have no
    // effect).//w  w w. j a va 2s .  c  om
    // http://kb.mozillazine.org/Browser.link.open_newwindow.restriction
    profile.setPreference("dom.popup_allowed_events", "");
    profile.setPreference("dom.popup_maximum", 0);
    profile.addExtension(new File(jalangiFFxpi));
    System.out.println("xxx4");
    driver = new FirefoxDriver(binary, profile, desiredCapabilities);
    System.out.println("xxx5");
    driver.manage().timeouts().implicitlyWait(120, TimeUnit.SECONDS);
    System.out.println("xxx6");
}

From source file:evaluation.JalangiFirefoxRunner.java

License:Apache License

private void setup() throws Exception {
    DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();
    LoggingPreferences loggingPreferences = new LoggingPreferences();
    loggingPreferences.enable(LogType.BROWSER, Level.ALL);
    desiredCapabilities.setCapability(CapabilityType.LOGGING_PREFS, loggingPreferences);
    FirefoxBinary binary = new FirefoxBinary(new File(firefoxBinary));
    FirefoxProfile profile = new FirefoxProfile();
    System.setProperty("webdriver.firefox.logfile", firefoxLogFile);
    profile.setPreference("webdriver.log.file", javascriptLogFile);
    profile.setPreference("dom.max_script_run_time", maxWaitTime);
    // Do not divert any links (browser.link.open_newwindow will have no effect). 
    // http://kb.mozillazine.org/Browser.link.open_newwindow.restriction
    profile.setPreference("dom.popup_allowed_events", "");
    profile.setPreference("dom.popup_maximum", 0);
    driver = new FirefoxDriver(binary, profile, desiredCapabilities);
    driver.manage().timeouts().implicitlyWait(120, TimeUnit.SECONDS);
}

From source file:evaluation.OctaneExperimentRunner.java

License:Apache License

private void run(String benchmark) throws Exception {
    DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();
    LoggingPreferences loggingPreferences = new LoggingPreferences();
    loggingPreferences.enable(LogType.BROWSER, Level.ALL);
    desiredCapabilities.setCapability(CapabilityType.LOGGING_PREFS, loggingPreferences);
    FirefoxBinary binary = new FirefoxBinary(new File(firefoxBinary));
    FirefoxProfile profile = new FirefoxProfile();
    System.setProperty("webdriver.firefox.logfile", firefoxLogFile);
    profile.setPreference("webdriver.log.file", javascriptLogFile);
    profile.setPreference("dom.max_script_run_time", maxWaitTime);
    profile.setPreference("extensions.sdk.console.logLevel", "info");
    profile.addExtension(new File(jalangiFFxpi));
    driver = new FirefoxDriver(binary, profile, desiredCapabilities);
    driver.manage().timeouts().implicitlyWait(120, TimeUnit.SECONDS);

    testBenchmark(benchmark);//w  w  w.j  ava 2 s  . c o m

    driver.quit();
    System.out.println("Done :-)");
}

From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.misc.MiscHandler1.java

License:Apache License

public void processDriver(WebDriver driver) {
    FirefoxProfile p = new FirefoxProfile();
    p.setPreference("webdriver_firefox_port", 8054);
    String URL = driver.getCurrentUrl();
    Site site = this.matches(URL);

    if (site == null)
        return;/*from  ww w.jav  a2  s .  c o  m*/

    System.out.println("Processing: " + URL);

    driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);

    List<Action> actions = site.getActions();

    for (Action action : actions) {
        String actionType = action.getType();

        if (actionType.equals("input")) {
            WebElement element = findWebElement(action.getBy(), action.getValue(), driver);
            if (element == null)
                return;
            element.sendKeys(action.getKey());

        } else if (actionType.equals("click")) {
            WebElement element = findWebElement(action.getBy(), action.getValue(), driver);
            if (element == null)
                return;
            element.click();
            //Wait for a potential new page to load
            //driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
            //   driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

        } else if (actionType.equals("redirect-append")) {
            //driver.navigate().to(action.getValue());
            //driver.get(action.getValue());//Exactly same as the above

            driver.get(URL + action.getValue());

            //Wait for a potential new page to load
            /* {
               Thread.sleep(10000);
            } catch(Exception e) {
               e.printStackTrace();
            }*/
        }
        driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);

    }
    driver.close();

}

From source file:ike.Ike.java

public static void main(String[] args) throws InterruptedException, FileNotFoundException, IOException {
    setProps();/*from   w  w  w  . j  a va  2  s.co  m*/
    FirefoxOptions options = new FirefoxOptions().setProfile(new FirefoxProfile());
    Proxy proxy = new Proxy();
    proxy.setProxyType(Proxy.ProxyType.AUTODETECT);
    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability("proxy", proxy);
    WebDriver driver = new FirefoxDriver(capabilities);
    driver.get("https://sise2mx.ikeasistencia.com/");
    driver.findElement(By.id("Usr")).clear();
    driver.findElement(By.id("Usr")).sendKeys("cmantenimiento");
    driver.findElement(By.id("Pass")).clear();
    driver.findElement(By.id("Pass")).sendKeys(readPass());
    driver.findElement(By.id("btnLogin")).click();
    for (int i = 0; i < 1; i = 0) {
        Thread.sleep(3100);
        if ((isElementPresent(("//*[@id=\"PW_LST\"]/tbody/tr[3]/td[10]/button"), driver)) == true) {
            driver.findElement(By.xpath("//*[@id=\"PW_LST\"]/tbody/tr[3]/td[10]/button")).click();
            System.out.println("Has aceptado un nuevo expediente.");
            System.out.println("Fecha: " + timeStamp());
            //msg();
        }
        if ((isElementPresent(("//*[@id=\"msg_alerta\"]/table/tbody/tr/td/table/tbody/tr[4]/td/button"),
                driver)) == true) {
            driver.findElement(
                    By.xpath("//*[@id=\"msg_alerta\"]/table/tbody/tr/td/table/tbody/tr[4]/td/button")).click();
            if ((isElementPresent(("//*[@id=\"PW_LST\"]/tbody/tr[3]/td[10]/button"), driver)) == true) {
                driver.findElement(By.xpath("//*[@id=\"PW_LST\"]/tbody/tr[3]/td[10]/button")).click();
            }
            System.out.println("Has aceptado un nuevo expediente.");
            System.out.println("Fecha: " + timeStamp());
            //msg();
        }
        if ((isElementPresent(("//*[@id=\"MensajeTimeOut\"]/table"), driver)) == true) {
            driver.findElement(
                    By.xpath("//*[@id=\"MensajeTimeOut\"]/table/tbody/tr/td/table/tbody/tr[4]/td[2]/button"))
                    .click();
        } else {
            driver.findElement(By.xpath("//div[2]/div[2]/table/tbody/tr/td")).click();
        }
    }
}

From source file:integration.io.github.seleniumquery.browser.driver.builders.FirefoxDriverBuilderTest.java

License:Apache License

@Test
public void withProfile__should_set_the_given_profile() {
    // given/*from   w  w  w .j  a  v  a2s .  co  m*/
    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("javascript.enabled", false);
    // when
    $.driver().useFirefox().withProfile(profile);
    // then
    assertJavaScriptIsOff($.driver().get());
}

From source file:io.github.bonigarcia.wdm.test.RemoteWebRtcFirefoxTest.java

License:Apache License

@Before
public void setupTest() throws MalformedURLException {
    DesiredCapabilities capability = DesiredCapabilities.firefox();
    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("media.navigator.permission.disabled", true);
    profile.setPreference("media.navigator.streams.fake", true);
    capability.setCapability(FirefoxDriver.PROFILE, profile);
    driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
}

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 {/* w ww  .  ja v  a  2 s  .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();//from ww w .j a  va2 s .  c  o m
    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();
}