The approach to use is to try and not include such elements in your selector.

Generall this means don’t hard code the entire selector (starting from body or some other elements) cos the page may change at some point. As you have discovered.

So in this case I would look to use the selector

 //*[@='text'][contains(@class,'form-control')][contains(@name,'projectsurvey')]

This is not guaranteed to work. For example you might have both a label and an /anchor field that would both be selected using this. You could get around this either using an index, e.g.

      //*[@type='text'][contains(@class,'form-control')][contains(@name,'projectsurvey')][0] 

or by adding an actual ID to the if you have access or ability to get the HTML itself changed, e.g.

      //*[@id='project_survey_name']

As you can see the above would be the desirable way.

For all these approaches I would also use css which is easier to read and maintain IMHO, e.g.

      *#project_survey_name



Source link https://sqa.stackexchange.com/questions/34639/-element-on---when-element-type-changes-e-g-input-to-a

LEAVE A REPLY

Please enter your comment!
Please enter your name here