Difference between attribute vs xpath as web locators

Hi,

I’ve seen that we can change the web locators we are using in Katalon studio. I would just like to clarify or anyone can give me or explain to me the difference between using attribute and xpath as web locators?

I assume you’re referring to this radio selection on Test Objects:

image

I believe this only affects web recording. According to the documentation:

Selection Method “XPath” was introduced in the version 5.7.0 as “Smart XPath Generator”:
https://docs.katalon.com/katalon-studio/new/version-570.html#smart-xpath-generator

A reading about “Smart XPath Generator” is here:

Quoting from the “Conclusion” section of this reading:

We showed several examples demonstrating that Selenium’s XPaths are fragile and hard to maintain. The common cause is Selenium’s reliance on an element’s index and ordering.
This article described Katalon Studio’s advanced and intelligent method to automatically generate locators or neighbor XPaths in automation test scripts. The XPaths are more resilient to changes in the AUT and more maintainable than those generated by Selenium. This advanced method is available in version 5.7 of Katalon Studio.

The author argues that

  • the Selection Mode “Attribute” is fragile and hard to maintian
  • the Selection Mode “XPath” is more resilient to changes in the AUT.
1 Like