0

im tring to create solution for dynamic page, where is table that can have 2 or more rows and in every row will be some element i need to interact with. I plan to use loop, but firs of all i need to store count of rows in that table, so cycle will know how many times repeat itself. Problem is that these rows dont have any common atributtes to catch on. That page uses tag <tr> in other part too so ${row_count} = get element count tag:tr will return much higher value that i need to get. Is there any way how to specify some section of page and count element only there?

1 Answer 1

0

Yes, that's done with the so called locators chaining in the SeleniumLibrary; you can read about it in the docs, the section "Chaining locators".

The syntax is something like:

${row_count} =    Get Element Count    xpath://div[@id="data-section"] >> tag:tr

, and this dummy example reads as "find an element of type tr that is a child of a div having id="data-section".
So in your case, make a locator that has only the tr-s you are are after, and chain the two.

The benefit about this chaining is that you can mix the locators strategies (the dummy example can be done solely in xpath with a single locator, but it's just to demonstrate), and can even mix a locator with a WebElement object.

Be sure to read on the correct syntax in that documentation, it's quite specific.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.