-1

while running the script, when the code finds the xpath is changed. Is there any way to update the xpath automatically during run time and proceed with the next steps without fail.

John
  • 1
  • 1
  • I think you'll need to provide a more detailed example. – Severin Nov 12 '18 at 10:36
  • It's totally unclear what exactly you want your script to do. Share your current code, exception log, current/desired output. Also add tag with your programming language – Andersson Nov 12 '18 at 10:37
  • Suppose, there are set of scripts which uses xpath of "login button" and if the xpath of the "login button" changes, then my script should not fail, instead it should pick up the current(Changed or new) xpath of login button and proceed with the execution without any human intervention – John Nov 12 '18 at 11:19
  • If your XPath returns nothing how your script should know which element to select? And what should it do in case there is no required element on page? Can you describe exact case with the code you're using? – Andersson Nov 12 '18 at 11:23
  • We are working on a use case, no existing code readly available. So the ask is "To capture the xpaths of all the webelements in a webpage and update the script(Code) if there is change noticed", Is there any way to do the same – John Nov 12 '18 at 11:27
  • I guess the answer is NO. You just might improve your selectors to make them less sensitive to DOM changes – Andersson Nov 12 '18 at 11:57
  • Is there any AI tool which would be helpful for this – John Nov 12 '18 at 12:04
  • Tool for what? Creating selectors? You'd better not use any tools at all - just create your own XPath/CSS selectors - that will be much more reliable – Andersson Nov 12 '18 at 12:42

1 Answers1

0

John, I think what you're asking is "how do I implement a crystal ball that foresees changes in HTML and auto-adapts to them".

The answer is - you don't, the best realistic way is to talk to developers to implement sensible IDs and classes on every important element and ask them to communicate changes before you run your tests, see them break and wonder what happened.

If your a dev yourself and you try to practice TDD, then:

1) implement a failing test with a dummy Xpath, see it fail

2) implement the UI

3) Update the Xpath in your test, run, see the test pass

Andrejs
  • 10,803
  • 4
  • 43
  • 48