jquery_wait = lambda { |br| br.wait_until { |b| b.execute_script('return
jQuery.active == 0') } } browser.after_hooks.add(jquery_wait)
On Tuesday, August 7, 2018 at 9:17:32 AM UTC-7, [email protected]
wrote:
>
> Hi Justin,
>
> We are also using this wait_for_ajax in one of our Project. You said
>
> I would suggest adding the jQuery.active check to your browser's
>> after_hooks. Ideally this would catch all (or at least most) of the
>> problems.
>>
>
> May I know how to do this?
>
> On Tuesday, August 7, 2018 at 9:37:42 PM UTC+5:30, Justin Ko wrote:
>>
>> The #wait_for_ajax simplifies things if you need to manually call it.
>> However, it sounds like you would have to sprinkle this everywhere.
>>
>>
>
>>
>> Note that there would be a small performance hit of making this check
>> after each click/goto. However, if it's an AJAX heavy application, it's
>> probably worth it.
>>
>> Justin
>>
>>
>> On Tuesday, August 7, 2018 at 11:36:54 AM UTC-4, Titus Fortner wrote:
>>>
>>> Found it
>>>
>>> See the section on Waiting for AJAX Calls here:
>>> http://cheezyworld.com/2012/02/23/page-object-0-6-2-released/
>>> let's you call `wait_for_ajax` where you want it.
>>>
>>>
>>> On Tue, Aug 7, 2018 at 7:43 AM NaviHan <[email protected]> wrote:
>>> >
>>> > Yes Justin, That was exactly what happened. I ran the script a few
>>> times and using "Watir::Wait.until(timeout: 30)
>>> {@browser.execute_script('return jQuery.active == 0')}" never gave me the
>>> error "
>>> >
>>> > Element <span class="swatchanchor-value">...</span> is not clickable
>>> at point (537, 362). Other element would receive the click: <div
>>> class="loader-bg"></div>"
>>> >
>>> >
>>> > The code is
>>> >
>>> > def select_online_size (size)
>>> > Watir::Wait.until(timeout: 30) {@browser.execute_script('return
>>> jQuery.active == 0')}
>>> > sizes_online_elements.find {|el| el.when_present.text.eql?
>>> size}.click
>>> > end
>>> >
>>> > I was expecting that the "when_present" method would not give any
>>> timing issue because this waits until the element is present. Somehow this
>>> evaulates to true at the same time the spinner which is loading while the
>>> Ajax is running receives the click.
>>> >
>>> >
>>> > Is there a PO way to resolve this , I mean without having to use the
>>> "jQuery" statement
>>> >
>>> >
>>> > Cheers
>>> >
>>> > Navi
>>> >
>>> > On Friday, 3 August 2018 15:12:45 UTC+10, NaviHan wrote:
>>> >>
>>> >> I have a functionality where I click an a link from an email a
>>> voucher gets added to the shopping cart and a pop up appears with a
>>> message. Im trying to assert the text in the popup
>>> >> I have defined the element as
>>> >>
>>> >> div(:cta_description, :css =>
>>> '.homepage-clicktoactiavte-description')
>>> >>
>>> >> Tried to use a mix of Watir and Pageobejct to read the text. The
>>> below code works 5 out of 10 times.
>>> >>
>>> >> @rewards_popup_txt = Watir::Wait.until{cta_description_element}.text
>>> >> @rewards_popup_txt = @rewards_popup_txt.gsub(/[^$,.A-Za-z0-9]/," ")
>>> >> return @rewards_popup_txt
>>> >>
>>> >>
>>> >> Tried using, which doesnt even set the @reward_popup_txt and shows
>>> error
>>> >>
>>> >>
>>> >> if (Watir::Wait.while {cta_description_element.visible?})
>>> >> @rewards_popup_txt = cta_description_element.text
>>> >> end
>>> >> @rewards_popup_txt = @rewards_popup_txt.gsub(/[^$,.A-Za-z0-9]/," ")
>>> >> return @rewards_popup_txt
>>> >>
>>> >> Error
>>> >> NoMethodError: undefined method `gsub' for nil:NilClass
>>> >> ./features/support/pages/Frontend/Cotton_On/Loyalty_Page.rb:22:in
>>> `rewards_popup_description'
>>> >>
>>> >> Any stable way to do the job?
>>> >
>>> > --
>>> > --
>>> > 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.
>>>
>>
--
--
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.