I'm not sure what needs to happen after the click since that's where it is 
failing. But this code can't hurt because if there is no spinner it will 
move on to the next thing right away


On Tuesday, November 6, 2018 at 12:27:08 PM UTC-6, rajagopalan madasami 
wrote:
>
> Hi Titus,
>
> Can you please let me know whether my code is okay now?
>
>
> def waitAndClickButton(locator, action, name, data)
>   puts "ClickButton   : #{name}"
>   sleep 2
>   loc = getLocator(locator)
>   @b.div(id: "spinnerOverlay").wait_while(&:present?)
>   @b.button(loc.first => loc.last).click
>   @b.div(id: "spinnerOverlay").wait_while(&:present?)
> end
>
>
> On Tue, 6 Nov 2018 at 23:46, Titus Fortner <titusf...@gmail.com 
> <javascript:>> wrote:
>
>> I posted it above:
>> @b.alert.ok 
>> @b.div(id: "spinnerOverlay").wait_while(&:present?) 
>> @b.button(id: "NavContinue").click 
>>
>> But we can make this better in the Watir code which is why I asked if you 
>> could also raise the issue on Github.
>>
>>
>>
>> On Tuesday, November 6, 2018 at 12:12:32 PM UTC-6, rajagopalan madasami 
>> wrote:
>>>
>>> Okay. Can you please tell me what order should I need to write the code? 
>>>
>>> And I have a question, If element goes stale then WATIR automatically 
>>> regains the element , right ? It regain in many places which I see.
>>>
>>> On Tue 6 Nov, 2018, 11:39 PM Titus Fortner <titusf...@gmail.com wrote:
>>>
>>>> It's failing because it goes stale. It goes stale because there is a 
>>>> refresh on the page, the refresh on the page happens after the spinner 
>>>> that 
>>>> the alert kicks off. The problem is that the element is located before the 
>>>> spinner, and for it to work right now, you have to wait until after the 
>>>> spinner to locate the element. However you organize it in the code, it 
>>>> needs to be in that order not the order you have.
>>>>
>>>>
>>>>
>>>> On Tuesday, November 6, 2018 at 11:37:01 AM UTC-6, rajagopalan madasami 
>>>> wrote:
>>>>>
>>>>> I am calling this function 
>>>>>
>>>>> def waitForPageLoad
>>>>>
>>>>>   @b.wait_until(timeout: @Page_Load) {@b.execute_script("return 
>>>>> (jQuery.active === 0)").eql? true}
>>>>> end
>>>>>
>>>>> function in every click function like
>>>>>
>>>>> def clickButton(locator, action, name, data)
>>>>>   puts "ClickButton   : #{name}"
>>>>>   loc = getLocator(locator)
>>>>>   @b.button(loc.first => loc.last).click
>>>>>   waitForPageLoad
>>>>> end
>>>>>
>>>>> Do you see the clickButton method 
>>>>>
>>>>> calls waitForPageLoad at the end so it waits for the spinner disappear. 
>>>>> So it doesn't click on the spinner. Even if it clicks at the 
>>>>>
>>>>> spinner it retry it because I have included 
>>>>> Selenium::WebDriver::Error::ElementClickInterceptedError
>>>>>
>>>>> rescue Selenium::WebDriver::Error::ElementNotVisibleError, 
>>>>> Selenium::WebDriver::Error::ElementNotInteractableError,Selenium::WebDriver::Error::ElementClickInterceptedError
>>>>>   raise_present unless Wait.timer.remaining_time.positive?
>>>>>   raise_present unless %i[wait_for_present wait_for_enabled 
>>>>> wait_for_writable].include?(precondition)
>>>>>   retry
>>>>>
>>>>> So all I am seeing here is, It perfectlys lands on a page, and it 
>>>>> successfully enters into the click method but it waits for 30 seconds and 
>>>>> it fails. 
>>>>>
>>>>>   
>>>>>
>>>>>
>>>>> On Tue, 6 Nov 2018 at 22:51, Titus Fortner <titusf...@gmail.com> 
>>>>> wrote:
>>>>>
>>>>>> Yes, this makes sense from the code perspective.
>>>>>>
>>>>>> What your site is doing is requiring you to accept an alert, then it
>>>>>> does some kind of processing, then it refreshes some/all of the page.
>>>>>>
>>>>>> Your code is trying to click the element before the refresh has
>>>>>> happened, and because of the way you are rescuing it, it is giving you
>>>>>> misleading information. The element was located but couldn't be used,
>>>>>> then at the point it is trying to be used it is stale, and that method
>>>>>> isn't relocating when stale.
>>>>>>
>>>>>> Can you raise an issue on Github with this gist? Something like "Watir
>>>>>> should relocate stale elements when trying to click them"
>>>>>>
>>>>>> In the meantime, something like this should work:
>>>>>>
>>>>>> @b.alert.ok
>>>>>> @b.div(id: "spinnerOverlay").wait_while(&:present?)
>>>>>> @b.button(id: "NavContinue").click
>>>>>>
>>>>>>
>>>>>> On Tue, Nov 6, 2018 at 10:56 AM <rajagopal...@gmail.com> wrote:
>>>>>> >
>>>>>> > Hi Titus,
>>>>>> >
>>>>>> > Here is the gist url
>>>>>> >
>>>>>> > 
>>>>>> https://gist.github.com/Rajagopalan-M/ba78aed6342c61d07968cfe195d3f4de
>>>>>> >
>>>>>> > --
>>>>>> > --
>>>>>> > 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-...@googlegroups.com
>>>>>> > http://groups.google.com/group/watir-general
>>>>>> > watir-genera...@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-genera...@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-...@googlegroups.com
>>>>>> http://groups.google.com/group/watir-general
>>>>>> watir-genera...@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-genera...@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-...@googlegroups.com
>>>> http://groups.google.com/group/watir-general
>>>> watir-genera...@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-genera...@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-...@googlegroups.com <javascript:>
>> http://groups.google.com/group/watir-general
>> watir-genera...@googlegroups.com <javascript:>
>> --- 
>> 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-genera...@googlegroups.com <javascript:>.
>> 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