Hi Titus Let me explain in deatils
We define the selector in the code as div(class: "here") Dynamic action changed the class to "not-here" in the DOM but but the the selector still remains the same in code .(div(class: "here")) Due to this reason element.wait_while(&:present?) ,will timeout as Watir just keeps verifying that the cached element is still there using the selector defined in code which is again (div(class: "here")) As a solution we use element.wait_while_present which looks up the element from scratch.. But the class of the element in DOM is still "not_here" and the selector in code is "here" So element.wait_while_present is never going to locate the element as the class has changed to "not-here" in DOM. But if in the DOM the class has changed back to "here" from "not-here" then wait_while_present will locate it. I hope you see where the confusion is. We never talks about the dynamic action which changes the class back to "here" 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. [email protected] http://groups.google.com/group/watir-general [email protected] --- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
