1

I need to access this element:

<input id ="combo-1105-inputWrap">

The 4 digits in the xpath are autogenerated per browser session. I need to find that particular xpath and key in the data.

I have tried to use a regular expression in my xpath but I am not able to make this work.

//*[contains(id,'combo-1[0-9]{3}') and ends-with(id,'-inputWrap')]

How can I reliably access this element?

  • 1
    stackoverflow.com/questions/405060/… gives more detail on using regular expressions in Xpath. – Kate Paulk Nov 7 '17 at 12:35
  • Try using "//input[contains(@id,'combo-')]".It might work. – shanila Nov 7 '17 at 17:20
  • Problem with the "//input[contains(@id,'combo-')]" is that it matchs with all the UI elements present on the page contains the id combo-. But I need to identify only the particular Input box with the combination of "combo-1105-inputWrap" – chandrasekhar gandrakota Nov 8 '17 at 7:01
  • Can you add some more html so we can make it unique using parent elements – NarendraR Nov 8 '17 at 9:08
4

You can use some wild cards in cssSelecter to locate the same. Try below css Selector :

input[id^='combo-'][id$='-inputWrap']

For further clarification see this :-

input[id^='id_prefix_']

input[id$='_id_suffix']

input[id*='id_pattern']

You can find more information here.

  • 1
    I found this one more helpful in understanding the Regular Expressions – chandrasekhar gandrakota Jun 8 '18 at 8:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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