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-withandcontainsCSS:
div[id^='abcd'][id*='selenium']
starts-withCSS:
div[id^='abcd']
starts-withandcontainsxPath:
//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'>
containsandcontainsxPath:
//div[contains(@id, 'abcd') and contains(@id,'selenium')]
