Me and my team sometimes experienced this issue when testing one Cucumber feature in:

  • different version of Android and iOS

  • different device with same OS version.

This really slowing us down because we need different XPath for different environment. Really time consuming to do this over and over again and really hard to maintain our element locator.

Our devs developed the app we're testing in React.

My question simply, why this thing happened and how we work around it? Is there any solution?

2 Answers 2


Yes, identify your element with an ID, class, name or other specific attribute.

XPath should only be used as a last resort, or if the selector is really complex and/or contains dynamic data. But even then you can usually figure out a more robust selector.


I have variable IDs for the application which Iam working on now, that means every time I run, ID changes. So I can neither use ID to identify my element nor i can use that to create xpath. Better option will be to use CSS selector to identify elements.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.