HtmlUnit - dynamically loaded JavaScript not running

I'm trying to write some automated tests of a website 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 UI initialization. My problem is that HtmlUnit updates the DOM with the new JavaScripts, but does not then seem to run those JavaScripts, because expected DOM elements do not appear.

Here are some things I tried:

  1. Viewing the page with toXml(). The page.toXml() method shows the JavaScripts added, but not the expected UI elements.
  2. Testing for the presence of expected DOM elements. These show up in a real web browser, and I can use jquery and firebug together to confirm that they are there.
  3. Trying to manually start the JavaScripts through the executeJavaScript. When I do this, it can find the method I'm invoking directly, but that method cannot find symbols in other JavaScripts.

Has anyone else ran into this issue?


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

Need Your Help

What alternatives to __attribute__ exist on 64-bit kernels?

c gcc iso

Is there any alternative to non-ISO gcc specific extension __attribute__ on 64-bit kernels ?

PhpStorm; how to hide line status in editor

ide styles phpstorm

Is there any way to hide or change those line status in PhpStorm 8.0.3?