Is the use of Attributes not good enough?

I’ve seen topics talking about “xpath is better than css” or “css is better than xpath”.
I’m just wondering if in Katalon Studio, the use of Attributes instead of xpath and/or css is good enough for object recognition?


@gilbert.escobar It depends upon the scenario, sometimes xpath is better sometimes css. It should fulfill your requirement of correct object recognition

No one thing is better than the other.

I prefer CSS. I’m very familiar with it. The web runs on it (along with HTML and JS).

Attributes, generally speaking, are not so good at guaranteeing uniqueness unless the id attribute is present – the HTML standards insist an id is unique throughout the document.

Thanks for the info, Russ.
In UFT, I use Properties or Attributes a lot and with so many options available to make the object unique such as index, object to the left/right above/below, etc. it works well. In Ranorex, the use of Ranorexpath works very well.
Very few occasions where xpath had to be used in UFT. But I’ve seen some xpaths for dynamic objects also keeps changing from a Third-Party app.
Does this happen in the use of CSS too?

Yes. As to the relative frequencies, I have nothing to compare (again, I use CSS, never XPath).

One thing is for sure, for all locators, if the AUT is new and/or in a state of flux, you should expect to find some locators need tweaking.

To alleviate the issue, you can try to write better locators that do as little structural parsing as possible. If your locator needs to traverse a lengthy path to get to the target element, it is more likely to need a tweak (or six) over time. I sense (but I don’t know) that XPaths (certainly those generated by tools) tend to suffer more from this. But again, I’m not the expert for XPath.

Aside: Using attributes is fine. Under the hood, the attributes system is probably using sizzle or a descendant of it (the part of CSS that does the traversal/query-lookups). So don’t let me turn you away from what you prefer.

Good luck.

We have our custom attribute for all objects what we need.
I think it maybe is good, though we have not done this idea yet.