Skip to main content

Optimizing Object Identification and Tools in Katalon Studio

Note:
  • If your test execution encounters errors related to your Test Object cannot be found due to some specific reasons, you can refer to troubleshooting guide first before trying to optimize your Test Object properties: Element not visible exception.
  1. Always try to use fixed ID attribute if available. Try to communicate with development team to put the Id on each web element at front-end development side. In case the ID is dynamic (changed in every page load), should try to use other properties and below tips.
  2. Depending on your system under test, try to use attributes that rarely changes when SUT makes changes, for example: name, ID, text, etc.
  3. Do not use attributes that can be changed when running on other environments such as HWDN, dynamic ID, properties depending on screen resolution (width, height, x, y), etc.
  4. If ID attribute is not available, we can use other attributes which identifies uniquely the object. Plus, use the combination of attributes to make the XPath more specific. For example, "//input[@name ='qty' and @type='text']". These attributes should have the meaning for end-users, such as name, title, text, etc.
  5. Make sure that we do not overuse multiple attributes. When capturing objects, first focus on one attribute only. Depend on each situation, we can add more later.
  6. Use the Relative XPath instead of Absolute XPath statements.
  7. Always avoid using indexes in XPath to identify an object in capturing and static defining objects. It is not reliable and with smallest modification, XPath might break.
  8. Use XPath functions in XPath wherever necessary to better identification such as position(); last(); starts-with(); contains().
  9. In case there are two objects with the same property value in a specific web page, try to identify a nearby object with unique identification and then locate to intended object.
  10. There are still debates in using CSS or XPath. People in favor of CSS say that it is more readable and faster. However those in favor of XPath claim that it's ability to transverse the page while CSS cannot. Most of these debates always are outdated. You should define your own strategy to determine the best approach for you and your team. In practical experience from our internal QA experts and some from outside, CSS tends to be better than XPath. CSS is more readable, brief, concise and behaves same in all browsers, especially dealing with IE browser. XPath will behave differently in IE browser. However, using CSS, when you defining an object, it's hard to identify its parents.
  11. Tools to identify objects on web applications:
    • Firebug and FirePath: add-ons of Firefox browser. Please be noticed that the only difference from Automation tester point of view is FireBug returns Absolute XPath and FirePath returns Relative XPath.
    • Developer tool of Chrome browser.
    • XPath Helper, XPath Checker: adds-on of Chrome browser.
    • WebDriver Element Locator: an add-on of Firefox browser.
Was this page helpful?