On the web page there are many elements with the same span class name. And I'm able to get the value of the first element with keyword "Get Text class: ...".
But I just can not figure it out how to iterate and get the values of all those same span class names. Any ideas?
I know how to iterate e.g. a text file with Python, but I'm not yet familiar enough with Selenium and RFW.
You can get all web elements with same class using the Get WebElements keyword, and then you can iterate them with a for loop. Note that I am using the RF 3.1 new for syntax. You can access the text attribute using the extended variable syntax.
${elements}= Get WebElements //span[@class='myclass']
FOR ${element} IN @{elements}
Log ${element.text}
END
Other option is to use the Get Text keyword inside the loop, you can pass the web element variable as a locator.
${elements}= Get WebElements //span[@class='myclass']
FOR ${element} IN @{elements}
${text}= Get Text ${element}
Log ${text}
END
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With