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:functional.testing.customerclient.test.LoginTest.java

@Before
public void beforeTest() {
    driver = new FirefoxDriver();
    driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    driver.navigate().to("http://localhost:8080/admissions-customer-client/login.xhtml");
    loginPage = new LoginPage(driver);
}

From source file:functional.testing.customerclient.test.RegisterTest.java

@Before
public void setup() {
    driver = new FirefoxDriver();
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    driver.navigate().to("http://localhost:8080/admissions-customer-client/login.xhtml");
    LoginPage lp = new LoginPage(driver);
    rp = lp.clickRegisterAccount();/*from  w w  w.  ja v  a2 s  .c om*/
}

From source file:gelezka.RefreshGelezo.java

private void createDriver() {
    // driver = new ChromeDriver();
    driver = new FirefoxDriver();
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}

From source file:gheckodrivertest.BestJobsFirstPage.java

public static void main(String[] args) // TODO code application logic here
{
    try {// w w  w .j  a  va  2  s.c om
        //System.setProperty("webdriver.gecko.driver", "D:\\Documentatie\\Selenium\\geckodriver\\geckodriver.exe");
        System.setProperty("webdriver.gecko.driver", "D:\\gdrwrapper.bat");
        System.setProperty("webdriver.gecko.logfile", "D:\\geckodriver.log");
        WebDriver driver = new FirefoxDriver();

        DesiredCapabilities capabilities = DesiredCapabilities.firefox();

        LoggingPreferences logPrefs = new LoggingPreferences();
        logPrefs.enable(LogType.BROWSER, Level.ALL);
        logPrefs.enable(LogType.CLIENT, Level.ALL);
        logPrefs.enable(LogType.DRIVER, Level.ALL);
        logPrefs.enable(LogType.SERVER, Level.ALL);
        logPrefs.enable(LogType.PERFORMANCE, Level.ALL);

        capabilities.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);

        driver.get("http:\\bestjobs.eu");

        WebElement btnEnter = driver.findElement(By.xpath("html/body/div[1]/div/div/div/div/div[2]/a/button"));
        btnEnter.click();
        //driver.manage().timeouts().wait(30);
        System.out.println(driver.getTitle());
        /**
         * <li
         * class="sign-up-switch amplitude" data - key = "sign_up_email_started"
         * > <a
         * href = "/en/register" > Register <  / a
         * > < / li
         * >
         */
        // WebElement liSignIn = driver.findElement(By.className("sign-up-switch amplitude"));
        By btnRegister = By.linkText("Register");
        WebDriverWait wait = new WebDriverWait(driver, 10);
        wait.until(ExpectedConditions.presenceOfElementLocated(btnRegister));

        WebElement anchSignIn = driver.findElement(By.linkText("Register"));
        anchSignIn.click();
        //driver.manage().timeouts().wait(30);
        Logs logs = driver.manage().logs();
        LogEntries logEntries = logs.get(LogType.BROWSER);

        for (LogEntry logEntry : logEntries) {
            System.out.println("browser entry: " + logEntry.getMessage());
        }

        //driver.quit();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:glenn.IT_SeleniumTest.java

License:Apache License

@Test
public void seleniumTest() {
    StringBuffer verificationErrors = new StringBuffer();
    String baseUrl = "http://localhost:8090";

    WebDriver driver = new FirefoxDriver();

    driver.get(baseUrl + "/JavaApp-war/");
    driver.findElement(By.id("name")).clear();
    driver.findElement(By.id("name")).sendKeys("Glenn Brown");
    driver.findElement(By.name("Submit")).click();
    // Warning: verifyTextPresent may require manual changes
    try {//  w  w w . j a  v  a  2  s. co  m
        assertTrue(driver.findElement(By.cssSelector("BODY")).getText().matches("^[\\s\\S]*$"));
    } catch (Error e) {
        verificationErrors.append(e.toString());
    }
}

From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.login.LoginHandler21.java

License:Apache License

public boolean shouldProcessURL(String URL) {
    System.out.print("============SELENIUM=================");
    System.out.println("DEBUG:::::" + URL);
    System.setProperty("webdriver.firefox.bin", "/Applications/Firefox.app/Contents/MacOS/firefox");
    WebDriver driver = new FirefoxDriver();

    // And now use this to visit Google
    driver.get(URL);//from www  .ja va2  s  .c o m
    try {

        String url1, url2, url3, url4;

        url1 = "www.arguntrader.com/ucp.php?mode=login";
        url2 = "www.buyusedguns.net/login.php";
        url3 = "www.hawaiiguntrader.com/login/";
        url4 = "www.gunidaho.com/site/login.htm";

        WebElement username;
        WebElement password;
        WebElement submit;

        if (URL.contains(url1)) {
            System.out.println(url1
                    + " :***************************login page***********************************************8");
            username = driver.findElement(By.id("username"));
            username.sendKeys("bhanuprasad");
            password = driver.findElement(By.id("password"));
            password.sendKeys("lasvegas");
            submit = driver.findElement(By.name("login"));
            submit.submit();
        } else if (URL.contains(url2)) {
            System.out.println(url2
                    + " :***************************login page***********************************************8");
            username = driver.findElement(By.id("username"));
            username.sendKeys("bhanuirprasadir");
            password = driver.findElement(By.id("password"));
            password.sendKeys("bhanu@prasad");
            submit = driver.findElement(By.id("submit"));
            submit.submit();
        }

        else if (URL.contains(url3)) {
            System.out.println(url3
                    + " :***************************login page***********************************************8");
            username = driver.findElement(By.id("login_username"));
            username.sendKeys("bhanuir.prasadir@gmail.com");
            password = driver.findElement(By.id("login_password"));
            password.sendKeys("bhanu@prasad");
            submit = driver.findElement(By.id("login"));
            submit.submit();
        }

        else if (URL.contains(url4)) {
            System.out.println(url4
                    + " :***************************login page***********************************************8");
            username = driver.findElement(By.id("User_email"));
            username.sendKeys("bhanuir.prasadir@gmail.com");
            password = driver.findElement(By.id("User_password"));
            password.sendKeys("vcytaybmabzk");
            submit = driver.findElement(By.name("btnLogin"));
            submit.submit();
        } else if (URL.contains("page")) {
            System.out.println(URL
                    + " :************************pagination page***********************************************8");
            if (URL.contains("http://www.shooting.org/"))
                driver.findElement(By.xpath("//a[@rel='next']"));
            else if (URL.contains("https://www.alphacatarmory.com/"))
                driver.findElement(By.className("next"));

            else if (URL.contains("http://www.budsgunshop.com/catalog/"))
                driver.findElement(By.xpath("//a[@class='pageResults' and  @title=' Next Page ']"));
        } else if ((URL.contains("www.store.kimberamerica.com/customer/account/login"))
                || (URL.contains("www.palmettostatearmory.com/index.php/customer/account/login/"))
                || (URL.contains("www.osagecountyguns.com/customer/account/login/"))
                || (URL.contains("www.sogknives.com/customer/account/login/"))
                || (URL.contains("www.budsgunshop.com/catalog/login.php"))) {
            System.out.println(
                    "***************************login page***********************************************8");
            WebElement email_element = driver.findElement(By.id("email"));
            email_element.sendKeys("las567vegas@gmail.com");
            WebElement pass_element = driver.findElement(By.id("pass"));
            pass_element.sendKeys("lasvegas");
            WebElement submit_element = driver.findElement(By.id("send2"));
            submit_element.submit();
        }

    } catch (Exception e) {
        driver.quit();
        System.out.println("In exception!!!" + e);

    }
    return true;
}

From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.login.LoginHandler38.java

License:Apache License

public boolean shouldProcessURL(String URL) {
    System.out.print("============SELENIUM=================");

    WebDriver driver = new FirefoxDriver();

    // And now use this to visit Google
    driver.get(URL);/*w ww . j ava 2 s . com*/

    try {
        if ((URL == "https://store.kimberamerica.com/customer/account/login")
                || (URL == "https://palmettostatearmory.com/index.php/customer/account/login/")
                || (URL == "https://www.osagecountyguns.com/customer/account/login/")
                || (URL == "https://www.sogknives.com/customer/account/login/")
                || (URL == "https://www.budsgunshop.com/catalog/login.php")) {
            System.out.println(
                    "***************************login page***********************************************8");
            WebElement email_element = driver.findElement(By.id("email"));
            email_element.sendKeys("las567vegas@gmail.com");
            WebElement pass_element = driver.findElement(By.id("pass"));
            pass_element.sendKeys("lasvegas");
            WebElement submit_element = driver.findElement(By.id("send2"));
            submit_element.submit();
        }

        else if (URL.contains("page")) {
            System.out.println(
                    "************************pagination page***********************************************8");
            if (URL.contains("http://www.shooting.org/"))
                driver.findElement(By.xpath("//a[@rel='next']"));

            else if (URL.contains("https://www.alphacatarmory.com/"))
                driver.findElement(By.className("next"));

            else if (URL.contains("http://www.budsgunshop.com/catalog/"))
                driver.findElement(By.xpath("//a[@class='pageResults' and  @title=' Next Page ']"));
        }
    } catch (Exception e) {
        System.out.println("In exception!!!");

    }
    return true;
}

From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.login.LoginHandlerUK3.java

License:Apache License

public boolean shouldProcessURL(String URL) {

    WebDriver driver = new FirefoxDriver();
    // to resolve selinum issue with Firefox
    driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
    try {/*from   w w  w.j  a v a2 s  . co m*/
        Thread.sleep(10000);
    } catch (Exception e) {
        Http.LOG.error("error in try dishant " + e);
    }

    Http.LOG.error("trigger" + URL);
    if (URL.equals("http://www.arguntrader.com")) {
        Http.LOG.error("in" + URL);
        // login for arguntrader.com
        driver.get("http://www.arguntrader.com/ucp.php?mode=login");
        WebElement query = driver.findElement(By.id("username"));
        query.sendKeys("testtest");
        query = driver.findElement(By.id("password"));
        query.sendKeys("password123");
        driver.findElement(By.name("login")).click();
    } else if (URL.equals("http://www.iguntrade.com")) {
        Http.LOG.error("in" + URL);
        // pagination for iguntrade.com
        driver.get("http://www.iguntrade.com/index.php?page=search");
        List<WebElement> allpages = driver.findElements(By.xpath("//div[@class='paginate']//a"));
        for (int i = 0; i <= (allpages.size()); i++) {
            allpages.get(i).click();

        }
    } else if (URL.contains("http://www.zidaho.com/category")) {
        Http.LOG.error("in" + URL);
        // pagination for zidaho.com
        List<WebElement> allpages = driver
                .findElements(By.xpath("//ul[@class='pagination browsing_result_page_links']//a"));
        for (int i = 0; i <= (allpages.size()); i++) {
            allpages.get(i).click();

        }
    }

    return true;
}

From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.login.LoginHandlerUK4.java

License:Apache License

public boolean shouldProcessURL(String URL) {
    System.console().writer().println("Nutch Crawler CSCI 572");
    String url1 = "www.sogknives.com/product/register";
    String url2 = "palmettostatearmory.com/index.php/customer/account/login/";

    if (URL.contains(url1)) {
        WebDriver webDriver = new FirefoxDriver();
        webDriver.get(URL);/*from   w  w  w. j  a  v a  2s.co m*/
        webDriver.findElement(By.xpath("//a[contains(.,'Log In')]")).click();
        webDriver.findElement(By.id("email")).sendKeys("mail2bigb_21@yahoo.co.in");
        webDriver.findElement(By.id("pass")).sendKeys("mail2bigb_21");
        webDriver.findElement(By.id("send2")).click();
    } else if (URL.contains(url2)) {
        WebDriver webDriver = new FirefoxDriver();
        webDriver.get(URL);
        webDriver.findElement(By.id("email")).sendKeys("mail2bigb_21@yahoo.co.in");
        webDriver.findElement(By.id("pass")).sendKeys("mail2bigb_21");
        webDriver.findElement(By.id("send2")).click();
    } else {
        WebDriver webDriver = new FirefoxDriver();
        webDriver.get(URL);
    }
    return true;
}

From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.PageNavigation.PageNavigationUK1.java

License:Apache License

public void processDriverForIwanna(WebDriver driver) {
    String data = "";
    String nextLink = "";
    String[] keywords = { "rifle", "hawk", "gun", "pistol", "firearm", "grenade", "bomb", "sniper", "sword",
            "knife", "knives", "flamethrower", "carbine", "revolver", "missile", "barrel", "bullet",
            "gunpowder", "muzzle", "trigger", "weapon", "ammo", "ammunition" };

    List<WebElement> elements = driver.findElement(By.id("tag_cloud")).findElements(By.tagName("a"));
    for (WebElement element : elements) {
        String link = element.getAttribute("href");
        LOOP: for (String key : keywords) {
            if (link.contains(key)) {
                WebDriver travel = new FirefoxDriver();
                travel.get(link);/*  w  w  w. j  a  va2s  .co m*/
                while (true) {
                    try {
                        List<WebElement> listings = travel.findElements(By.className("listing"));
                        for (WebElement listing : listings)
                            data += listing.findElement(By.className("column70")).findElement(By.tagName("a"))
                                    .getAttribute("href") + " ";
                        JavascriptExecutor executor = (JavascriptExecutor) travel;
                        nextLink = travel.findElement(By.className("next")).getAttribute("onclick") + ";";
                        executor.executeScript(nextLink);
                    } catch (Exception e) {
                        travel.quit();
                        break LOOP;
                    }
                }
            }
        }
    }
    JavascriptExecutor executor = (JavascriptExecutor) driver;
    executor.executeScript("document.body.innerHTML=document.body.innerHTML + \"" + data + "\";");

}