Using wildcards in Selenium IDE

10,777

Solution 1

You can use starts-with() for this:

//li[starts-with(@id, 'message_')]/div[2]/div[2]/a/img

It's one of the examples mentioned in Locating Techniques in Selenium's docs for starts-with().

Solution 2

In Target field of the command in Selenium IDE where you can see message_123123 click on a dropdownlist and choose an option which is related to xpath:idRelative or if this one doesn't work then try another options which do not include that annoying message_123123 so this way you'll identify webpage element by it's location but not id. I solved my issue this way

Share:
10,777
Axos
Author by

Axos

Updated on June 14, 2022

Comments

  • Axos
    Axos about 2 years

    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!!