ISTQB Certified Software Test Engineer

Sunday, May 25, 2014

Ignoring JS Errors in HTML Unit Driver --Here is the Solution

When you are using one of the greates features of Selenium,Headless browser,we may find several issues like javascript handling,unable to handle ajax calls and soon... Here is the confiuration of Htmlunit driver,so that we can over come those issues.

HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.){
@override
public WebClient modifyWebClient(WebClient client){ webClient.getOptions().setJavaScriptEnabled(true); webClient.getOptions().setThrowExceptionOnFailingStatusCode(true); webClient.getOptions().setThrowExceptionOnScriptError(true); return client; } }; driver.setJavaScriptEnabled(true);