If else click?

I’m trying to create a robot that will do a search in web form and depending on the result the click options are different.
May occur randomly…
I don’t know what is the best strategy to execute this?
1 the search returns nothing so I go back to the search

2 back document information but it doesn’t have it attached to download

3 more information and you have the document for download

Hi @Rodrigo_Buch I recommend using an Element Exist activity to determine if “Nao existem notas…” message is found.

That activity returns a boolean that you can then evaluate

Hope it helps!

Check this one - very similar to what you require:


You could also try the pick branch activity which will trigger based on the found element.

André :robot:

Thanks for the help, it worked perfectly with a few tweaks.

But in one of the options I need to download the image, only it is stored in an S3 bucket so when I click on the download button it opens another browser tab…

So how do I right click the browser and download the image?

It actually made it a little more complicated, because sometimes it’s jpg images and sometimes it’s pdf.

So the browser behavior is different. when it is jpg it opens another tab and when it is pdf it downloads directly

Hi @Rodrigo_Buch , The “Click” activity allows you to define if it is a right or left click. Look at the " MouseButton property in the properties panel of “Click”.

You can also try and do a “Get Attribute” of the element where the PDF/JPG is and then check if it is PDF/JPG. Once you know, you can act accordingly!

So that’s the problem, I don’t know when it will be PDF or JPG, only when I click on the download button.

Is the download button a hyperlink or is there any where else from where you can get the name of the file? If yes, you can do a GET ATTRIBUTE (activity) to try and get the filename - if that ends in a .pdf, it is a pdf; in .jpg, it is a jpg.

Also, try looking at the source code of the page, if this is a webpage and search for .pdf and/or .jpg to see if the name is available.

Other option could be to click the download button and then check if a new file is downloaded. If it is, good (move on). If not, trigger the download image code.

Hi @Rodrigo_Buch … Which browser are you using? because probably is easier configurate the browser and active always the dialog to download.

@Rodrigo_Buch I would try to get attribute as @sumitd says and then use HTTP Request activity (from UiPath.WebAPI.Activities package)


Endpoint: Link to download
Method: GET
Resource Path: Full download path (including name and extension)

Hope it helps

Hi Carmen

I tested it but it didn’t work because it only asks for the download for the PDF, for JPG it opens a new tab directly.

If you are able to get hyperlink from Download Icon you can use it on endpoint property of HTTP Request Activity.

It works with simple setup in most cases. In other it is more compelx to get it done

ok… and what happen if you do click with the other button ? Just wondering if it shows another menu that could help …

right button


Salvar Link como … is the same as Save as? if you click there what happens?

saves the file correctly the problem I don’t know in advance when it will be PDF or JPG

oh I thought your problem was saving the files … so lets recap …

You problem is that you need to know before what kind of file it is? and then?

what I’m doing is that the robot will search for invoice numbers from an xlsx and when there is a file, download it, but sometimes it’s a pdf and other times it’s images and the browser works differently for PDF and images

I don’t know if it would work…
thought I’d use Elements Exists and check that element from the PDF if it finds it click save or use a SendHotkey “crtl +s” and save

so … why you dont try intead with click Right Botton and save it? seems to me that will work in any case. Or you just need to save ONLY the pdf ? in that case I think that your solution is ok aswell.

thank you for the help

I’ll try with Firefox since it has this option to always open the pdf in the browser and it would work equally well for the images.