Soopa Stylin
Soopa Stylin

Reputation: 31

ChromeDriver -Element ID or Xpath changes

I have a quick question , I created some test cases using chrome driver on a Friday , today I returned and all test cases have failed ,when I checked I see that all the elements ID's or xpaths have changed , My question is why did this happen? I also need to know does this happen often?

Thank you

Upvotes: 1

Views: 375

Answers (3)

user6260412
user6260412

Reputation: 21

The Application you are working is dynamic. everytime you refresh a page or sends some data to server, the dynamic element changes it attribute values. I recommend you go with dynamic xpaths. you will find many learning sites to break the ice!!

Hope this helps!!

Upvotes: 1

Vijay Anand
Vijay Anand

Reputation: 44

Please Check your web pages which are used for testing, Element ID or Xpath changes mainly due to the frameworks which is used for the web page development. (i.e) like ExtJS based applications will basically generate dynamic ids. So if any components/elements are added to the web pages, it will automatically re-generate their ids.

Please refer to this SO post.

Upvotes: 2

cruisepandey
cruisepandey

Reputation: 29382

My question is why did this happen? -- Possibly reason in this scenarios could be :

  1. UI of Web Page has changed, so that your XPATHs are failing.
  2. Your XPATH may contains alphanumeric characters(or may be too long absolute path), which is not a good web locating strategy. You may want to switch to different locators for stability.

I also need to know does this happen often? -- It can happen at any point of time. (Lots of Web applications are changing their user Interface to give good user experience)

Upvotes: 1

Related Questions