Why doesn't HtmlUnitDriver execute JavaScript?

前端 未结 5 1849
滥情空心
滥情空心 2020-12-20 12:00

I got the following problem: I am running a JUnit testCase with Selenium 2.9 using HtmlUnitDriver with Browserversion Firefox_3_6. JavaScript is enabled. Now when it should

5条回答
  •  天涯浪人
    2020-12-20 12:38

    If you wish to set the BrowserVersion as well as enable Javascript with HtmlUnitDriver, your initialization needs to look like the following (as there is no way to do both via the constructor):

    HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_3_6);
    driver.setJavascriptEnabled(true);
    

    This will allow you to use the browser definition of your choice and use Javascript.

提交回复
热议问题