The Watir API is designed such that you shouldn't ever need to use CSS (or 
XPath). Especially with the latest versions where there is no performance 
penalty to nesting elements. Presumably a Hash of attribute or class 
key/value pairs is easier to read and parse than CSS selector annotation.

Another thing to consider if you have access to the underlying markup, is 
to use a unique custom attribute (I recommend `data-test`) for everything 
you want to interact with on a page for a test. ID is becoming less common 
because of single page applications, and class values are there for 
formatting the site, not for providing unique locators for elements for 
your tests.





On Sunday, March 24, 2019 at 1:15:53 AM UTC-5, NaviHan wrote:
>
> I have seen in my project using css to identify elements using PageObject.
> I always use attributes like id, class and name to identify elements.
>
> Which is the better way and why?
>

-- 
-- 
Before posting, please read 
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
 
In short: search before you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to