HtmlUnit ScriptException errors

早过忘川 提交于 2019-12-04 17:55:32

Many questions are asked referencing this kind of issues. The ScriptException is raised because you have a syntactical error in your javascript. Most browsers manage to interpret the JS even with some kind of errors but HtmlUnit is a bit inflexible in that sense.

Your options are:

  1. Correct JS code
  2. Disable JS in the WebClient
  3. Don't use HtmlUnit. Use a different framework with better JS support such as PhantomJS (note it is not a Java-based framework)

I had the same error with the liveperson mTag.js

The problem is with the compacted mTag.js response.

There are several workaround:

  1. Replace the compacted mTag.js with a clear one (requires LivePerson support)
  2. Work with a 'real' Selenium WebDriver (Firefox Driver or similar)
ƒαrнαη
_webClient.getOptions().setThrowExceptionOnScriptError(false);

works in this incorrect JS scenario.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!