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.){
public WebClient modifyWebClient(WebClient client){ webClient.getOptions().setJavaScriptEnabled(true); webClient.getOptions().setThrowExceptionOnFailingStatusCode(true); webClient.getOptions().setThrowExceptionOnScriptError(true); return client; } }; driver.setJavaScriptEnabled(true);

1 comment:

  1. Most people who come here are looking for how to disable warnings as opposed to errors. Here's the code for that: