Google Groups

HtmlUnitDriver cannot render content if style="display:none"

fritz Feb 9, 2010 2:57 PM
Posted in group: webdriver
Having trouble trying to get the content of an hidden div, if the
content was embedded by a javascript function upon loading the page.
I'm using webdriver-htmlunit version: 0.9.7376. Is this a known issue?
See below for the code.

Sample codes below.

1. save as sample.html
   function populateHiddenHolder() {
     var hidden = document.getElementById("hidden");
     hidden.innerHTML = "content from the hidden div";
  <body onload="populateHiddenHolder()">
    <div id="visible">content from the visible div!</div>
    <div id="hidden" style="display:none"></div>

2. Run this WebDriver test.
public void test() {
 HtmlUnitDriver driver = new HtmlUnitDriver();

 WebElement visible = driver.findElement("visible"));
 System.out.println("visible:: " + visible.getText());

 RenderedWebElement hidden =
 System.out.println("hidden:: " + hidden.getText());

3. Result (failed! hidden content is not displaying)

visible:: content from the visible div!

Note: this works fine if style="display:none" is removed from the
hidden DIV.