#wait_while_present will do a #reset! (remove the cache of the driver 
object) and attempt to locate the element from scratch with the selector 
`{class: "here"}`. If it finds it, then the wait loop will continue, if it 
does not find it, it will exit out of the waiting loop.

Incidentally, I think I've found a way to make that the default behavior 
for `wait_until(&:present?)` so I might be deprecating 
`#wait_while_present` and `#wait_until_present` entirely to minimize this 
confusion.




On Thursday, September 13, 2018 at 2:22:00 PM UTC-7, NaviHan wrote:
>
> Thanks a lot Titus and Rajagopalan.
>
> I want to wrap this up with one more question about wait_while_present. 
> Had this confusion while reading Titus's article on Watir waits (
> http://watir.com/guides/waiting/)
>
> you have this element, <div class="here">Foo</div> and you locate it with 
> code "element = browser.div(class: "here")"
>
> Some dynamic event caused the element class to change: "<div 
> class="not-here">Foo</div>"
>
> In this case we want the element to be looked up from scratch during the 
> polling, which is what this does:
>
> element.wait_while_present
>
> But my question is becasue the class of the element has changed to 
> "not-here" how the wait_while_present is going to work, basically the 
> identifier has changed?
>
> Or did you mean that the class has changed from "here" to "not-here" and 
> again it changed back to "here" ??
>
> 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.

Reply via email to