[wtr-general] Re: Which is better in PageObject model, using id, class, name to identify elements or using css to identify elements

2019-03-26 Thread NaviHan
Hi Justin Thanks for the detailed explanation. But cant we use collections here. Instead of declaring links as links(:product_names) { div(class: "price-and-quick-add-button-wrapper"). links(class: "name-link") } isnt links(:product_name, :class => 'name-link') better? And then use

[wtr-general] Re: Which is better in PageObject model, using id, class, name to identify elements or using css to identify elements

2019-03-26 Thread Justin Ko
Generally, no, there is no easier way to deal with nested elements. Though if you don't need to access :wishlist_remove_all, you could just do: span(:remove_all_link){ div(class: "wishlist-removal-all").span } I don't think Page-Object is making it any harder than pure Watir. Page-Object does

[wtr-general] Re: Which is better in PageObject model, using id, class, name to identify elements or using css to identify elements

2019-03-26 Thread Titus Fortner
The other reason to perhaps prefer css is that Page Object gem makes using nested elements harder. span(:remove_all_link, :css=> ".wishlist-remove-all span") I think would need to look like: element(:wishlist_remove_all, :class => "wishlist-remove-all") span(:remove_all_link){

[wtr-general] Re: Which is better in PageObject model, using id, class, name to identify elements or using css to identify elements

2019-03-26 Thread Justin Ko
In most cases, it is simply a matter of personal preference. There is usually no technical difference between between using CSS/XPath vs attributes. To me, the most important thing is to be consistent as an organization so that code is consistent, which makes the code easier to read/maintain.

[wtr-general] Re: Which is better in PageObject model, using id, class, name to identify elements or using css to identify elements

2019-03-26 Thread NaviHan
Hi Titus Today I saw a team member defining elements like this + a(:start_shopping_link, :css => "a.start-shopping")

[wtr-general] Re: Which is better in PageObject model, using id, class, name to identify elements or using css to identify elements

2019-03-24 Thread NaviHan
Thanks Titus. But what if someone ask, why cant I use the css or xpath. If you use them what is issue and how we avoid that with attributes like is, class or data-set? On Sunday, 24 March 2019 17:15:53 UTC+11, NaviHan wrote: > > I have seen in my project using css to identify elements using

[wtr-general] Re: Which is better in PageObject model, using id, class, name to identify elements or using css to identify elements

2019-03-24 Thread Titus Fortner
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.