HtmlUnit - dynamically loaded JavaScript not working

I am trying to write some automated website tests using HtmlUnit. Our web pages load two JavaScripts, one of which then loads several other JavaScripts dynamically into the DOM. These JavaScripts then do some user interface initialization. My problem is that HtmlUnit is updating the DOM with the new JavaScripts, but it doesn't seem to start these JavaScripts because the expected DOM elements are not showing.

Here are some things I've tried:

  • View page with toXml(). The page.toXml () method shows added JavaScripts, but not expected user interface elements.
  • Testing for the expected DOM elements. They are displayed in a real web browser, and I can use jquery and firebug together to confirm that they are.
  • Trying to manually run JavaScripts through executeJavaScript. When I do this, it can find a method that I call directly, but this method cannot find characters in other Java scripts.

Has anyone else encountered this problem?

+5
source share
1 answer

Did you try to insert a short pause after loading the page?

+1
source

All Articles