hollingsworthd / jBrowserDriver

A programmable, embeddable web browser driver compatible with the Selenium WebDriver spec -- headless, WebKit-based, pure Java
Other
812 stars 143 forks source link

Disable script injection when JS disabled #188

Open 0604hx opened 8 years ago

0604hx commented 8 years ago

I use JBrowserDriver to load some webpage and save the page source. My code is like: WebElement webElement = webDriver.findElement(By.xpath("/html")); String content = webElement.getAttribute("outerHTML");

But I find the page source file is so huge (1800Kb, but the origin page source is only 50Kb).

I find some code were added into page source, like this

image

How can I remove those code? Thanks a lot.

hollingsworthd commented 8 years ago

Thanks for reporting this. That bit of JS is injected by the driver into the page. It's supposed to remove itself from the DOM after executing. Seems to work most times. Do you have a test case or web page I can reproduce this with?

hollingsworthd commented 8 years ago

I'd assume maybe this is caused by running with JS disabled via Settings.