1

im having a problem with HtmlUnitDriver using Selenium.

Im using the Selenium 2.5 version.

The test is so simply and usualy it works correctly but sometimes the driver just stop and wait endlessly for a page to load.

my code is something like this:

initialization...

private WebDriver driver;
    driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_3_6);((HtmlUnitDriver) driver).setJavascriptEnabled(true);
        //driver = new FirefoxDriver();
        driver.manage().timeouts().implicitlyWait(0, TimeUnit.MILLISECONDS);
        driver.manage().timeouts().setScriptTimeout(0, TimeUnit.MILLISECONDS);

and then a lot of blocks like this one:

new Actions(driver).moveToElement(driver.findElement(By.linkText("Someting"))).perform(); 
        driver.findElement(By.linkText("something else")).click();
        driver.findElement(By.name("something")).sendKeys("8");
        driver.findElement(By.xpath("//img[@title='something']")).click();

after each clic() it loads a new page.

I usualy end the whole test correctly and i have try catched all the blocks so the web is not the problem.

The webdriver is ignoring the timeouts(i try a lot of diferent timeouts and the problem persists) and i cant stop the driver from another threads invoquing "quit()" or "close()"

I search everywhere but i cant found a solution.

¿Anyone can help me?

Thanks in advance.

Anonimo
  • 97
  • 5

2 Answers2

2

I solve it, i post my solution if anyone have the same problem.

Im pressing esc from other thread (the main is busy waiting...)

((HtmlUnitDriver) test.getDriver()).getKeyboard().pressKey(Keys.ESCAPE);

and then i kill the browser and restart the test

test.getDriver().quit(); restart();//create a new test instance
Anonimo
  • 97
  • 5
0

I've faced this behaviour before.

I would first update to 2.9 and try again

Then, I would check the pages I'm hitting, because if they have frames or iframes they get downloaded too and if you don't control their content anything could happen

Take a look at this link because it might have the solution you're looking for.

Hope this helps.

Community
  • 1
  • 1
Mosty Mostacho
  • 42,742
  • 16
  • 96
  • 123
  • Thanks for the reply, im using Selenium 2.5 that uses HtmlUnit 2.9. And i read that question, and yes, the page have frames. But i want to load em all :s Now im trying to press esc from other thread (the main is busy waiting...) ((HtmlUnitDriver) test.getDriver()).getKeyboard().pressKey(Keys.ESCAPE); and then i kill the browser and restart the test test.getDriver().quit(); restart();//create a new test instance It seems to work but im waiting the last real test. thanks again – Anonimo Sep 13 '11 at 16:15