Tuesday, November 10, 2015

Cannot find function addEventListener in object [object HTMLDocument]

If you get this error, do not worry. The answer is not difficult to understand.
ANSWER: 
   do not initialize your HtmlUnit WebClient like this: 
      new WebClient();
   instead, initialize it like this: 
      new WebClient(BrowserVersion.FIREFOX_38);
The default "browser" that the HtmlUnit WebClient gives you does not have some of the basic JavaScript functions available to call such as "addEventListener".

See also: HtmlUnit issue tracker non-issue 1615.

No comments:

Post a Comment