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

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

Introduction

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

Prototype

private FirefoxDriver(FirefoxDriverCommandExecutor executor, FirefoxOptions options) 

Source Link

Usage

From source file:edu.uga.cs.clickminer.test.BrowserEngineTest.java

License:Open Source License

/**
 * <p>browserEngineTest_18.</p>
 *
 * @throws java.io.IOException if any.//from w  w  w.j  a  v  a  2  s. co m
 * @throws java.lang.InterruptedException if any.
 */
public static void browserEngineTest_18() throws IOException, InterruptedException {
    FirefoxProfile profile = new FirefoxProfile(
            TestUtils.getWebdriverProfile("/home/cjneasbi/.mozilla/firefox", "webdriver"));
    WebDriver wdriver = new FirefoxDriver(
            new FirefoxBinary(new File("/home/cjneasbi/Desktop/old_firefox/firefox-17.0/firefox-bin")),
            profile);
    // WebDriver wdriver = new FirefoxDriver();
    wdriver.get("http://www.cs.uga.edu/~neasbitt/");
    wdriver.switchTo().activeElement();

    Thread.sleep(5000);

    WebElement elem = wdriver.findElement(By.id("profile"));
    Map<String, String> attrs = JSUtils.getElementAttributes(wdriver, elem);
    System.out.println(attrs);

    wdriver.close();
}

From source file:edu.usc.cs.ir.selenium.handler.Arguntrader.java

License:Apache License

public static void main(String[] args) {
    Arguntrader glocktalk = new Arguntrader();
    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference(FirefoxProfile.ALLOWED_HOSTS_PREFERENCE, "localhost");
    profile.setPreference("dom.ipc.plugins.enabled.libflashplayer.so", "false");
    profile.setPreference("permissions.default.stylesheet", 1);
    profile.setPreference("permissions.default.image", 1);

    FirefoxBinary binary = new FirefoxBinary();
    binary.setTimeout(TimeUnit.SECONDS.toMillis(180));

    WebDriver driver = new FirefoxDriver(binary, profile);
    driver.manage().timeouts().pageLoadTimeout(10000, TimeUnit.MILLISECONDS);

    try {//from   w ww .  ja v  a 2  s.  c  o m
        driver.get("http://arguntrader.com/viewforum.php?f=8");
        System.out.println(new String(glocktalk.processDriver(driver).getBytes("UTF-8")));
    } catch (Exception e) {
        if (e instanceof TimeoutException) {
            System.out.println("Timeout Exception");

            try {
                System.out.println(new String(glocktalk.processDriver(driver).getBytes("UTF-8")));
            } catch (UnsupportedEncodingException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

        }
        e.printStackTrace();
    } finally {
        if (driver != null) {
            driver.close();
            driver.quit();
        }
    }
}

From source file:edu.usc.cs.ir.selenium.handler.Glocktalk.java

License:Apache License

public static void main(String[] args) {
    Glocktalk glocktalk = new Glocktalk();
    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference(FirefoxProfile.ALLOWED_HOSTS_PREFERENCE, "localhost");
    profile.setPreference("dom.ipc.plugins.enabled.libflashplayer.so", "false");
    profile.setPreference("permissions.default.stylesheet", 1);
    profile.setPreference("permissions.default.image", 1);

    FirefoxBinary binary = new FirefoxBinary();
    binary.setTimeout(TimeUnit.SECONDS.toMillis(180));

    WebDriver driver = new FirefoxDriver(binary, profile);
    driver.manage().timeouts().pageLoadTimeout(10000, TimeUnit.MILLISECONDS);

    try {/*w ww.j  a v  a 2  s.  c om*/
        driver.get("http://www.glocktalk.com/media?page=6");
        System.out.println(new String(glocktalk.processDriver(driver).getBytes("UTF-8")));
    } catch (Exception e) {
        if (e instanceof TimeoutException) {
            System.out.println("Timeout Exception");

            try {
                System.out.println(new String(glocktalk.processDriver(driver).getBytes("UTF-8")));
            } catch (UnsupportedEncodingException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

        }
        //e.printStackTrace();
    } finally {
        if (driver != null) {
            driver.close();
            driver.quit();
        }
    }
}

From source file:gov.nih.nci.firebird.commons.selenium2.test.WebDriverModule.java

License:Open Source License

@Provides
@Singleton//from w  w w  .j a  va 2  s.  com
@Named("selenium.firefox.driver")
public WebDriver provideFirefoxDriver(@Named("selenium.firefox.profile.location") String profileLocation,
        @Named("selenium.firefox.binary.location") String binaryLocation) {
    FirefoxProfile profile = null;
    FirefoxBinary binary = null;
    try {
        File profileDir = new File(profileLocation);
        profile = new FirefoxProfile(profileDir);
    } catch (UnableToCreateProfileException e) {
    }
    File binaryDir = new File(binaryLocation);
    if (binaryDir.exists()) {
        binary = new FirefoxBinary(binaryDir);
    }
    WebDriver driver = new FirefoxDriver(binary, profile);
    closeDriverOnShutdown(driver);
    return driver;
}

From source file:it.com.pyxis.jira.selenium.WebDriverFactory.java

License:Open Source License

private WebDriver newXvfbDriver(String xvfbDisplayId) {

    FirefoxBinary firefox = new FirefoxBinary();
    firefox.setEnvironmentProperty("DISPLAY", xvfbDisplayId);

    WebDriver driver = new FirefoxDriver(firefox, null);

    setDriverSpeed(driver);/*from  w  ww. ja v a  2s . co  m*/
    setTimeout(driver);

    return driver;
}

From source file:iTests.framework.utils.WebuiTestUtils.java

public static FirefoxDriver createFirefoxDriver() {

    String newmanSystemProperty = System.getProperty("com.gs.test.use.newman");
    LogUtils.log("WebuiTestsUtils, passed newmanSystemProperty=" + newmanSystemProperty);

    boolean useNewman = Boolean
            .parseBoolean(System.getProperty("com.gs.test.use.newman", Boolean.FALSE.toString()));
    LogUtils.log("useNewman=" + useNewman);
    if (useNewman) {
        LogUtils.log("--- createFirefoxDriver ---");
        String Xport = System.getProperty("lmportal.xvfb.id", ":1");
        LogUtils.log("Xport=" + Xport);
        //final File firefoxPath = new File( System.getProperty( "lmportal.deploy.firefox.path", "/usr/bin/firefox" ) );
        FirefoxBinary firefoxBinary = new FirefoxBinary(/*firefoxPath*/);
        LogUtils.log("FirefoxBinary initialized");
        firefoxBinary.setEnvironmentProperty("DISPLAY", Xport);
        LogUtils.log("After set DISPLAY port");

        return new FirefoxDriver(firefoxBinary, null);
    }/*from ww w .  jav  a 2 s  .  c  o  m*/

    return new FirefoxDriver();
}

From source file:nz.co.testamation.core.WebIntegrationTestAutoConfiguration.java

License:Apache License

@Bean
@Autowired//from  w w  w.  ja  va 2s . 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));
}