Hi Navi,

(This is just response to your first reply. I'll have a look at your other 
replies when I have more time.)

`add_to_bag_element.when_present.click` would be Page-Object code rather 
than Watir code. There are no warnings that would be thrown from it.

Switching to `add_to_bag` will increase the timeout from 5 to 30 seconds 
(assuming you haven't overridden the defaults):
- Page Object's `#when_present` only waits 5 seconds
- Watir's `#click` waits 30 seconds

You should only need to wait when inspecting the element (rather than 
taking a user action). For example, checking the element's text waits for 
the element to exist, but not for it to be present. Keep in mind that you 
would only need to wait if the thing you are inspecting would change based 
on being hidden or not. #text can matter since it only shows visible text 
nodes. Checking most attributes, ex #id, presumably wouldn't matter. In 
general, the hope of Watir 6.0 is that you would rarely need to add the 
waits.

Justin


On Tuesday, September 11, 2018 at 9:50:05 AM UTC-4, NaviHan wrote:
>
> Hi Justin
>
> Unfortunately thats not the truth. We started automation for our project 
> approximately an year back, and Im pretty sure the version since the start 
> is post 6.0.
> We are doing these kind of duplication out of ignorance.
>
> Coming to the question, does watir show any warnings if we use 
> "add_to_bag_element.when_present.click" instead of "add_to_bag"?
>
> And is the wait the default of 30 seconds?
>
> Can you give an example where we have to explicitly wait?
>
> Cheers
>
> On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>>
>> This is something that keeps me a bit sceptic when I write and read the 
>> automation code in my project.
>> This used PageObjects.
>>
>> I have seen extensive use of element referces, for example 
>>
>> button(:add_to_bag, :css => '#add-to-cart')
>> add_to_bag.element.when_present.click
>>
>>
>>
>> instead of 
>>
>> add_to_bag 
>>
>> which directly clicks the element
>>
>> I have also seen extensive use of referencing elements using 
>> <element>.when_present, <element>.wait_until_present etc
>>
>> Im confused where we should draw the line when deciding to reference the 
>> element and actually using it(as in directly calling "add_o_bag" in the 
>> above example to click the element.
>>
>> Any thoughts?
>>
>>
>>

-- 
-- 
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