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

public FirefoxDriver() 

Source Link

Usage

From source file:daveayan.gherkinsalad.browser.factory.FireFoxBrowser.java

License:Open Source License

public WebDriver getDriver() {
    try {//from  ww  w.  j a  v  a2  s  . com
        ReportFactory.reporter().action("Opening Firefox");
        WebDriver driver = new FirefoxDriver();
        return driver;
    } catch (Throwable th) {
        log.info(th.getMessage());
    }
    return new NullWebDriver();
}

From source file:db.Db.java

public static void main(String[] args) throws InterruptedException, Exception {
    // TODO code application logic here

    //SETUP// ww  w.  j av  a 2  s  .com
    WebDriver driver;
    String referralUrl, accounts[][];
    String mSuffix = new String();

    double space = 0, nAccounts;
    int needAccounts, creAccounts, f;
    StringBuffer verificationErrors = new StringBuffer();
    driver = new FirefoxDriver();
    //        driver = new HtmlUnitDriver();
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

    referralUrl = "https://www.dropbox.com/referrals/NTM2OTAyMjIyMjk?src=global9";
    mSuffix = "@gmail.com";
    space = 16.250;
    space = (Math.floor(space * 2) / 2); //trunk number to .0 or .5

    needAccounts = (int) ((18 - space) * 2); //number of accounts needed
    creAccounts = 0; //number of accounts created
    accounts = new String[needAccounts][4]; //accounts credentials matrix

    //GENERATE ACCOUNTS

    for (f = 0; f < accounts.length; f++)
        genAccount(accounts, mSuffix, f);

    //REGISTER
    int regAttempts = 0;
    System.out.print("Registering accounts => ");
    for (f = 0; f < accounts.length; f++) {
        while (!regAccount(accounts, referralUrl, f, driver) && regAttempts < 3) {

            regAttempts++;
            genAccount(accounts, mSuffix, f);
        }
        if (regAttempts < 3)
            creAccounts++;
        else
            System.out.println("Registration failed 3 consecutive times. Aborting");

    } //end for

    if (creAccounts == needAccounts)
        System.out.println("\n" + creAccounts + " DROPBOX ACCOUNTS CREATED SUCCESFULLY!!  :D :D");

    //TEARDOWN
    driver.quit();

}

From source file:de.betterform.conformance.WebDriverTest.java

License:BSD License

@Before
public void setUp() {
    String driver = System.getProperties().getProperty("test.driver", WebDriverTest.FIREFOX).toUpperCase();
    if (driver.equals(WebDriverTest.HTMLUNIT)) {
        this.webDriver = new HtmlUnitDriver();
    } else if (driver.equals(WebDriverTest.FIREFOX)) {
        this.webDriver = new FirefoxDriver();
    } else if (driver.equals(WebDriverTest.CHROME)) {
        /* Use "chrome.binary" to set path to binary */
        this.webDriver = new ChromeDriver();
    } else if (driver.equals(WebDriverTest.IE)) {
        if (System.getProperty("os.name").toLowerCase().indexOf("win") > 0) {
            this.webDriver = new InternetExplorerDriver();
        } else {/*  www. j  a v a2s.c o  m*/
            fail("You specified InternetExplorer on a non Microsoft Operating System!");
        }
    }

    this.webDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}

From source file:de.codecentric.janus.plugin.library.SeleniumAdapter.java

License:Apache License

@BeforeStories
public void initSelenium() throws Exception {
    if (Config.isLocalSeleniumExecution()) {
        driver = new FirefoxDriver();
    } else {/*  w  w  w. j  a v a  2 s. co m*/
        throw new UnsupportedOperationException("Only local " + "execution is possible.");
    }
}

From source file:de.codecentric.zucchini.web.provider.FirefoxDriverProvider.java

License:Apache License

@Override
protected WebDriver createWebDriver() {
    return new FirefoxDriver();
}

From source file:de.dentrassi.pm.testing.TestSuite.java

License:Open Source License

@BeforeClass
public static void setupBrowser() throws MalformedURLException {
    if (hasSauce()) {
        driver = createSauce(Platform.WIN8_1, "chrome", null);
    } else {/* ww w.  j a v  a  2 s.  com*/
        driver = new FirefoxDriver();
    }
}

From source file:de.jpluehrig.atmosphere.AtmosphereMainTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    setDriver(new FirefoxDriver()); // Firefox

    // To use Chrome, first install chromedriver.exe from
    // http://chromedriver.storage.googleapis.com/index.html
    // on your system path (e.g. C:\Windows\System32\)
    //setDriver(new ChromeDriver()); // Chrome

    // To use Internet Explorer, first install iedriverserver.exe from
    // http://selenium-release.storage.googleapis.com/index.html?path=2.43/
    // on your system path (e.g. C:\Windows\System32\)
    //setDriver(new InternetExplorerDriver()); // IE

    // To test headlessly (without a browser), first install phantomjs.exe
    // from http://phantomjs.org/download.html on your system path
    // (e.g. C:\Windows\System32\)
    //   setDriver(new PhantomJSDriver()); // PhantomJS headless browser
}

From source file:de.mpg.mpdl.service.rest.screenshot.logic.HtmlScreenshot.java

License:Open Source License

public File takeScreenshot(String url, int width, int height, boolean useFireFox) {
    driver = useFireFox ? new FirefoxDriver() : getPhantomJSDriver();
    try {//from  w  ww . j  a v  a  2  s .c  om
        driver.get(url);
        driver.manage().window();
        driver.manage().window().setSize(new Dimension(width, height));
        return ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
    } finally {
        driver.close();
    }
}

From source file:de.tklerx.run.ResEntries.java

License:Open Source License

public void init_Browser() throws Exception {
    Path p = Paths.get(geckoDriverPath);
    if (Files.notExists(p)) {
        System.err.println("Path " + p + " does not exist. Please specify path to gecko driver!");
        throw new ParameterException("Path " + p + " does not exist. Please specify path to gecko driver!");
    }//w  w w . j av a 2 s  . co m
    System.setProperty("webdriver.gecko.driver", p.toString());

    if (browser.equalsIgnoreCase("Firefox")) {
        driver = new FirefoxDriver();
    } else if (browser.equalsIgnoreCase("Chrome")) {
        String pathToChromeDriver = ".//ChromeDriver//chromedriver_Win_220.exe";
        System.setProperty("webdriver.chrome.driver", pathToChromeDriver);
        driver = new ChromeDriver();
    } else {
        System.out.println("Browser not defined!");
        throw new Exception("Browser not defined!");
    }
    driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
    driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
}

From source file:de.tudarmstadt.ukp.argumentation.data.roomfordebate.NYTimesCommentsScraper.java

License:Apache License

/**
 * Downloads the page and rolls out the entire discussion using {@link FirefoxDriver}.
 *
 * @param articleUrl url, e.g. {@code http://www.nytimes.com/roomfordebate/2015/02/04/regulate-internet-providers/the-internet-is-back-to-solid-regulatory-ground}
 * @return generated HTML code of the entire page
 * @throws InterruptedException//from w w  w  . j  a v  a2 s.com
 */
public String readHTML(String articleUrl) throws InterruptedException {
    // load the url
    WebDriver driver = new FirefoxDriver();
    driver.get(articleUrl);

    // roll-out the entire discussion
    // TODO fix that, is broken in actual versions of Selenium/Firefox
    /*
    List<WebElement> commentsExpandElements;
    do {
    commentsExpandElements = driver.findElements(By.cssSelector("div.comments-expand"));
            
    // click on each of them
    for (WebElement commentsExpandElement : commentsExpandElements) {
        // only if visible & enabled
        if (commentsExpandElement.isDisplayed() && commentsExpandElement.isEnabled()) {
            commentsExpandElement.click();
            
            // give it some time to load new comments
            Thread.sleep(3000);
        }
    }
    }
    // until there is one remaining that doesn't do anything...
    while (commentsExpandElements.size() > 1);
    */

    // get the html
    String result = driver.getPageSource();

    // close firefox
    driver.close();

    return result;
}