as you may know there are a view applications out there which use very dynamic locators. With the one-locator-approach it is impossible to determine the right locator. In this case a multi-locator-approach would be needed. Tools like Testim or Functionize already use this opportunity driven by AI. Does anybody know if there are any intentions to implement this functionalities in a library used by Robot Framework?
If I understand your question correctly several Libraries already have this capability, but it’s library specific, so which library are you trying to use?
Hopefully someone can then point you in the right direction.
Hi @damies13 ,
with the existing libraries (primarily PlayWright) I couldn’t find this functionality. Maybe I’ve just overseen it. Let me give you an example.
When I want to click a button or fill out a text field I just can pass one locator to the keyword. As we know there are more than one opportunity to reach out for this locator higher in the DOM tree. In this case I would like to be able to pass a variable to the keyword that contains multiple locators to work with. Unfortunately I can’t see this with the existing libraries. Maybe you have more information in this case and could give me some tips.
You can do this with an xpath selector, say this was your html:
<table> <tr> <input id="Feild_1" type="text"> <input id="Del_1" type="button" value="Delete"> </tr> <tr> <input id="Feild_2" type="text"> <input id="Del_2" type="button" value="Delete"> </tr> <!-- a bunch more rows --> <tr> <input id="Feild_32" type="text"> <input id="Del_32" type="button" value="Delete"> </tr> <tr> <input id="Feild_33" type="text"> <input id="Del_33" type="button" value="Delete"> </tr> </table>
An xpath of
//tr/input[@value='Delete'] would match all the delete buttons, but if you want to click the 32nd button you can use an xpath like
This works with Browser Library and SeleniumLibrary and probably AppiumLibrary as well
Hopefully I understood what you were wanting to do,
If you are ok with using XPath or CSS selectors, both those supports multi-valued locators. It’s part of the query language and not the test tool. So I’m assuming good test tools that support those query methods will implement the full query language support for it.
CSS: locator1, locator2, locator3
XPath: locator1 | locator2 | locator3
You simply delimit locators by pipe “|” for XPath and by comma for CSS. But I know for sure combine with other features of XPath query language, it is much more help in your particular case than CSS, but CSS is usable for simple locators even if you have multiple to find.
So with the delimitation, the search by location will attempt to match any one in the list.
Also technically, using XPath (and sometimes CSS selectors), you can often use one locator to find the exact element you want even if it is complicated or gets moved around in the DOM a bit. It really is up to your skill in defining good XPath. It can even be parameterized to support selecting different elements say by text or color when they are very similar. Sadly the XPath generator tools are not so smart to give you such good locators, they give you the type that break easily and too fixed on position, static text, etc. now that is where perhaps AI could come in to produce good XPath like a skilled XPath pro could, but I don’t know what the state of such AI tools is like at the moment, I stopped doing QA/XPath for quite some time now.
Also don’t know if existing AI tools can generate mult-valued locators as I have presented to you, but that is certainly something they could and should aim for in future.
As far as I’m aware such AI based tools are not directly related to RF and more like Software As a Service automation tools that you have to subscribe and pay for, nothing in the OSS space or free self hosting.
thanks a lot for this information and it helped me a lot!