How to capture / get image from url path?

Hi Everyone,

Currently I am developing project for automation testing using Katalon. I need to capture an image and save it as file. I can take the screenshot by using the below script:

//Take screenshot

But the problem is I just got half of the image size, need to scrool down to get full size.
Is there any way to get an image by using the url path.
This is the example image in my html/browser:

“<div class=“card” style=“background-image:url(”/test-path/en/images/test.png”); display:none">"

Thanks in advance,

The short answer is yes but only if the image fits inside the browser viewport.

There are issues with the question you’re asking. WebUI.takeScreenshot doesn’t capture/save HTML image elements. It captures only the content of the viewport as an image. It does that even if there are no images displayed in the browser.

Regarding your <div> element. It is set to display:none. Your background image will be invisible.

If you want to capture a specific image using WebUI.takeScreenshot you could probably manipulate the HTML on the page to ensure the image fits within the browser viewport. But that is a bad idea. You are not testing a webpage, you are modifying a webpage using test code.

If I have misunderstood your intentions, please explain further.

1 Like


capture your image by locator

public void captureImage(){
	WebElement image = DriverFactory.getWebDriver().findElement(By.xpath("//img[@id='hplogo']"))
	String imgSrc = image.getAttribute("src")
	URL imageURL = new URL(imgSrc)
	BufferedImage saveImage =
	ImageIO.write(saveImage, "png", new File("C:\\Users\\\\Desktop\\data\\screenshots\\test-image.png"))
1 Like

Thanks @Russ_Thomas for reply, it’s absolutely true that “WebUI.takeScreenshot doesn’t capture/save HTML image elements”. It captures what the current displayed on the browser and not the specified image. I think manipulate the HTML on the page could be last option and nice to try.

Hi @Timo_Kuisma1,

I will try this one and come back for update.

Regards with many thanks.