Closed marcelocecin closed 3 years ago
Hello @marcelocecin
You may try the following depending on whether you want to:
**Scenario 1**
for n from 1 to 3
if (//*/table/tbody[`n`]/tr[1]/td[5]/span/text() == '350,90')
click //*/table/tbody[`n`]/tr[1]/td[6]/form[3]/input
**Scenario 2**
click (//*[@class="mr5 " and text() = "350,90"]/../..//*[@class="noClick"]//input)[3]
You can also put a variable price in place of 350,90 -
click (//*[@class="mr5 " and text() = "`price`"]/../..//*[@class="noClick"]//input)[3]
hello @ruthtxh, it worked perfectly thank you very much !
Just noticed there's a small typo in my solution, for looping it should be
for n from 1 to 3
That's great! Happy to help ~~
Thanks Ruth! I edited your solution to include the updated for loop. Your creating a html file to test is a great idea.
Hi Marcelo, adding on, while dom
step allows using functions in the browser like querySelector
, almost always there is no need to do that. Because TagUI has a smart algorithm to find the best match base on the element identifier you provide.
If you provide a very specific XPath or CSS selector, it'll work. If you provide something looser like the value of an id or name or text value or class or href etc it'll work too. Even if you provide something that is a partial match (eg the actual id is a longer string with some other text), it will work too. TagUI does the selection progressively to find the best match, from the most accurate element to something that matches loosely.
Thus, from a user perspective, give as specific as possible if you want to be sure what you are interacting on. Give as loose as possible (eg click email) to your level of comfort that works so that it is more readable. Lastly, you can make use of object repository if you want to hide these long strings away from the flow.
Also, if you specify an image snapshot of an UI element, TagUI will use computer vision to find it on the screen. And if you use (x,y) coordinates that'll work too. So, there are multiple ways to the same outcome, for user to choose best for scenario.
Adding on, video of how the XPath of that sibling save icon is found - https://www.youtube.com/watch?v=3xaP8rRzoVQ
hello @ruthtxh and @kensoh in this case I first tried to use computer vision, however the price values were not being found more and more TAGUI surprises me with the possibilities of interacting with several complex scenarios in addition, your response time and level is surprisingly excellent! thank you so much again !
hello @kensoh
I'm trying to capture another link from another website
I followed the directions in your video and managed to capture it by the safari inspector: //h4[contains(text(),'11/02/2021')]/a[contains(text(),'BOI')]/@href
however when I run on TAGUI the error occurs that I did not find the occurrence
Hi Marcelo, the reason is the use of single quotes in XPath. I think this is not mentioned in the new documentation.
TagUI sends the search over to Chrome enclosed in single quotes. A single quote in the XPath will throw error from Chrome.
Using double quotes in below XPath works as expected -
show //h4[contains(text(),"11/02/2021")]/a[contains(text(),"BOI")]/@href
I've also updated the new documentation on this. Thanks for raising this!
thank you ! @kensoh !
Our pleasure! Your queries and feedback will help us improve this free RPA tool, and bring more benefits to other users :)
Hello guys
I am facing a new situation and a new question came up about this case
in scenario 1, would it be possible to store in variable count
how many occurrences of tbody
are inside the table
?
so the loop would be automated according to this variable:
**Scenario 1**
for n from 1 to `count`
if (//*/table/tbody[`n`]/tr[1]/td[5]/span/text() == '350,90')
click //*/table/tbody[`n`]/tr[1]/td[6]/form[3]/input
thanks !
Hi Marcelo! You can use the count() function, it returns how many matches there is base on an identifier you provide. For eg -
total_items = count('xpath to test')
For example, if //*[@class="mr5 "
returns 3 matches, then 3 will be assigned to total_items, which you can use in a loop.
Adding on - besides full XPath, it can be relative XPath or CSS selector or various HTML attributes can be used to match.
hello Ken, perfect ! thanks again !
hi Ken ! I need to click on the
save icon
according to a value, example:350,90
can you please help me with this scenario ?
I believe that one of the ways would be to do a search using DOM
querySelector
andnextSibling
or XPathfollowing-sibling
so I can click in this buttonthank you very much !