I’m somewhat new to automation, and am learning everything auto-didactically, so forgive me if my terminology is a bit off. I’ve searched hi and low for an answer to this question, and I can’t seem to find anything. I presume it’s my small vocabulary when it comes to this stuff… anyway…
I’m attempting to write a test that performs all the actions necessary to complete a tutorial by using the recorder. However, for one particular step, the element ID changes. For example, the ID I’m trying to click is this:
//li[@id='message_661119']/div[2]/div[2]/a/img
However, for each new user that is performing the tutorial “quest”, the number of the id changes.
Is there anyway to get Selenium to recognize, or use, wildcards? Example:
//li[@id='message_******']/div[2]/div[2]/a/img
Of course, the example above does not work.
Any advice would be immensely helpful. Thank you!!
You can use
starts-with()for this:It’s one of the examples mentioned in Locating Techniques in Selenium’s docs for
starts-with().