Yeah, it is automatic only for action methods, which does not include text.
There's a case to be made to extend that behavior to text since it will
return an empty string if it isn't displayed, but for now you'll need to
keep the wait.



On Wed, Sep 12, 2018, 8:19 PM NaviHan <hishinessr...@gmail.com> wrote:

> Hi Titus
>
> Thanks for the detailed explanation and the documentation link.
> Unfortunately my confusion doesnt get clarified.
>
> As you said for an element which eventually displays, for example a pop up
> that appears due to a user action, we can read the text by
>
> *scenario 1*
> "my_element.when_present.text" because when_present get info from element
> that eventually *displays*
>
> The above changed to my_element.text, post Watir6.0 as the wait was made
> automatic
>
> *scenario 2*
> "my_element.wait_until(&:present?).text" also waits for the element to be
> displayed like "my_element.when_present.text"
> So they are one and the same.
>
> Because they are one and the same and post Watir6.0 the when_present wait
> was made automatic we can achieve the above objective with "my_element.text"
>
> So there will never be a case where we have to use wait_until(&:present?).
>
> This is my theory.
> Is that correct?
>
> Cheers
> Navi
>
>
> 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.
>

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