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

Add constructor option to force HtmlUnit to download images on every page load #40

Closed
stiemannkj1 opened this issue Feb 9, 2017 · 3 comments
Assignees
Milestone

Comments

@stiemannkj1
Copy link

stiemannkj1 commented Feb 9, 2017

Every browser that I use with (Firefox, Chrome, PhantomJS, and JBrowser) Selenium automatically downloads all images on each page. HtmlUnit does not download the images. While I appreciate the design choice to avoid downloading images (it certainly seems like it would speed up page loads), this behavior is inconsistent with other browsers and causes HtmlUnit to fail tests that other browsers pass. I am requesting that a constructor option or (Capabilities) capability be added to HtmlUnitDriver to specify that it should automatically download all images (similar to HtmlUnitDriver's constructor option to enable JavaScript).

One way to accomplish this task would be to run this code every time a new page is encountered:

DomNodeList<DomElement> imageElements = htmlPage.getElementsByTagName("img");

for (DomElement imageElement : imageElements) {

	HtmlImage htmlImage = (HtmlImage) imageElement;

	try {

		// Download the image.
		htmlImage.getImageReader();
	}
	catch (IOException e) {
		// do nothing.
	}
}
@stiemannkj1
Copy link
Author

@juangon
Copy link

juangon commented Feb 9, 2017

👍

@asashour asashour self-assigned this Feb 10, 2017
@asashour asashour added this to the 2.25 milestone Feb 10, 2017
@asashour
Copy link
Contributor

Thanks for reporting, it has been committed in 2.25 branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants