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();
}
}
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.
– Felipe Fonseca
That may be, I recently upgraded to the latest version.
– ralfting
Try to test on more than one browser, to check incompatibilities In some tests I did gives difference between Chrome and Firefox.
– Fdadamos
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
– fabiohbarbosa