0

We have an application that built on Angular. Our Performance team using HP LoadRunner TruClient with XPATH. This is fast developing application, and new features keep being adding, requiring changes to the testing XPaths.

Since we know that Angular doesn't need of element ID and they have asked us to add XPATH specifically for the performance script.

The current team is using XPATH like below,

//*[@id="addressAddBtn"]

This approach is so fragile since we are using Angular with PrimeNG. And if there is any upgrade and change in the application. They are facing lot of XPATH change and Their scripts completely breaks.

What would be best approach for this scenario instead of XPath?

I have seen those link they have mentioned about XPATH with Selenium and not sure on the HP LoadRunner TruClient.

What is the difference between cssSelector & Xpath and which is better with respect to performance for cross browser testing?

Which is the best way to locate an element in selenium webdriver other than XPath?

halfer
  • 19,824
  • 17
  • 99
  • 186
Raja
  • 3,477
  • 12
  • 47
  • 89

2 Answers2

1

In TruClient using XPATH is the last fallback of all other identification methods. I think that what happened was that the engineers writing the script got a message saying that the object could not be identified. In that dialog there is a button that allows you to fall back to XPATH. Clicking that button will make the script work but as you described could be prone to other issues in the future, especially for frameworks such as Angular.

The recommended way to overcome this problem is to use Descriptors - https://admhelp.microfocus.com/tc/en/12.60-12.63/Content/TruClient/descriptors.htm

This method will allow the automatic engine to identify the correct object without relying on incorrect properties such as ID in your case.

There are other methods to locate the object prior to using XPATH but I will not elaborate on them here.

The TruClient team would be more than happy to take a look at your website and check why the automatic identification didn't work and the XPATH fallback was suggested. If this is something relevant for you please contact us via the "Send us your feedback" button in VuGen help menu.

Buzzy
  • 2,905
  • 3
  • 22
  • 31
0

Finding element using xpath is the least priority as given on seleniumhq and protractor api documentation. The documentation sites gives priority to id, name, css and tag name first then xpath.

Finding element using xpath is sometime complex for the webdriver or protractor api thats why using direct locators like id, css, name or tag name is encouraged.

For detailed information visit the below given link

https://www.protractortest.org/#/locators

Zohair
  • 268
  • 2
  • 7