How to select Autogenerated web element

652 Views Asked by At

I have this xpath //*[@id="s2id_autogen8"]

After Refresh Xpath gets change. Can someone please advise how can I create customized XPath for this.

HTML Code:

<input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" class="select2-input select2-default" id="s2id_autogen38" style="width: 220px;">
2

There are 2 best solutions below

0
On BEST ANSWER

try this if id is changing and if class is not changing and also if you want to go with xpath only

//input[contains(@class,'select2-input')]
0
On

Change your xpath to -

//*[contains(@id,'s2id_autogen')]