Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetching innerHTML #148

Open
ptriller1und1 opened this issue May 17, 2024 · 2 comments
Open

Fetching innerHTML #148

ptriller1und1 opened this issue May 17, 2024 · 2 comments

Comments

@ptriller1und1
Copy link

I am just in the process of upgrading selenium to the newest version and I am trying to switch to htmluit3 in this process
but I have not figured out how to get innerHTML with the new version

    HtmlUnitDriver driver  = new HtmlUnitDriver(false);
    driver.get("https://www.google.de");
    System.out.println(driver.findElement(By.tagName("body")).getAttribute("innerHTML"));

This works fine with the old htmlunit driver but returns null in the htmlunit3 verions

When tested it with htmlunit3-driver:4.20.0 it returns null
When I tested it with htmlunit-driver:4.13.0 it returns the innerHTML as expected

@rbri
Copy link
Collaborator

rbri commented May 17, 2024

@ptriller1und1 interesting point - at the moment getting javascript properties (like innerHTML) are not supported if js is disabled.

Technically we only have to disable the support if the javascript engine is disabled (for more about the differences see https://www.htmlunit.org/javascript-howto.html#Enable.2FDisable_JavaScript_support).
Will think about that - maybe i have to adjust this...

As a workaround you can do something like

HtmlUnitDriver driver  = new HtmlUnitDriver(true);
driver.getWebClient().getOptions().setThrowExceptionOnScriptError(false);
driver.get("https://www.google.de");
System.out.println(driver.findElement(By.tagName("body")).getAttribute("innerHTML"));

@rbri
Copy link
Collaborator

rbri commented May 18, 2024

@ptriller1und1 is think you are right in all point here - fixed now.

Will do a release later today.

rbri added a commit that referenced this issue May 18, 2024
…e exceution of js methods is disabled for the driver (issue #148)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants