Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-09 Thread rajagopalan madasami
Hi please add WATIR tag in stack overflow. People will be looking into that
always.

On Fri 10 Aug, 2018, 9:58 AM Navi,  wrote:

> Hi Titus
>
> I ran the script directly from Jenkins box. Its a Windows Server 2016
> edition.
> When the script runs I can see the popup appears and its stays for
> 10seconds(configured time) and then disappears. Then it fails complaining
> "Element no found".
>
> The local is Windows 7 machine..
> Very very strange...
>
>
> On Fri, Aug 10, 2018 at 1:28 PM, Titus Fortner 
> wrote:
>
>> So are you thinking the popup had already gone away on remote? Are you
>> sure it was ever opened in the first place? 10 seconds should be
>> plenty of time to get information off of something. Is there something
>> happening on the site or in the code that would keep you from getting
>> that information in that 10 seconds?
>> On Wed, Aug 8, 2018 at 8:23 PM NaviHan  wrote:
>> >
>> > Yes Titus. I took the screenshot as well.
>> > It shows the homepage of the site, without the popup.
>> > Basically the popup appears on the homepage for 10second(this is driven
>> by config) and after 10 seconds it disappears. This is where we are trying
>> to read the text of the popup.
>> >
>> > The screenshot show the homepage without the popup...
>> >
>> > 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.
>> >
>> > 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.
>>
>
> --
> --
> 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 

Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-09 Thread Navi
Hi Titus

I ran the script directly from Jenkins box. Its a Windows Server 2016
edition.
When the script runs I can see the popup appears and its stays for
10seconds(configured time) and then disappears. Then it fails complaining
"Element no found".

The local is Windows 7 machine..
Very very strange...


On Fri, Aug 10, 2018 at 1:28 PM, Titus Fortner 
wrote:

> So are you thinking the popup had already gone away on remote? Are you
> sure it was ever opened in the first place? 10 seconds should be
> plenty of time to get information off of something. Is there something
> happening on the site or in the code that would keep you from getting
> that information in that 10 seconds?
> On Wed, Aug 8, 2018 at 8:23 PM NaviHan  wrote:
> >
> > Yes Titus. I took the screenshot as well.
> > It shows the homepage of the site, without the popup.
> > Basically the popup appears on the homepage for 10second(this is driven
> by config) and after 10 seconds it disappears. This is where we are trying
> to read the text of the popup.
> >
> > The screenshot show the homepage without the popup...
> >
> > 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.
> >
> > 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.
>

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


Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-09 Thread Titus Fortner
So are you thinking the popup had already gone away on remote? Are you
sure it was ever opened in the first place? 10 seconds should be
plenty of time to get information off of something. Is there something
happening on the site or in the code that would keep you from getting
that information in that 10 seconds?
On Wed, Aug 8, 2018 at 8:23 PM NaviHan  wrote:
>
> Yes Titus. I took the screenshot as well.
> It shows the homepage of the site, without the popup.
> Basically the popup appears on the homepage for 10second(this is driven by 
> config) and after 10 seconds it disappears. This is where we are trying to 
> read the text of the popup.
>
> The screenshot show the homepage without the popup...
>
> 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.
>
> 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.


Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-08 Thread Titus Fortner
In general, what is going on remotely is that the page is taking
slightly longer to load relative to what you have locally, so the
Selenium command is trying to execute before the site is ready for it

Does this help to explain the difference between #wait_until and #wait_while?

browser.wait_until { true } # => returns immediately
browser.wait_until { false } # => will time out
browser.wait_while { true } # => will time out
browser.wait_while { false } # => returns immediately

> 2. On local this passes but on Jenkins box the text is being read as empty

Text will return as empty if the element exists, but it not yet visible.
Ideally waiting for text to not be "" should be automatic, but
implementing that with the current code we have is not trivial. :(

So in for now you need to explicitly wait for it to become present first:

cta_description_element.wait_until(&:present?).text.gsub(/[^$,.A-Za-z0-9]/," ")

Based on our conversation here, I just added code that will go into
the next version of Watir that will allow you to do this (which might
be easier to understand?):

cta_description_element.wait_while(text: "").text.gsub(/[^$,.A-Za-z0-9]/," ")





On Wed, Aug 8, 2018 at 4:54 AM NaviHan  wrote:
>
> ***Please ignore previous message. It was accidently sent before typing 
> completely"
>
> Hi Titus and Rajagopalan and Justin
>
> The hook is written by another automation engineer, so Im yet to understand 
> that fully.
> Considering Im new to automation Im going through the learning curve and you 
> guys are of immense help.
> Tomorrow I will be debugging the script in Jenkins box as to why reading the 
> text from the popup fails just to remind this topic was started for that and 
> in the midst we nailed the javascript issue. The confusion with wait_until 
> and wait_while still bothers me.
>
> Let me make it a bit more clearer to you.
>
> 1. The pop up appears and Im trying to assert two texts in that popup.
> 2. On local this passes but on Jenkins box the text is being read as empty
>
> So Im thinking in the line, wait while the pop up disappears during that time 
> read the texts in the pop up. I have this idea in mind but dont know how to 
> implement that.
> These are the methods..
>
> def rewards_popup_description
>   #return cta_description_element.when_present.text.gsub(/[^$,.A-Za-z0-9]/," 
> ")
>   return cta_description_element.when_present(timeout = 
> 10).text.gsub(/[^$,.A-Za-z0-9]/," ")
>
> end
>
>
> def rewards_popup_expiration
>   return cta_expiry_element.when_present(timeout = 
> 10).text.gsub(/[^$,.A-Za-z0-9]/," ")
> end
>
>
> Instead of this can I do something like, note :- in BOLD is PSEUDO CODE
>
> cta_description_element.wait_while do
>   cta_description_element.visible?   AND READ THE TEXT
> end
>
>
> cheers
>
> 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.
>
> 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 

Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-08 Thread rajagopalan madasami
Okay thank you.

On Wed, Aug 8, 2018 at 9:43 PM, Titus Fortner 
wrote:

> Let's keep questions in threads relevant to the thread being
> discussed. Alex (p0deje) does the Ruby work right now, with help from
> Thomas (twalpole), Lucas (lucast) and me.
>
> NaviHan, I'll have time to look at this later today.
> On Wed, Aug 8, 2018 at 9:03 AM rajagopalan madasami
>  wrote:
> >
> > Hi Titus,
> >
> > Can I know who is fixing and releasing this logs? Is it from our WATIR
> team?
> >
> > https://raw.githubusercontent.com/SeleniumHQ/selenium/master/rb/CHANGES
> >
> >
> > On Wed, Aug 8, 2018 at 5:24 PM, NaviHan  wrote:
> >>
> >> ***Please ignore previous message. It was accidently sent before typing
> completely"
> >>
> >> Hi Titus and Rajagopalan and Justin
> >>
> >> The hook is written by another automation engineer, so Im yet to
> understand that fully.
> >> Considering Im new to automation Im going through the learning curve
> and you guys are of immense help.
> >> Tomorrow I will be debugging the script in Jenkins box as to why
> reading the text from the popup fails just to remind this topic was started
> for that and in the midst we nailed the javascript issue. The confusion
> with wait_until and wait_while still bothers me.
> >>
> >> Let me make it a bit more clearer to you.
> >>
> >> 1. The pop up appears and Im trying to assert two texts in that popup.
> >> 2. On local this passes but on Jenkins box the text is being read as
> empty
> >>
> >> So Im thinking in the line, wait while the pop up disappears during
> that time read the texts in the pop up. I have this idea in mind but dont
> know how to implement that.
> >> These are the methods..
> >>
> >> def rewards_popup_description
> >>   #return 
> >> cta_description_element.when_present.text.gsub(/[^$,.A-Za-z0-9]/,"
> ")
> >>   return cta_description_element.when_present(timeout =
> 10).text.gsub(/[^$,.A-Za-z0-9]/," ")
> >>
> >> end
> >>
> >>
> >> def rewards_popup_expiration
> >>   return cta_expiry_element.when_present(timeout =
> 10).text.gsub(/[^$,.A-Za-z0-9]/," ")
> >> end
> >>
> >>
> >> Instead of this can I do something like, note :- in BOLD is PSEUDO CODE
> >>
> >> cta_description_element.wait_while do
> >>   cta_description_element.visible?   AND READ THE TEXT
> >> end
> >>
> >>
> >> cheers
> >>
> >> 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.
> >>
> >> 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.
>
> --
> --
> Before posting, please read https://github.com/watir/
> watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
> In short: search 

Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-08 Thread Titus Fortner
Let's keep questions in threads relevant to the thread being
discussed. Alex (p0deje) does the Ruby work right now, with help from
Thomas (twalpole), Lucas (lucast) and me.

NaviHan, I'll have time to look at this later today.
On Wed, Aug 8, 2018 at 9:03 AM rajagopalan madasami
 wrote:
>
> Hi Titus,
>
> Can I know who is fixing and releasing this logs? Is it from our WATIR team?
>
> https://raw.githubusercontent.com/SeleniumHQ/selenium/master/rb/CHANGES
>
>
> On Wed, Aug 8, 2018 at 5:24 PM, NaviHan  wrote:
>>
>> ***Please ignore previous message. It was accidently sent before typing 
>> completely"
>>
>> Hi Titus and Rajagopalan and Justin
>>
>> The hook is written by another automation engineer, so Im yet to understand 
>> that fully.
>> Considering Im new to automation Im going through the learning curve and you 
>> guys are of immense help.
>> Tomorrow I will be debugging the script in Jenkins box as to why reading the 
>> text from the popup fails just to remind this topic was started for that and 
>> in the midst we nailed the javascript issue. The confusion with wait_until 
>> and wait_while still bothers me.
>>
>> Let me make it a bit more clearer to you.
>>
>> 1. The pop up appears and Im trying to assert two texts in that popup.
>> 2. On local this passes but on Jenkins box the text is being read as empty
>>
>> So Im thinking in the line, wait while the pop up disappears during that 
>> time read the texts in the pop up. I have this idea in mind but dont know 
>> how to implement that.
>> These are the methods..
>>
>> def rewards_popup_description
>>   #return cta_description_element.when_present.text.gsub(/[^$,.A-Za-z0-9]/," 
>> ")
>>   return cta_description_element.when_present(timeout = 
>> 10).text.gsub(/[^$,.A-Za-z0-9]/," ")
>>
>> end
>>
>>
>> def rewards_popup_expiration
>>   return cta_expiry_element.when_present(timeout = 
>> 10).text.gsub(/[^$,.A-Za-z0-9]/," ")
>> end
>>
>>
>> Instead of this can I do something like, note :- in BOLD is PSEUDO CODE
>>
>> cta_description_element.wait_while do
>>   cta_description_element.visible?   AND READ THE TEXT
>> end
>>
>>
>> cheers
>>
>> 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.
>>
>> 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.

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

Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-08 Thread rajagopalan madasami
 Hi Titus,

Can I know who is fixing and releasing this logs? Is it from our WATIR
team?

https://raw.githubusercontent.com/SeleniumHQ/selenium/master/rb/CHANGES


On Wed, Aug 8, 2018 at 5:24 PM, NaviHan  wrote:

> ***Please ignore previous message. It was accidently sent before typing
> completely"
>
> Hi Titus and Rajagopalan and Justin
>
> The hook is written by another automation engineer, so Im yet to
> understand that fully.
> Considering Im new to automation Im going through the learning curve and
> you guys are of immense help.
> Tomorrow I will be debugging the script in Jenkins box as to why reading
> the text from the popup fails just to remind this topic was started for
> that and in the midst we nailed the javascript issue. The confusion with
> wait_until and wait_while still bothers me.
>
> Let me make it a bit more clearer to you.
>
> 1. The pop up appears and Im trying to assert two texts in that popup.
> 2. On local this passes but on Jenkins box the text is being read as empty
>
> So Im thinking in the line, wait while the pop up disappears during that
> time read the texts in the pop up. I have this idea in mind but dont know
> how to implement that.
> These are the methods..
>
> def rewards_popup_description
>   #return cta_description_element.when_present.text.gsub(/[^$,.A-Za-z0-9]/," 
> ")
>   return cta_description_element.when_present(timeout = 
> 10).text.gsub(/[^$,.A-Za-z0-9]/," ")
>
> end
>
>
> def rewards_popup_expiration
>   return cta_expiry_element.when_present(timeout = 
> 10).text.gsub(/[^$,.A-Za-z0-9]/," ")
> end
>
>
> Instead of this can I do something like, note :- in BOLD is PSEUDO CODE
>
> cta_description_element.wait_while do
>   cta_description_element.visible?   AND READ THE TEXT
> end
>
>
> cheers
>
> 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.
>
> 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.


Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-08 Thread rajagopalan madasami
Yeah, that would be good idea. Our waiting methodology is what we differ
tremendously from directly using Selenium. When they use this driver level
wait, that would hinder WATIR to do its job as expected.

On Wed 8 Aug, 2018, 12:14 PM Titus Fortner,  wrote:

> Oh wow, implicit_wait of 300 will likely cause issues even if you aren't
> using Watir. Definitely don't need it with Watir. I kind of want to change
> the Selenium code to expose the existing implicit wait value in the driver
> just so Watir can check for it and throw big warning flags saying not to
> set it. :)
>
>
> On Tuesday, August 7, 2018 at 10:51:04 PM UTC-7, rajagopalan madasami
> wrote:
>>
>> Hi you don't have to use implicit wait while you use WATIR , that's
>> needed if you use pure selenium binding. If you use implicit wait, then you
>> can't know the element status immediately. Don't use implicit wait, WATIR
>> has its own waiting strategy.
>>
>> On Wed 8 Aug, 2018, 11:16 AM NaviHan,  wrote:
>>
>>> Hi Titus and Justin
>>>
>>> "wait_for_ajax" did the job :-) I used it only at places where the
>>> spinner loading caused problem. Im curios where to put the code blok Titus
>>> provided in the hooks.rb file
>>> My hooks look like this.
>>>
>>> @Justin, Im curios to know why you asked if Im sure that the timing
>>> issue was resolved using the jQuery statement. Are these kind of issues
>>> caused by something else?
>>>
>>>
>>> require 'rubygems'
>>> require 'page-object'
>>> require 'watir'
>>> require 'page-object/page_factory'
>>> require 'log4r'
>>> require 'cucumber'
>>> require 'selenium-webdriver'
>>> require 'fig_newton'
>>>
>>>
>>>
>>>
>>> Before do|scenario|
>>>
>>>   case ENV["TEST_ENV"]
>>>
>>> when 'dev'
>>>   begin
>>> ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
>>> @browser = Watir::Browser.new :chrome
>>> @browser.window.maximize
>>> @browser.driver.manage.timeouts.implicit_wait = 300
>>> @browser.cookies.clear
>>> @browser.driver.manage.window.maximize
>>> PageObject.default_element_wait=(10)
>>> FigNewton.load( "#{ENV["TEST_ENV"]}" + ".yml")
>>> PageObject.javascript_framework = :jquery
>>>   end
>>> when 'dev04'
>>>   begin
>>> ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
>>> @browser = Watir::Browser.new :chrome
>>> @browser.window.maximize
>>> @browser.driver.manage.timeouts.implicit_wait = 300
>>> @browser.cookies.clear
>>> @browser.driver.manage.window.maximize
>>> PageObject.default_element_wait=(10)
>>> FigNewton.load( "#{ENV["TEST_ENV"]}" + ".yml")
>>> PageObject.javascript_framework = :jquery
>>>   end
>>> else
>>>   ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
>>>   @browser = Watir::Browser.new :chrome
>>>   @browser.window.maximize
>>>   @browser.driver.manage.timeouts.implicit_wait = 300
>>>   @browser.cookies.clear
>>>   @browser.driver.manage.window.maximize
>>>   PageObject.default_element_wait=(10)
>>>   FigNewton.load( "dev04.yml")
>>>   PageObject.javascript_framework = :jquery
>>>   end
>>>
>>> end #before scenario>> class="m_-3767466441214720462styled-by-p
>>>
>>> --
> --
> 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.


Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-08 Thread Titus Fortner
Oh wow, implicit_wait of 300 will likely cause issues even if you aren't 
using Watir. Definitely don't need it with Watir. I kind of want to change 
the Selenium code to expose the existing implicit wait value in the driver 
just so Watir can check for it and throw big warning flags saying not to 
set it. :)


On Tuesday, August 7, 2018 at 10:51:04 PM UTC-7, rajagopalan madasami wrote:
>
> Hi you don't have to use implicit wait while you use WATIR , that's needed 
> if you use pure selenium binding. If you use implicit wait, then you can't 
> know the element status immediately. Don't use implicit wait, WATIR has its 
> own waiting strategy.
>
> On Wed 8 Aug, 2018, 11:16 AM NaviHan, > 
> wrote:
>
>> Hi Titus and Justin
>>
>> "wait_for_ajax" did the job :-) I used it only at places where the 
>> spinner loading caused problem. Im curios where to put the code blok Titus 
>> provided in the hooks.rb file
>> My hooks look like this.
>>
>> @Justin, Im curios to know why you asked if Im sure that the timing issue 
>> was resolved using the jQuery statement. Are these kind of issues caused by 
>> something else?
>>
>>
>> require 'rubygems'
>> require 'page-object'
>> require 'watir'
>> require 'page-object/page_factory'
>> require 'log4r'
>> require 'cucumber'
>> require 'selenium-webdriver'
>> require 'fig_newton'
>>
>>
>>
>>
>> Before do|scenario|
>>
>>   case ENV["TEST_ENV"]
>>
>> when 'dev'
>>   begin
>> ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
>> @browser = Watir::Browser.new :chrome
>> @browser.window.maximize
>> @browser.driver.manage.timeouts.implicit_wait = 300
>> @browser.cookies.clear
>> @browser.driver.manage.window.maximize
>> PageObject.default_element_wait=(10)
>> FigNewton.load( "#{ENV["TEST_ENV"]}" + ".yml")
>> PageObject.javascript_framework = :jquery
>>   end
>> when 'dev04'
>>   begin
>> ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
>> @browser = Watir::Browser.new :chrome
>> @browser.window.maximize
>> @browser.driver.manage.timeouts.implicit_wait = 300
>> @browser.cookies.clear
>> @browser.driver.manage.window.maximize
>> PageObject.default_element_wait=(10)
>> FigNewton.load( "#{ENV["TEST_ENV"]}" + ".yml")
>> PageObject.javascript_framework = :jquery
>>   end
>> else
>>   ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
>>   @browser = Watir::Browser.new :chrome
>>   @browser.window.maximize
>>   @browser.driver.manage.timeouts.implicit_wait = 300
>>   @browser.cookies.clear
>>   @browser.driver.manage.window.maximize
>>   PageObject.default_element_wait=(10)
>>   FigNewton.load( "dev04.yml")
>>   PageObject.javascript_framework = :jquery
>>   end
>>
>> end #before scenario> class="m_-3767466441214720462styled-by-p
>>
>>

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


Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread rajagopalan madasami
Hi you don't have to use implicit wait while you use WATIR , that's needed
if you use pure selenium binding. If you use implicit wait, then you can't
know the element status immediately. Don't use implicit wait, WATIR has its
own waiting strategy.

On Wed 8 Aug, 2018, 11:16 AM NaviHan,  wrote:

> Hi Titus and Justin
>
> "wait_for_ajax" did the job :-) I used it only at places where the spinner
> loading caused problem. Im curios where to put the code blok Titus provided
> in the hooks.rb file
> My hooks look like this.
>
> @Justin, Im curios to know why you asked if Im sure that the timing issue
> was resolved using the jQuery statement. Are these kind of issues caused by
> something else?
>
>
> require 'rubygems'
> require 'page-object'
> require 'watir'
> require 'page-object/page_factory'
> require 'log4r'
> require 'cucumber'
> require 'selenium-webdriver'
> require 'fig_newton'
>
>
>
>
> Before do|scenario|
>
>   case ENV["TEST_ENV"]
>
> when 'dev'
>   begin
> ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
> @browser = Watir::Browser.new :chrome
> @browser.window.maximize
> @browser.driver.manage.timeouts.implicit_wait = 300
> @browser.cookies.clear
> @browser.driver.manage.window.maximize
> PageObject.default_element_wait=(10)
> FigNewton.load( "#{ENV["TEST_ENV"]}" + ".yml")
> PageObject.javascript_framework = :jquery
>   end
> when 'dev04'
>   begin
> ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
> @browser = Watir::Browser.new :chrome
> @browser.window.maximize
> @browser.driver.manage.timeouts.implicit_wait = 300
> @browser.cookies.clear
> @browser.driver.manage.window.maximize
> PageObject.default_element_wait=(10)
> FigNewton.load( "#{ENV["TEST_ENV"]}" + ".yml")
> PageObject.javascript_framework = :jquery
>   end
> else
>   ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
>   @browser = Watir::Browser.new :chrome
>   @browser.window.maximize
>   @browser.driver.manage.timeouts.implicit_wait = 300
>   @browser.cookies.clear
>   @browser.driver.manage.window.maximize
>   PageObject.default_element_wait=(10)
>   FigNewton.load( "dev04.yml")
>   PageObject.javascript_framework = :jquery
>   end
>
> end #before scenario
>
>
>
>
> # "after all"
> After do |scenario|
>   @browser.driver.quit
>  if (scenario.passed?)
>puts 'Scenario Passed !'
>  else
>puts 'Scenario Failed !'
>  end
> end
>
>
>
> AfterStep('@screen') do
>filename = DateTime.now.strftime("%d%b%Y%H%M%S")
>@browser.screenshot.save 
> ("C:/Users/lohit.kotian/Documents/Automation/screenshots-cucumber/#{filename}.png")
>#@browser.screenshot.save 
> ("C:/Jenkins/workspace/screenshots-cucumber/#{filename}.png")
> end
>
>
> Around('@multipletimes') do |scenario, block|
>   $counter = 0
>   $total_times_to_run = 6
>   while $counter < $total_times_to_run  do
>  block.call
>  puts("Total times scripts were repeated = #$counter" )
>  $counter +=1
>   end
> end
>
>
> After do |scenario|
>   take_screenshot(@browser, scenario)
> end
>
> # need to check this code for the full page screenshots as a part of the 
> enhancement
>
>   def take_screenshot(browser, scenario)
> time = Time.now.strftime("%Y-%m-%d_%H%M")
> if scenario.failed?
>   scenario_name = scenario.name.gsub(/[^\w\-]/, ' ')
>   screenshot_path =  "#{scenario_name}" + "_failure_" + time
>   @browser.screenshot.save("./screenshots/#{screenshot_path}.png")
> end
>
>   end
>
>
> I would require your help to clear my doubts about "wait while" and "wait
> until". I see this is something extensively used in out project but no one
> has a clear answer.A grep gave me this
> ./features/support/pages/Frontend/COG/Checkout_Page.rb:Watir::Wait.
> while {order_summ_content_element.visible?}
> ./features/support/pages/Frontend/COG/Paypal_Page.rb:Watir::Wait.while
> {paypal_logo_element.visible?}
> ./features/support/pages/Frontend/COG/Paypal_Page.rb:Watir::Wait.while
> {paypal_spinner_element.visible?}
> ./features/support/pages/Frontend/COG/Pdp_Page.rb:if Watir::Wait.while
> {olapped_sm_window_element.visible?}
> ./features/support/pages/Frontend/COG/Pdp_Page.rb:# Watir::Wait.while
> {stores_elements[9].visible?}
> ./features/support/pages/Frontend/COG/Pdp_Page.rb:Watir::Wait.while {
> stores_elements[9].visible?}
> ./features/support/pages/Frontend/COG/Thankyou_Page.rb:return Watir::
> Wait.while {@browser.text.include?('Did you enjoy your shopping
> experience today')}
>
>
> And Wait.until is used everywhere and the list is huge
> ./features/support/pages/Frontend/COG/Pdp_Page.rb:#
> Watir::Wait.until {check_stores_element}.click
> ./features/support/pages/Frontend/COG/Pdp_Page.rb:  #return
> Watir::Wait.until {el}.parent(:index => 1).attribute('class') if
> el.text.include? "#{size}"
>  

Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread rajagopalan madasami
I have already read this thread , thank you.

On Tue 7 Aug, 2018, 11:44 PM Titus Fortner,  wrote:

> The poc code for Watir::Executor has been sitting in the PRs for a year:
> https://github.com/watir/watir/pull/587
>
> I was going to wait until Watir 7 to release it, but I don't think there
> is anything backward-compatibility breaking in it, so I don't think I
> should technically need to wait for that.
>
>
>
>
> On Tue, Aug 7, 2018 at 10:58 AM rajagopalan madasami <
> rajagopalanmadas...@gmail.com> wrote:
>
>> I have created a framework where I specifically asked them to use click
>> and clickAndWait separately , click will simply performs the WATIR click,
>> clickAndWait will perform the WATIR click and call the function waitForLoad
>> as you have seen. So if such a hook is available that would be easy for me.
>>
>> On Tue 7 Aug, 2018, 11:24 PM Titus Fortner, 
>> wrote:
>>
>>> It's more than that when running remotely, though. Definitely use it if
>>> it makes sense regardless of local or remote, but if you've solved your
>>> issue by just wrapping the select method, that's targeted and "better." :)
>>>
>>>
>>>
>>> On Tuesday, August 7, 2018 at 10:41:36 AM UTC-7, Justin Ko wrote:

 I agree that adding it to the after hooks adds overhead. Though at
 0.015s per click, it's not the worst thing in the world.

 I worked on one application where almost every button/link click
 triggered a loading overlay. Creating a method for each button/link to add
 the wait would defeat the purpose of using the Page Object gem. As with
 anything, the "better way" really depends on the application you're 
 testing.

 Justin


 On Tuesday, August 7, 2018 at 1:00:37 PM UTC-4, rajagopal...@gmail.com
 wrote:
>
> Okay, I will be waiting for that then! There was a new project in my
> company for which I convinced them to use WATIR instead of Selenium where 
> I
> had to implement this waiting behavior! Okay excited to see this new
> feature to be added!   Thanks.
>
> On Tuesday, August 7, 2018 at 10:24:55 PM UTC+5:30, Titus Fortner
> wrote:
>>
>> you'll be able to specify the exact desired behaviours in a more
>> granular way
>>
>> On Tue, Aug 7, 2018, 9:53 AM  wrote:
>>
>>> Oh okay. But you said
>>>
>>> The Executor class when implemented will open up a lot more
 flexibility.
>>>
>>>
>>> So will it be lesser wire call after Executor class implemented? Can
>>> I add after that?
>>>
>>> On Tuesday, August 7, 2018 at 10:18:51 PM UTC+5:30, Titus Fortner
>>> wrote:

 No, your way is better if it is working for you. Adding it to the
 after hook will add a ton more unnecessary calls to your code.


 On Tue, Aug 7, 2018 at 9:38 AM  wrote:

> That will be interesting, I am using as shown below,
>
>>
>> def selectAndWait(locator, value)
>>   select locator, value
>>   waitForPageLoad
>> end
>>
>> def waitForPageLoad
>>   @b.wait_until(timeout: @Page_Load) {@b.execute_script("return 
>> (jQuery.active === 0)").eql? true}
>> end
>>
>>
>
> Let me try using this `after_hook`, a very interesting idea indeed.
> On Tuesday, August 7, 2018 at 9:59:47 PM UTC+5:30, Titus Fortner
> wrote:
>>
>> after any action that changes or is likely to change the dom, so
>> it can get heavy if overused. The Executor class when implemented 
>> will open
>> up a lot more flexibility.
>>
>>
>>
>>
>> On Tue, Aug 7, 2018, 9:27 AM  wrote:
>>
>>> Ah! that's pretty interesting, I was not knowing this. So you
>>> say Once I have written this code, this code will be executed after 
>>> every
>>> click I do?
>>>
>>> On Tuesday, August 7, 2018 at 9:54:17 PM UTC+5:30, Titus Fortner
>>> wrote:

 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,
 rajagopal...@gmail.com 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:
>>
>> 

Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread Titus Fortner
The poc code for Watir::Executor has been sitting in the PRs for a year:
https://github.com/watir/watir/pull/587

I was going to wait until Watir 7 to release it, but I don't think there is
anything backward-compatibility breaking in it, so I don't think I should
technically need to wait for that.




On Tue, Aug 7, 2018 at 10:58 AM rajagopalan madasami <
rajagopalanmadas...@gmail.com> wrote:

> I have created a framework where I specifically asked them to use click
> and clickAndWait separately , click will simply performs the WATIR click,
> clickAndWait will perform the WATIR click and call the function waitForLoad
> as you have seen. So if such a hook is available that would be easy for me.
>
> On Tue 7 Aug, 2018, 11:24 PM Titus Fortner, 
> wrote:
>
>> It's more than that when running remotely, though. Definitely use it if
>> it makes sense regardless of local or remote, but if you've solved your
>> issue by just wrapping the select method, that's targeted and "better." :)
>>
>>
>>
>> On Tuesday, August 7, 2018 at 10:41:36 AM UTC-7, Justin Ko wrote:
>>>
>>> I agree that adding it to the after hooks adds overhead. Though at
>>> 0.015s per click, it's not the worst thing in the world.
>>>
>>> I worked on one application where almost every button/link click
>>> triggered a loading overlay. Creating a method for each button/link to add
>>> the wait would defeat the purpose of using the Page Object gem. As with
>>> anything, the "better way" really depends on the application you're testing.
>>>
>>> Justin
>>>
>>>
>>> On Tuesday, August 7, 2018 at 1:00:37 PM UTC-4, rajagopal...@gmail.com
>>> wrote:

 Okay, I will be waiting for that then! There was a new project in my
 company for which I convinced them to use WATIR instead of Selenium where I
 had to implement this waiting behavior! Okay excited to see this new
 feature to be added!   Thanks.

 On Tuesday, August 7, 2018 at 10:24:55 PM UTC+5:30, Titus Fortner wrote:
>
> you'll be able to specify the exact desired behaviours in a more
> granular way
>
> On Tue, Aug 7, 2018, 9:53 AM  wrote:
>
>> Oh okay. But you said
>>
>> The Executor class when implemented will open up a lot more
>>> flexibility.
>>
>>
>> So will it be lesser wire call after Executor class implemented? Can
>> I add after that?
>>
>> On Tuesday, August 7, 2018 at 10:18:51 PM UTC+5:30, Titus Fortner
>> wrote:
>>>
>>> No, your way is better if it is working for you. Adding it to the
>>> after hook will add a ton more unnecessary calls to your code.
>>>
>>>
>>> On Tue, Aug 7, 2018 at 9:38 AM  wrote:
>>>
 That will be interesting, I am using as shown below,

>
> def selectAndWait(locator, value)
>   select locator, value
>   waitForPageLoad
> end
>
> def waitForPageLoad
>   @b.wait_until(timeout: @Page_Load) {@b.execute_script("return 
> (jQuery.active === 0)").eql? true}
> end
>
>

 Let me try using this `after_hook`, a very interesting idea indeed.
 On Tuesday, August 7, 2018 at 9:59:47 PM UTC+5:30, Titus Fortner
 wrote:
>
> after any action that changes or is likely to change the dom, so
> it can get heavy if overused. The Executor class when implemented 
> will open
> up a lot more flexibility.
>
>
>
>
> On Tue, Aug 7, 2018, 9:27 AM  wrote:
>
>> Ah! that's pretty interesting, I was not knowing this. So you say
>> Once I have written this code, this code will be executed after 
>> every click
>> I do?
>>
>> On Tuesday, August 7, 2018 at 9:54:17 PM UTC+5:30, Titus Fortner
>> wrote:
>>>
>>> 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,
>>> rajagopal...@gmail.com 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 

Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread rajagopalan madasami
I have created a framework where I specifically asked them to use click and
clickAndWait separately , click will simply performs the WATIR click,
clickAndWait will perform the WATIR click and call the function waitForLoad
as you have seen. So if such a hook is available that would be easy for me.

On Tue 7 Aug, 2018, 11:24 PM Titus Fortner,  wrote:

> It's more than that when running remotely, though. Definitely use it if it
> makes sense regardless of local or remote, but if you've solved your issue
> by just wrapping the select method, that's targeted and "better." :)
>
>
>
> On Tuesday, August 7, 2018 at 10:41:36 AM UTC-7, Justin Ko wrote:
>>
>> I agree that adding it to the after hooks adds overhead. Though at 0.015s
>> per click, it's not the worst thing in the world.
>>
>> I worked on one application where almost every button/link click
>> triggered a loading overlay. Creating a method for each button/link to add
>> the wait would defeat the purpose of using the Page Object gem. As with
>> anything, the "better way" really depends on the application you're testing.
>>
>> Justin
>>
>>
>> On Tuesday, August 7, 2018 at 1:00:37 PM UTC-4, rajagopal...@gmail.com
>> wrote:
>>>
>>> Okay, I will be waiting for that then! There was a new project in my
>>> company for which I convinced them to use WATIR instead of Selenium where I
>>> had to implement this waiting behavior! Okay excited to see this new
>>> feature to be added!   Thanks.
>>>
>>> On Tuesday, August 7, 2018 at 10:24:55 PM UTC+5:30, Titus Fortner wrote:

 you'll be able to specify the exact desired behaviours in a more
 granular way

 On Tue, Aug 7, 2018, 9:53 AM  wrote:

> Oh okay. But you said
>
> The Executor class when implemented will open up a lot more
>> flexibility.
>
>
> So will it be lesser wire call after Executor class implemented? Can I
> add after that?
>
> On Tuesday, August 7, 2018 at 10:18:51 PM UTC+5:30, Titus Fortner
> wrote:
>>
>> No, your way is better if it is working for you. Adding it to the
>> after hook will add a ton more unnecessary calls to your code.
>>
>>
>> On Tue, Aug 7, 2018 at 9:38 AM  wrote:
>>
>>> That will be interesting, I am using as shown below,
>>>

 def selectAndWait(locator, value)
   select locator, value
   waitForPageLoad
 end

 def waitForPageLoad
   @b.wait_until(timeout: @Page_Load) {@b.execute_script("return 
 (jQuery.active === 0)").eql? true}
 end


>>>
>>> Let me try using this `after_hook`, a very interesting idea indeed.
>>> On Tuesday, August 7, 2018 at 9:59:47 PM UTC+5:30, Titus Fortner
>>> wrote:

 after any action that changes or is likely to change the dom, so it
 can get heavy if overused. The Executor class when implemented will 
 open up
 a lot more flexibility.




 On Tue, Aug 7, 2018, 9:27 AM  wrote:

> Ah! that's pretty interesting, I was not knowing this. So you say
> Once I have written this code, this code will be executed after every 
> click
> I do?
>
> On Tuesday, August 7, 2018 at 9:54:17 PM UTC+5:30, Titus Fortner
> wrote:
>>
>> 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,
>> rajagopal...@gmail.com 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 

Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread Titus Fortner
It's more than that when running remotely, though. Definitely use it if it 
makes sense regardless of local or remote, but if you've solved your issue 
by just wrapping the select method, that's targeted and "better." :)



On Tuesday, August 7, 2018 at 10:41:36 AM UTC-7, Justin Ko wrote:
>
> I agree that adding it to the after hooks adds overhead. Though at 0.015s 
> per click, it's not the worst thing in the world. 
>
> I worked on one application where almost every button/link click triggered 
> a loading overlay. Creating a method for each button/link to add the wait 
> would defeat the purpose of using the Page Object gem. As with anything, 
> the "better way" really depends on the application you're testing.
>
> Justin
>
>
> On Tuesday, August 7, 2018 at 1:00:37 PM UTC-4, rajagopal...@gmail.com 
> wrote:
>>
>> Okay, I will be waiting for that then! There was a new project in my 
>> company for which I convinced them to use WATIR instead of Selenium where I 
>> had to implement this waiting behavior! Okay excited to see this new 
>> feature to be added!   Thanks.
>>
>> On Tuesday, August 7, 2018 at 10:24:55 PM UTC+5:30, Titus Fortner wrote:
>>>
>>> you'll be able to specify the exact desired behaviours in a more 
>>> granular way
>>>
>>> On Tue, Aug 7, 2018, 9:53 AM  wrote:
>>>
 Oh okay. But you said 

 The Executor class when implemented will open up a lot more flexibility.


 So will it be lesser wire call after Executor class implemented? Can I 
 add after that?  

 On Tuesday, August 7, 2018 at 10:18:51 PM UTC+5:30, Titus Fortner wrote:
>
> No, your way is better if it is working for you. Adding it to the 
> after hook will add a ton more unnecessary calls to your code.
>
>
> On Tue, Aug 7, 2018 at 9:38 AM  wrote:
>
>> That will be interesting, I am using as shown below, 
>>
>>>
>>> def selectAndWait(locator, value)
>>>   select locator, value
>>>   waitForPageLoad
>>> end
>>>
>>> def waitForPageLoad
>>>   @b.wait_until(timeout: @Page_Load) {@b.execute_script("return 
>>> (jQuery.active === 0)").eql? true}
>>> end
>>>
>>>
>>
>> Let me try using this `after_hook`, a very interesting idea indeed.
>> On Tuesday, August 7, 2018 at 9:59:47 PM UTC+5:30, Titus Fortner 
>> wrote:
>>>
>>> after any action that changes or is likely to change the dom, so it 
>>> can get heavy if overused. The Executor class when implemented will 
>>> open up 
>>> a lot more flexibility.
>>>
>>>
>>>
>>>
>>> On Tue, Aug 7, 2018, 9:27 AM  wrote:
>>>
 Ah! that's pretty interesting, I was not knowing this. So you say 
 Once I have written this code, this code will be executed after every 
 click 
 I do? 

 On Tuesday, August 7, 2018 at 9:54:17 PM UTC+5:30, Titus Fortner 
 wrote:
>
> 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, 
> rajagopal...@gmail.com 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  
 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 " 
 > 
 > 

Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread rajagopalan madasami
Ah that's very negligible! I believe I can add that in my current project.

On Tue 7 Aug, 2018, 11:11 PM Justin Ko,  wrote:

> I agree that adding it to the after hooks adds overhead. Though at 0.015s
> per click, it's not the worst thing in the world.
>
> I worked on one application where almost every button/link click triggered
> a loading overlay. Creating a method for each button/link to add the wait
> would defeat the purpose of using the Page Object gem. As with anything,
> the "better way" really depends on the application you're testing.
>
> Justin
>
>
> On Tuesday, August 7, 2018 at 1:00:37 PM UTC-4, rajagopal...@gmail.com
> wrote:
>>
>> Okay, I will be waiting for that then! There was a new project in my
>> company for which I convinced them to use WATIR instead of Selenium where I
>> had to implement this waiting behavior! Okay excited to see this new
>> feature to be added!   Thanks.
>>
>> On Tuesday, August 7, 2018 at 10:24:55 PM UTC+5:30, Titus Fortner wrote:
>>>
>>> you'll be able to specify the exact desired behaviours in a more
>>> granular way
>>>
>>> On Tue, Aug 7, 2018, 9:53 AM  wrote:
>>>
 Oh okay. But you said

 The Executor class when implemented will open up a lot more flexibility.


 So will it be lesser wire call after Executor class implemented? Can I
 add after that?

 On Tuesday, August 7, 2018 at 10:18:51 PM UTC+5:30, Titus Fortner wrote:
>
> No, your way is better if it is working for you. Adding it to the
> after hook will add a ton more unnecessary calls to your code.
>
>
> On Tue, Aug 7, 2018 at 9:38 AM  wrote:
>
>> That will be interesting, I am using as shown below,
>>
>>>
>>> def selectAndWait(locator, value)
>>>   select locator, value
>>>   waitForPageLoad
>>> end
>>>
>>> def waitForPageLoad
>>>   @b.wait_until(timeout: @Page_Load) {@b.execute_script("return 
>>> (jQuery.active === 0)").eql? true}
>>> end
>>>
>>>
>>
>> Let me try using this `after_hook`, a very interesting idea indeed.
>> On Tuesday, August 7, 2018 at 9:59:47 PM UTC+5:30, Titus Fortner
>> wrote:
>>>
>>> after any action that changes or is likely to change the dom, so it
>>> can get heavy if overused. The Executor class when implemented will 
>>> open up
>>> a lot more flexibility.
>>>
>>>
>>>
>>>
>>> On Tue, Aug 7, 2018, 9:27 AM  wrote:
>>>
 Ah! that's pretty interesting, I was not knowing this. So you say
 Once I have written this code, this code will be executed after every 
 click
 I do?

 On Tuesday, August 7, 2018 at 9:54:17 PM UTC+5:30, Titus Fortner
 wrote:
>
> 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,
> rajagopal...@gmail.com 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 
 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 ... is not
 clickable at point (537, 362). Other element would receive the 
 click: >>> class="loader-bg">"
 >
 >
 > The code is
 >

Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread Justin Ko
I agree that adding it to the after hooks adds overhead. Though at 0.015s 
per click, it's not the worst thing in the world. 

I worked on one application where almost every button/link click triggered 
a loading overlay. Creating a method for each button/link to add the wait 
would defeat the purpose of using the Page Object gem. As with anything, 
the "better way" really depends on the application you're testing.

Justin


On Tuesday, August 7, 2018 at 1:00:37 PM UTC-4, rajagopal...@gmail.com 
wrote:
>
> Okay, I will be waiting for that then! There was a new project in my 
> company for which I convinced them to use WATIR instead of Selenium where I 
> had to implement this waiting behavior! Okay excited to see this new 
> feature to be added!   Thanks.
>
> On Tuesday, August 7, 2018 at 10:24:55 PM UTC+5:30, Titus Fortner wrote:
>>
>> you'll be able to specify the exact desired behaviours in a more granular 
>> way
>>
>> On Tue, Aug 7, 2018, 9:53 AM  wrote:
>>
>>> Oh okay. But you said 
>>>
>>> The Executor class when implemented will open up a lot more flexibility.
>>>
>>>
>>> So will it be lesser wire call after Executor class implemented? Can I 
>>> add after that?  
>>>
>>> On Tuesday, August 7, 2018 at 10:18:51 PM UTC+5:30, Titus Fortner wrote:

 No, your way is better if it is working for you. Adding it to the after 
 hook will add a ton more unnecessary calls to your code.


 On Tue, Aug 7, 2018 at 9:38 AM  wrote:

> That will be interesting, I am using as shown below, 
>
>>
>> def selectAndWait(locator, value)
>>   select locator, value
>>   waitForPageLoad
>> end
>>
>> def waitForPageLoad
>>   @b.wait_until(timeout: @Page_Load) {@b.execute_script("return 
>> (jQuery.active === 0)").eql? true}
>> end
>>
>>
>
> Let me try using this `after_hook`, a very interesting idea indeed.
> On Tuesday, August 7, 2018 at 9:59:47 PM UTC+5:30, Titus Fortner wrote:
>>
>> after any action that changes or is likely to change the dom, so it 
>> can get heavy if overused. The Executor class when implemented will open 
>> up 
>> a lot more flexibility.
>>
>>
>>
>>
>> On Tue, Aug 7, 2018, 9:27 AM  wrote:
>>
>>> Ah! that's pretty interesting, I was not knowing this. So you say 
>>> Once I have written this code, this code will be executed after every 
>>> click 
>>> I do? 
>>>
>>> On Tuesday, August 7, 2018 at 9:54:17 PM UTC+5:30, Titus Fortner 
>>> wrote:

 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, 
 rajagopal...@gmail.com 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  
>>> 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 ... is not 
>>> clickable at point (537, 362). Other element would receive the 
>>> click: >> class="loader-bg">" 
>>> > 
>>> > 
>>> > 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? 

Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread rajagopalanmadasami
Okay, I will be waiting for that then! There was a new project in my 
company for which I convinced them to use WATIR instead of Selenium where I 
had to implement this waiting behavior! Okay excited to see this new 
feature to be added!   Thanks.

On Tuesday, August 7, 2018 at 10:24:55 PM UTC+5:30, Titus Fortner wrote:
>
> you'll be able to specify the exact desired behaviours in a more granular 
> way
>
> On Tue, Aug 7, 2018, 9:53 AM > wrote:
>
>> Oh okay. But you said 
>>
>> The Executor class when implemented will open up a lot more flexibility.
>>
>>
>> So will it be lesser wire call after Executor class implemented? Can I 
>> add after that?  
>>
>> On Tuesday, August 7, 2018 at 10:18:51 PM UTC+5:30, Titus Fortner wrote:
>>>
>>> No, your way is better if it is working for you. Adding it to the after 
>>> hook will add a ton more unnecessary calls to your code.
>>>
>>>
>>> On Tue, Aug 7, 2018 at 9:38 AM  wrote:
>>>
 That will be interesting, I am using as shown below, 

>
> def selectAndWait(locator, value)
>   select locator, value
>   waitForPageLoad
> end
>
> def waitForPageLoad
>   @b.wait_until(timeout: @Page_Load) {@b.execute_script("return 
> (jQuery.active === 0)").eql? true}
> end
>
>

 Let me try using this `after_hook`, a very interesting idea indeed.
 On Tuesday, August 7, 2018 at 9:59:47 PM UTC+5:30, Titus Fortner wrote:
>
> after any action that changes or is likely to change the dom, so it 
> can get heavy if overused. The Executor class when implemented will open 
> up 
> a lot more flexibility.
>
>
>
>
> On Tue, Aug 7, 2018, 9:27 AM  wrote:
>
>> Ah! that's pretty interesting, I was not knowing this. So you say 
>> Once I have written this code, this code will be executed after every 
>> click 
>> I do? 
>>
>> On Tuesday, August 7, 2018 at 9:54:17 PM UTC+5:30, Titus Fortner 
>> wrote:
>>>
>>> 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, 
>>> rajagopal...@gmail.com 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  
>> 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 ... is not 
>> clickable at point (537, 362). Other element would receive the 
>> click: > class="loader-bg">" 
>> > 
>> > 
>> > 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 

Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread Titus Fortner
you'll be able to specify the exact desired behaviours in a more granular
way

On Tue, Aug 7, 2018, 9:53 AM  wrote:

> Oh okay. But you said
>
> The Executor class when implemented will open up a lot more flexibility.
>
>
> So will it be lesser wire call after Executor class implemented? Can I add
> after that?
>
> On Tuesday, August 7, 2018 at 10:18:51 PM UTC+5:30, Titus Fortner wrote:
>>
>> No, your way is better if it is working for you. Adding it to the after
>> hook will add a ton more unnecessary calls to your code.
>>
>>
>> On Tue, Aug 7, 2018 at 9:38 AM  wrote:
>>
>>> That will be interesting, I am using as shown below,
>>>

 def selectAndWait(locator, value)
   select locator, value
   waitForPageLoad
 end

 def waitForPageLoad
   @b.wait_until(timeout: @Page_Load) {@b.execute_script("return 
 (jQuery.active === 0)").eql? true}
 end


>>>
>>> Let me try using this `after_hook`, a very interesting idea indeed.
>>> On Tuesday, August 7, 2018 at 9:59:47 PM UTC+5:30, Titus Fortner wrote:

 after any action that changes or is likely to change the dom, so it can
 get heavy if overused. The Executor class when implemented will open up a
 lot more flexibility.




 On Tue, Aug 7, 2018, 9:27 AM  wrote:

> Ah! that's pretty interesting, I was not knowing this. So you say Once
> I have written this code, this code will be executed after every click I
> do?
>
> On Tuesday, August 7, 2018 at 9:54:17 PM UTC+5:30, Titus Fortner wrote:
>>
>> 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,
>> rajagopal...@gmail.com 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 
> 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 ... is not
> clickable at point (537, 362). Other element would receive the click: 
>  class="loader-bg">"
> >
> >
> > 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.
> >>

Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread rajagopalanmadasami
Oh okay. But you said 

The Executor class when implemented will open up a lot more flexibility.


So will it be lesser wire call after Executor class implemented? Can I add 
after that?  

On Tuesday, August 7, 2018 at 10:18:51 PM UTC+5:30, Titus Fortner wrote:
>
> No, your way is better if it is working for you. Adding it to the after 
> hook will add a ton more unnecessary calls to your code.
>
>
> On Tue, Aug 7, 2018 at 9:38 AM > 
> wrote:
>
>> That will be interesting, I am using as shown below, 
>>
>>>
>>> def selectAndWait(locator, value)
>>>   select locator, value
>>>   waitForPageLoad
>>> end
>>>
>>> def waitForPageLoad
>>>   @b.wait_until(timeout: @Page_Load) {@b.execute_script("return 
>>> (jQuery.active === 0)").eql? true}
>>> end
>>>
>>>
>>
>> Let me try using this `after_hook`, a very interesting idea indeed.
>> On Tuesday, August 7, 2018 at 9:59:47 PM UTC+5:30, Titus Fortner wrote:
>>>
>>> after any action that changes or is likely to change the dom, so it can 
>>> get heavy if overused. The Executor class when implemented will open up a 
>>> lot more flexibility.
>>>
>>>
>>>
>>>
>>> On Tue, Aug 7, 2018, 9:27 AM  wrote:
>>>
 Ah! that's pretty interesting, I was not knowing this. So you say Once 
 I have written this code, this code will be executed after every click I 
 do? 

 On Tuesday, August 7, 2018 at 9:54:17 PM UTC+5:30, Titus Fortner wrote:
>
> 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, rajagopal...@gmail.com 
> 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  
 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 ... is not 
 clickable at point (537, 362). Other element would receive the click: 
 >>> class="loader-bg">" 
 > 
 > 
 > 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 

Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread Titus Fortner
No, your way is better if it is working for you. Adding it to the after
hook will add a ton more unnecessary calls to your code.


On Tue, Aug 7, 2018 at 9:38 AM  wrote:

> That will be interesting, I am using as shown below,
>
>>
>> def selectAndWait(locator, value)
>>   select locator, value
>>   waitForPageLoad
>> end
>>
>> def waitForPageLoad
>>   @b.wait_until(timeout: @Page_Load) {@b.execute_script("return 
>> (jQuery.active === 0)").eql? true}
>> end
>>
>>
>
> Let me try using this `after_hook`, a very interesting idea indeed.
> On Tuesday, August 7, 2018 at 9:59:47 PM UTC+5:30, Titus Fortner wrote:
>>
>> after any action that changes or is likely to change the dom, so it can
>> get heavy if overused. The Executor class when implemented will open up a
>> lot more flexibility.
>>
>>
>>
>>
>> On Tue, Aug 7, 2018, 9:27 AM  wrote:
>>
>>> Ah! that's pretty interesting, I was not knowing this. So you say Once I
>>> have written this code, this code will be executed after every click I do?
>>>
>>> On Tuesday, August 7, 2018 at 9:54:17 PM UTC+5:30, Titus Fortner wrote:

 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, rajagopal...@gmail.com
 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  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 ... is not
>>> clickable at point (537, 362). Other element would receive the click: 
>>> >> class="loader-bg">"
>>> >
>>> >
>>> > 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 

Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread rajagopalanmadasami
That will be interesting, I am using as shown below, 

>
> def selectAndWait(locator, value)
>   select locator, value
>   waitForPageLoad
> end
>
> def waitForPageLoad
>   @b.wait_until(timeout: @Page_Load) {@b.execute_script("return 
> (jQuery.active === 0)").eql? true}
> end
>
>

Let me try using this `after_hook`, a very interesting idea indeed.
On Tuesday, August 7, 2018 at 9:59:47 PM UTC+5:30, Titus Fortner wrote:
>
> after any action that changes or is likely to change the dom, so it can 
> get heavy if overused. The Executor class when implemented will open up a 
> lot more flexibility.
>
>
>
>
> On Tue, Aug 7, 2018, 9:27 AM > wrote:
>
>> Ah! that's pretty interesting, I was not knowing this. So you say Once I 
>> have written this code, this code will be executed after every click I do? 
>>
>> On Tuesday, August 7, 2018 at 9:54:17 PM UTC+5:30, Titus Fortner wrote:
>>>
>>> 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, rajagopal...@gmail.com 
>>> 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  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 ... is not 
>> clickable at point (537, 362). Other element would receive the click: 
>> > class="loader-bg">" 
>> > 
>> > 
>> > 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 

Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread Titus Fortner
after any action that changes or is likely to change the dom, so it can get
heavy if overused. The Executor class when implemented will open up a lot
more flexibility.




On Tue, Aug 7, 2018, 9:27 AM  wrote:

> Ah! that's pretty interesting, I was not knowing this. So you say Once I
> have written this code, this code will be executed after every click I do?
>
> On Tuesday, August 7, 2018 at 9:54:17 PM UTC+5:30, Titus Fortner wrote:
>>
>> 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, rajagopal...@gmail.com
>> 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  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 ... is not clickable
> at point (537, 362). Other element would receive the click:  class="loader-bg">"
> >
> >
> > 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.
> >
> > 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
> 

Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread rajagopalanmadasami
Ah! that's pretty interesting, I was not knowing this. So you say Once I 
have written this code, this code will be executed after every click I do? 

On Tuesday, August 7, 2018 at 9:54:17 PM UTC+5:30, Titus Fortner wrote:
>
> 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, rajagopal...@gmail.com 
> 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  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 ... is not clickable 
 at point (537, 362). Other element would receive the click: >>> class="loader-bg">" 
 > 
 > 
 > 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. 
 > 
 > 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-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You 

Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread Titus Fortner

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, rajagopal...@gmail.com 
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  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 ... is not clickable 
>>> at point (537, 362). Other element would receive the click: >> class="loader-bg">" 
>>> > 
>>> > 
>>> > 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. 
>>> > 
>>> > 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-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.


Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread rajagopalanmadasami
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  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 ... is not clickable at 
>> point (537, 362). Other element would receive the click: > class="loader-bg">" 
>> > 
>> > 
>> > 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. 
>> > 
>> > 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-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.


Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread Justin Ko
The #wait_for_ajax simplifies things if you need to manually call it. 
However, it sounds like you would have to sprinkle this everywhere.

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.

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 > 
> 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 ... is not clickable at 
> point (537, 362). Other element would receive the click:  class="loader-bg">" 
> > 
> > 
> > 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. 
> > 
> > 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-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.


Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread Titus Fortner
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  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 ... is not clickable at point 
> (537, 362). Other element would receive the click:  class="loader-bg">"
>
>
> 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.
>
> 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.


Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread NaviHan
Yes Titus. I actually meant click after the wait. 

The stale element issue is resolved with Watir upgrade. 

I used jquery statement and managed to fix the issue. But what is the page 
object way to do that? 

Also could you please clarify the difference between wait.until(&:present?) and 
wait.while(&:present). I remember you mentioned the first wait for to be truthy 
and the latter tobefalsey. 

When I use both it gives the same results. I check the presence of an element 
using wait until present and if this evaluates to true do something.

wait while also does the same sometimes. 

Is there a good documentation on page object waits. It's really killing me. 

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


Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-06 Thread Titus Fortner
So, it looks like there are a couple things going on here.

> wait_until with present flag will wait until the element is present and then 
> clicks it
I think you just misspoke here, but to clarify just in case, `#click`
method will automatically wait for the element it is clicking to be
present based on that element's locator. `#wait_until(&:present?)`
does not automatically click anything

Figuring out if something is "displayed" is very tricky and the
drivers do their best job to approximate it. JavaScript will flummox
them for sure. Is the JavaScript jquery? You can wait for the jquery
queue to be zero. That would be easiest. I think PO gem even has a way
to do that automatically for you. Or you can: `browser.wait_until {
execute_script("return jQuery.active == 0") }`

If it isn't javascript, then it gets difficult because figuring out
these transitionary stages involves a race condition both before and
after the transition. I'm actually curious how other people handle
these with their explicit waits. I petitioned (and it was agreed to)
for the next version of the w3c specification to require an endpoint
to allow us to implement an `#interactible?` method, which we could
then poll for as an explicit wait. In the meantime, I think the best
answer looks like this, but it's a little hacky

def ensure_click(element)
  element.click
rescue Selenium::WebDriver::Error::UnknownError => ex
  raise unless ex.message.include?("is not clickable")
  sleep 0.1
  retry
end

As for `StaleElementReferenceError`, update to Watir 6.12. I think we
fixed a bug that caused that to slip through. If you are still seeing
that with 6.12, it's a problem and I'll want to dig into it more. You
should never get that with Watir.
On Mon, Aug 6, 2018 at 8:52 PM NaviHan  wrote:
>
> You are right. It works with pure Watir.
> Unfortunately my company insists Pageobejct :-)
>
> With a fresh mind wait_while and wait_until is so confusing
> For instance wait_until with present flag will wait until the element is 
> present and then clicks it and I clearly do not understand why its should 
> click some other element in this case "loader.bg"
>
> May be I should wait for Justin Ko to help me with this as I use page object.
>
> I slightly modified the code as
>
> variation_groups_elements.find { |el| 
> el.wait_until(&:present?).title.include? color }.click
>
> This works when it clicks on the first color say "eucalyptus". After that the 
> script does a couple of things and then go to select a different color say 
> black.
> Thats when this is failing.
>
> Selenium::WebDriver::Error::UnknownError: unknown error: Element  class="swatchanchor" 
> href="https://ci.cottonon.com/AU/show-variation/?dwvar_2003013_color=2003013-05pid=2003013dwvar_2003013_size=XXSoriginalPid=2003013-05;
>  title="Select Colour: BLACK" data-attribute-type="color">... is not 
> clickable at point (504, 64). Other element would receive the click:  class="loader-bg">
>  (Session info: chrome=68.0.3440.84)
>  (Driver info: chromedriver=2.41.578737 
> (49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 6.1.7601 SP1 
> x86_64)
>
> The cucumber script is
>
> And the user navigates to PDP of the product "123"
> And the user selects the color "eucalyptus"
> And the user selects the online size "XXS"
> And the user navigates to In-Store tab
> And the user searches for stock in stores by postcode 3030
> And the user selects the color "black"
>
> There is a javascript spinner which appears while loading the list of stores 
> for line "And the user searches for stock in stores by postcode 3030"
>
>
> But as we are using wait_until(&:present) I would expect the script to wait 
> till the next color is present and then do the click.
>
> Any more thoughts?
> Selenium::WebDriver::Error::StaleElementReferenceError: stale element 
> reference: element is not attached to the page document
>   (Session info: chrome=68.0.3440.84)
>   (Driver info: chromedriver=2.36.540470 
> (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 6.1.7601 SP1 
> x86_64)
>
>
> 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]/," ")

Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-06 Thread Titus Fortner
1. I need more of a stack trace than that. What method is calling wait?

2. I need to see more code. If you are locating an element with
`title: /Select Colour/` then it doesn't make sense to wait for the
title to include that value, clicking on it will automatically wait
for that condition to be true.

Did you take a screenshot at the point of the exception to verify that
the page is in the condition you need it to be in?


On Mon, Aug 6, 2018 at 4:47 PM NaviHan  wrote:
>
> Still having issues with wait
>
>   def select_variation_group(color)
> variation_groups_elements.map do |element|
>   element.wait_until { |el| el.title.include? color }
>   element.click
> end
>   end
>
> Error
> Watir::Wait::TimeoutError: timed out after 10 seconds, waiting for true 
> condition on #/Select Colour:/, 
> :tag_name=>"a", :index=>0}>
>
>
>
> 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.
>
> 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.


Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-06 Thread Titus Fortner
There are several reasons why tests can pass locally but fail
remotely. Sometimes the code is run at a different resolution. The
debugging process is going to be the same. Read the error message to
see what specifically is failing, and look at the full stack trace
(use `--backtrace`) to see the exact spot of failure. Create a
screenshot at the point of failure to see if anything is obvious (on
the wrong page, element is covered by another element, element isn't
loaded, etc, etc). If it might be an issue with the driver or the
waiting logic, you can turn on the Selenium or Watir logging.

I notice that your version of Chromedriver is not compatible with your
version of Chrome
(https://chromedriver.storage.googleapis.com/2.41/notes.txt).

As for clearing up the waiting confusion, let's start with, you should
never need to use Watir::Wait directly. I'm curious where you are
seeing examples for the code you are using because it will not work.
This code is waiting for the element after it is already attempting to
use the element.

Watir::Wait.until {el}.click if el.attribute('title').include? "#{color}"

This is probably the code you want:
element.wait_until { |el| el.title.include? color }


On Mon, Aug 6, 2018 at 6:23 AM NaviHan  wrote:
>
> Thanks Titus
>
> The script again failed in Jenkins box but it passed in local machine. What 
> could be the reason? Im yet to get the details of the box like OS etc. Used 
> the same code snippet
>
> cta_description_element.wait_until(&:present?).text.gsub(/[^$,.A-Za-z0-9]/," 
> ")
>
>
> Also while working on a different script, I found something strange. The 
> below code snippet fails with reason as specified.
> variation_groups_elements.map do |el|
>
>   Watir::Wait.until {el}.click if el.attribute('title').include? 
> "#{color}"
> end
>
> Selenium::WebDriver::Error::UnknownError: unknown error: Element  class="swatchanchor" 
> href="https://ci.cottonon.com/AU/show-variation/?dwvar_2003013_color=2003013-05pid=2003013dwvar_2003013_size=XXSoriginalPid=2003013-05;
>  title="Select Colour: BLACK" data-attribute-type="color">... is not 
> clickable at point (504, 64). Other element would receive the click:  class="loader-bg">
>   (Session info: chrome=68.0.3440.84)
>   (Driver info: chromedriver=2.36.540470 
> (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 6.1.7601 SP1 
> x86_64)
>
>
> I tried modifying the code as below expecting that the script waits for 3 
> second until it finds "el" but got the same error above
>
> Watir::Wait.until(timeout = 3) {el}.click if el.attribute('title').include? 
> "#{color}"
>
>
> However putting a 1 second sleep before the statement passed. Wondering what 
> is the difference?
>
> variation_groups_elements.map do |el|
>   sleep 1
>   Watir::Wait.until {el}.click if el.attribute('title').include? "#{color}"
> end
>
>
> Im so much confused about the Watir::Wait.until, wait_until, wait_while 
> methods. Putting a sleep instead gives more favorable outputs.
>
> Thanks in advance
> But putting a sleep before works fine. How are both different
> 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.
>
> 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