disable javascript exceptions when running selenium code

  • 1 Replies
  • 1575 Views
disable javascript exceptions when running selenium code
« on: July 31, 2016, 19:55:43 pm »
Is it possible to disable the exceptions the browser is throwing while running webdriver test suites ?

Re: disable javascript exceptions when running selenium code
« Reply #1 on: August 22, 2016, 11:01:32 am »
You could possibly do it if you use HtmlUnitDriver.

You would need to override the modifyWebClient() method though:

Code
public class HtmlDriver extends HtmlUnitDriver {
 @Override
    protected WebClient modifyWebClient(WebClient client) {
        WebClient _client = super.modifyWebClient(client);
        _client.getOptions().setThrowExceptionOnScriptError(false);
        return _client;
    }
}

 

Sitemap 1 2 3 4 5 6 7 8