Selenium problem with get!

5

What I want

Open a browser using Selenium, making you go to a website (eg link ) driver.get("http://www.google.com"); and type in its text field a search element.sendKeys("Cheese!"); after finalizing submit form to search element.submit();

Problem

The driver instance is successful and Firefox opens, but it will be in the initial screen "Blank page" without doing anything else. It does not have an error message, it just does not.

Code

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

public class TesteAutomatizado  {
    public static void main(String[] args) throws InterruptedException {

        WebDriver driver = new FirefoxDriver();

        driver.get("http://www.google.com");
        WebElement element = driver.findElement(By.name("q"));

        element.sendKeys("Cheese!");

        element.submit();

        System.out.println("Page title is: " + driver.getTitle());

        (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver d) {
                return d.getTitle().toLowerCase().startsWith("cheese!");
            }
        });

        System.out.println("Page title is: " + driver.getTitle());
        driver.quit();
    }
}

Sample Page

Question

I've looked in various places on the internet and the examples are the same. Would anyone have any idea what might be going on?

    
asked by anonymous 05.05.2014 / 18:15

2 answers

6

Be careful updating the Firefox version. Take a look at Selenium changelog and see the latest supported version.

Unfortunately, since Firefox is changing a lot of the version, it is difficult for the Selenium team to generate a compatibility-only version.

Looking at the log I mentioned and linkei, the latest version of Selenium (2.41.0), supports Firefox 28. If I'm not mistaken, version 29 was released in April.

It's a headache, but I've always had to instruct company personnel to stick with a fixed version of Firefox, disabling automatic updating.

An alternative is to use a portable version of Firefox in another directory and specify the executable at Selenium / WebDriver startup.

    
05.05.2014 / 19:23
1

Downgrading the Firefox version is not always necessary. Once Firefox is updated a new version of the Selenium API is released to comply with the latest version of the browser.

    
20.05.2014 / 15:56