sourabhkt / robotframework-seleniumlibrary

Automatically exported from code.google.com/p/robotframework-seleniumlibrary
Apache License 2.0
0 stars 0 forks source link

Loop through all XPath Matches found and Transfer to a List #201

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

Relatively new with the Robot framework and currently trying it out. I have the 
following requirement:

1. In a page, I'll run an Xpath query such as the following: 
//a[contains(., 'http')]
2. This may then return more than 1 match (NOTE: I cannot pre-determine how 
many matches there will be in that page as it changes over time, hence Xpath 
Should Match X Times is not used)
3. I use Get Matching Xpath Count to determine how many matches are actually 
there
4. From the number of matches, I'd like to be able to get the values of each 
match and transfer them to a list (i.e. @{URLs})

Is there a way that I can retrieve all the values that matched the Xpath query 
and use them for succeeding loops or steps?

Another thing I'm thinking is, after I get the Xpath count, can I run a loop 
that will iterate through an Xpath wherein the only thing that changes is one 
variable?

Example is the following:
id('affAdFlightDetailsAdList')/x:tbody/x:tr[1]/x:td/x:div[3]/x:ul/x:li[1]/x:a

That Xpath was just taken from Firefox, but basically, the table row (tr) value 
is the only thing that is needed to be changed to get the next match (i.e. 
change tr[1] to tr[2] while retaining the rest of the Xpath query will yield 
the next match of the query I used in step #1 above.

I was unable to find a documentation that indicates if I can use something 
similar to the following:
id('affAdFlightDetailsAdList')/x:tbody/x:tr[${index}]/x:td/x:div[3]/x:ul/x:li[1]
/x:a

Which would loop through the data until there's no more matches found. Will 
placing a variable within a locator work?

Would greatly appreciate your thoughts. Thank you in advance!

Original issue reported on code.google.com by robertvi...@gmail.com on 15 Aug 2011 at 6:17

GoogleCodeExporter commented 9 years ago
This issue tracker is for bug reports and enhancement requests. Could you 
please send these questions to robotframework-users mailing list? There are 
more people that can help you and also others that can learn from the 
discussion.

Original comment by pekka.klarck on 15 Aug 2011 at 10:05

GoogleCodeExporter commented 9 years ago
Thanks for pointing it out. Have reposted in the mailing list as advised.

Cheers.

Original comment by robertvi...@gmail.com on 16 Aug 2011 at 12:31