This is my first post.
I just started learning RPA, I did already automated some actions, but for the love of god I can’t figure out how to click a dynamically generated link.
In few words, in this intranet like website, I have a section where I can query for specific reports, when i click on query, a link gets generated.
When I do inspect this link i get this:
Open file …/Queries/Qry123411.csv generated 10/01/2023 13:55
I Am using the RPA.Browser.Selenium Library.
I have tried all sorts of combinations, what I do not get is why a simple click link href:“…/Queries/Qry123411.csv” does not work and returns link not found.
Any help is very appreciated
<a href="../Queries/Qry123411.csv" target="Qry123411"> Open file ../Queries/Qry123411.csv generated il 10/01/2023 13:55</a>
Sorry, this is the inspected content
(not that I have experience with that problem, but here are my thoughts)
That does not seem to be a valid link.
Maybe It should be
<a href="file:/// (it is missing the protocol) or
The relative path is the point here. The server should know to resolve it when you click the link.
I usually recommend to anyone new to test automation to learn how to construct xpaths, this is a skill that you’ll find useful as this standard selection method is used by many test automation tools not just Robot Framework. A good starting point is this XPath Tutorial
In your case, you just need to identify what parts of the link remains constant so you can use that to identify the link.
Here are some examples that could work for you:
Click Link //a[contains(@href, ".csv")]
Click Link //a[contains(@href, "Queries")]
Click Link //a[contains(text(), "generated il")]
Click Link //a[contains(text(), "Open file")]
Hope that helps,
Hey, thank you both for your answers!
I saw the tutorial, thank you for that, I now understand the logic behind xpath.
Unfortunately, none of your suggestions works, I suppose this link gets generated in a wierd way.
I say that because on other elements on the webpage, using dev tools I can exctract a working xpath but if I do the same on that particular element all I get is this:
What you suggested should work in theory
something to check in dev tools, if the link in a frame/iframe? you might need to use Select Frame before clicking the link?
Guessing “link not found” is what click link returns
Something worth checking, but you are prefixing the locator if your using an xpath that was suggested above?
Click Link xpath://a…
I believe if you don’t provide it from how it reads it will check against those stated in the documentation with xpath isn’t one unless you tell it:
Oh also something worth a try if you haven’t after the above, you may need to set a wait until if this link is dynamically generated.