-1

I've developed an automation framework that is used to test an application built with Dojo. The difficulty I'm experiencing is the way that Dojo dynamically generates IDs. Therefore, the IDs are as volatile as XPaths. Changing, adding, or removing an element on a page can result in the ID of the elements changing as well. This causes the automation to break. I'm sure that without checking each element on each page and doing some coding that is out of my expertise, there is probably no 100% solution. However, I'm here to ask for more experienced programmers to give your suggestions on what the best way to grab elements for testing would be in this situation (the solution that will break the least). Right now I am grabbing them by ID.

  • Have you try use css selector to locator element? Please show some HTML code – yong Jan 25 '18 at 15:23
  • 1
    Please read [ask], especially the part about [mcve] (MCVE), and [How much research effort is expected?](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users) This will help you debug your own programs and solve problems for yourself. If you do this and are still stuck you can come back and post your MCVE, what you tried, and the execution result including any error messages so we can better help you. Also provide a link to the page and/or the relevant HTML. – JeffC Jan 25 '18 at 15:57
  • 1
    Please provide a couple HTML samples. Grab a relevant section of HTML that contains element(s) that you are interested in then refresh the page and provide the same section of HTML. That way we can see what changes and what doesn't... we can provide a less brittle answer that way. – JeffC Jan 25 '18 at 16:01

1 Answers1

-1

The best way to locate the elements is going to be some absolute xpath combined with relative xpaths. So basically, what you are going to want to do is, containers on the page which do not change, are going to recieve an absolute xpath. Then elements which are going to appear and disappear, are going to recieve relative xpaths.

Could you provide HTML? I can then give you some examples.

Anand
  • 1,461
  • 1
  • 10
  • 21
  • 1
    Absolute XPaths are rarely, if ever, a good idea. They are very brittle. A handcrafted CSS selector or XPath would be better. – JeffC Jan 25 '18 at 15:58
  • I agree. But a handcrafted XPath or CSS selector might not suffice. Ahw well, without the code we aren't going to be able to answer this question anyway. – Anand Jan 25 '18 at 15:59