I was wondering what are the common approaches for dealing with extremely long locators using robotframework and/or selenium?
I’m talking about locators that long:
<input id="all00$SPWebExample1$g_bcd023df_3ba6_4f8f_bef3_164383c266aa$ctl00$$HereComesAnotherText1$rblFoundIs" />
The obvious approach is to “hide” them in the resource files so they don’t pollute the test case files. Another approach I’ve seen is to create a static xml file containing a full structure of a tested website and parse the xml file (I can provide example if needed).
Are there any better ways to do this?
If the ids are being generated automatically, then it isn’t a good idea to store them in a long locator like that.
Instead of:
Use:
The XPath version is considerably shorter, and won’t be as easily breakable as storing the full ID.
If there are multiple input elements that contain the same text, then there are other ways to narrow down the result.