TestProject Forum
Powered by leading experts in the test automation community

Disable javascript exceptions when running selenium code

Is it possible to disable the exceptions the browser is throwing while running webdriver test suites ?

You could possibly do it if you use HtmlUnitDriver.

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

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