Selenium htmlUnit dynamic content not working

427 views Asked by At

I'm trying to create selenium tests for one site. In short, when a user opens the site, a CMS adds some dynamic elements (HTML + JS) to the page.

When I run tests on FF driver - all is OK.

FF Driver config:

DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability(CapabilityType.ELEMENT_SCROLL_BEHAVIOR,1);
return new FirefoxDriver(desiredCapabilities);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

Some page part, in this case.

driver.getPageSource()

http://pastebin.com/P3F6HsDP

As you can see, the dynamic block does exist.

But in the case of HtmlUnit:

HtmlUnitDriver htmlUnitDriver = new HtmlUnitDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

... the dynamic block doesn't exist: http://pastebin.com/b4iRGzjM

Can you please suggest how I can fix it or share some thoughts?

I tried:

  htmlUnitDriver.setJavascriptEnabled(true);

But I got the following error: http://pastebin.com/qRazGjGY

1

There are 1 answers

0
Java Dude On

Have not fixed this. So, I've stared to use Remote Driver + PhantomJS. HTMLunit don't support all JS libs.