Reputation: 25703
I am working with a page that has some JS errors like TypeError: 'undefined' is not a function (evaluating 'q.apply(m,d)')
, browsers seem to ignore these errors and the page functionality doesn't degrade, but PhantomJS throws an exception. How can I disable that? I've read how to ignore errors in phantomjs but I don't know how to do that with Selenium.
Upvotes: 0
Views: 2600
Reputation: 373
When I run my tests using PhantomJS 2.0 then I do not get the non-fatal javascript errors getting reported. However when I run with PhantomJS version 1.9.8 then I get the exact behavior that you describe. So simply upgrading the version of PhantomJS you are using to the latest may solve your problem.
Otherwise you can change the logging level of PhantomJS. I believe you can use code like this below where you instantiate the browser.
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);
caps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, "--webdriver-loglevel=ERROR");
WebDriver driver = new PhantomJSDriver(caps);
Upvotes: 1