HTML code:
<div id='abcd12$selenium450'>
where the numeric value ie 12 or 450 are changing frequently but the string part remains constant. I have tries with contains(), but I am confused bcz the xpath should contain abcd as well as selenium. Can anyone help here?
CodePudding user response:
You should use starts-with
and contains
both.
//div[starts-with(@id, 'abcd') and contains(@id,'selenium')]
CodePudding user response:
You can achieve that in multiple ways.
starts-with
andcontains
CSS:
div[id^='abcd'][id*='selenium']
starts-with
CSS:
div[id^='abcd']
starts-with
andcontains
xPath:
//div[starts-with(@id, 'abcd') and contains(@id,'selenium')]
If element is something like this then you can use multiple contains
HTML:
<div id='12abcd$selenium450'>
contains
andcontains
xPath:
//div[contains(@id, 'abcd') and contains(@id,'selenium')]