开发者

Selenium HtmlUnit freeze randomly loading a web page

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 Fir开发者_StackOverflowefoxDriver();
        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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜