Selenium problem with get!

Asked

Viewed 1,701 times

5

What I desire

Open a browser using Selenium, accessing a website (e.g..: http://www.google.com) driver.get("http://www.google.com"); and write a search in his text field element.sendKeys("Cheese!"); after submitting the form to perform the search element.submit();

Problem

The driver instance is done successfully and Firefox opens, but is on the home screen "Blank Page" without doing anything else. No error message, 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();
    }
}

Page of the example

Question

I’ve searched several places on the internet and the examples are the same. Would anyone have any idea what might be going on?

  • What version of Firefox? I usually encounter problems using Selenium in newer versions of Firefox. Test with another Driver or downgrade your version of Firefox to test.

  • That may be, I recently upgraded to the latest version.

  • Try to test on more than one browser, to check incompatibilities In some tests I did gives difference between Chrome and Firefox.

  • I’ve never tried with Firefox dude, I use the Chrome drive which I find simpler... in case you’re interested I have a tutorial for this: http://wp.me/p2DZEL-4P

2 answers

6


Be careful when updating the Firefox version. Look before the changelog Selenium and see what the latest compatible version.

Unfortunately, as Firefox is changing a lot of version, it is complicated for the Selenium team to generate a version only for compatibility.

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

It’s a headache, but I always needed to instruct the company staff to keep a fixed version of Firefox, disabling the automatic update.

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

1

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

  • 1

    Not always. But just to quote one example, to this day there is no version of Selenium for FF 29. This means that anyone who for some reason installed the latest version of FF more than 20 days ago cannot run Selenium with it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.