Selecting multiple screenshots from a webpage and saving their images to a local folder

Goal: I want to go to a website, download images from a gallery one by one and then saving them on a local folder

Workflow I’ve done inside a sequence:

  1. An input dialog that asks me how many images I want to download. My answer is stored in a variable called number

  2. An open browser activity that goes directly to the first image of the provided gallery of the website

  3. Inside a Do activity I’ve:
    3.1. An Assign activity with a variable called val with the default value of 0
    3.2. A Do While acvity with another sequence:
    3.2.1. A Take Screenshot activity
    3.2.2. A Save Image activity
    3.2.3. A Click activity (that clicks on the Next button of the gallery to go to another page and get another image)

obs: The Do While condition is val < CInt(number)

Sounds like a simple workflow. However, here’s what happens: For example, if I answer that I will want to download 6 images. The first one works good, the second one works good and between the third and the fifth, the selector behaves weird. He makes some sort of zoom into the second picture of the gallery. All of sudden, the 6th and final picture gets download and saved again normally. At the second image, he doesn’t takes the screenshot of the area I wanted. He basically clicks the image and gets me the full resolution image.

I also get a Worfklow Exception that says:

“Main has thrown an exception
Message: The UiElement is no longer valid
Source. Click 'A ’
Exception Type: InvalidUiElementException”

Could anyone give any tip of how to debug this problem?

1 Like

Is this a Slideshow?

This is the website:

Cool pics. I like the Jupiter Red spot pic. :slight_smile:

Hi @mrrobot,

can you please refer this xaml to get the all the images from the website and it will store it into your local machine. (instead of taking screenshot you can save image)


Hello @arivu96,

Thanks for your file, it’s appreciated. However, it is not suited to the behavior I want to accomplish. Your file might be useful in some cases but not in this particular case. I don’t need all the images from a website, I only need the amount of images the user wants when he provides that information on an input dialog. And I really need to use the Take Screenshot activity.


because i liked the images.

BTW, if screenshots only, just replace Http Request activity with below (change your path), probably page scroll is required.


downloadImage.xaml (22.7 KB)

1 Like

Hello @vvaidya,

So, first things first, thank you for your effort and time. I saw your workflow and it seems workable indeed, no doubts about it. However, I’m afraid is a little bit too much advanced for me as I’m just starting with UiPath and some programming mindsets are still out of bounds for me.

Having said this, I thought that it could be useful a not so complex workflow. Therefore, I leave in annex my current workflow with the hope of someone understanding and explaining to me what’s the issue. I think the workflow logic I have it’s pretty simple and straight forward.

TakeScreenshotAndSaveImage.xaml (13.1 KB)

When you are taking a screenshot, is the image clearly visibly on the screen? In my laptop i have do to “page down” to go to second Image. In 3rd page because of text in between, 80% of Image is visible.

TakeScreenshotAndSaveImage.xaml (15.4 KB)

Just came across your problem . The selector varies dynamically when you click the “Next option”.
So , the solution is keep the next selector title as generic and try to run the code. It perfectly works.
Refer the image and paste the selector for the “Next” activity.

1 Like