Re: [wtr-general] Re: How often to get element reference, best practice?

2018-09-13 Thread rajagopalan madasami
Beautiful, thanks!

On Fri 14 Sep, 2018, 9:21 AM Titus Fortner,  wrote:

> yes
> On Thu, Sep 13, 2018 at 8:41 PM rajagopalan madasami
>  wrote:
> >
> > Waiting for select list is added?
> >
> > On Fri 14 Sep, 2018, 7:18 AM Titus Fortner, 
> wrote:
> >>
> >> 6.14 was just released, hopefully it addresses your issues.
> >> On Thu, Sep 13, 2018 at 9:57 AM rajagopalan madasami
> >>  wrote:
> >> >
> >> > Yes, I saw this new change in your new article but I can't use WATIR
> 6.13 because as you know, its not waiting for select list.
> >> >
> >> > On Thu 13 Sep, 2018, 9:00 PM Titus Fortner, 
> wrote:
> >> >>
> >> >> As of 6.13 you can now that wait like this:
> >> >>
> >> >> b.label(id: 'something').wait_until(text: 'Expected Text')
> >> >>
> >> >>
> >> >> On Thursday, September 13, 2018 at 4:40:53 AM UTC-7, rajagopalan
> madasami wrote:
> >> >>>
> >> >>> Hi Navi,
> >> >>>
> >> >>> yes, you are right with your understanding.
> >> >>>
> >> >>> WATIR locates elements completely different from Selenium
> >> >>>
> >> >>> When you write,
> >> >>>
> >> >>> element=b.span(id: 'click')
> >> >>>
> >> >>> It doesn't locate the element, but when you write
> >> >>>
> >> >>> element.click
> >> >>>
> >> >>> it locates the element and continue to perform the click operation,
> this arrangement is useful to relocate the element when element goes to
> stale, waiting until element is visible and likewise this arrangement is
> useful for cases. Technically this should include even when I call text
> method as well. But I do in my project here is,
> >> >>>
> >> >>> I write code like
> >> >>>
> >> >>> b.wait_until(b.label(id: 'something').text?'Expected Text')
> >> >>>
> >> >>> This will reexecute the statement for 30 seconds, otherwise it
> would throw the error
> >> >>>
> >> >>> Or
> >> >>>
> >> >>> b.label(id: 'something').wait_until{|element|
> element.text.eql?'Expected Text'}
> >> >>>
> >> >>>
> >> >>>
> >> >>> On Thu, Sep 13, 2018 at 11:16 AM NaviHan 
> wrote:
> >> 
> >>  Hi Titus
> >> 
> >>  Thats makes it very clear now :-)
> >> 
> >>  Just to confirm, action methods as in set, click, select
> >>  And the reading attribute values like id, text, or any other
> custom attribute are not auto covered and we need to use
> wait_until(&:present?)
> >> 
> >>  Is that correct?
> >> 
> >>  Cheers
> >>  Navi
> >> 
> >>  On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
> >> >
> >> > This is something that keeps me a bit sceptic when I write and
> read the automation code in my project.
> >> > This used PageObjects.
> >> >
> >> > I have seen extensive use of element referces, for example
> >> >
> >> > button(:add_to_bag, :css => '#add-to-cart')
> >> > add_to_bag.element.when_present.click
> >> >
> >> >
> >> >
> >> > instead of
> >> >
> >> > add_to_bag
> >> >
> >> > which directly clicks the element
> >> >
> >> > I have also seen extensive use of referencing elements using
> .when_present, .wait_until_present etc
> >> >
> >> > Im confused where we should draw the line when deciding to
> reference the element and actually using it(as in directly calling
> "add_o_bag" in the above example to click the element.
> >> >
> >> > Any thoughts?
> >> >
> >> >
> >>  --
> >>  --
> >>  Before posting, please read
> https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group
> .
> >>  In short: search before you ask, be nice.
> >> 
> >>  watir-...@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.
> >> >
> >> > --
> >> > --
> >> > 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
> >> > 

Re: [wtr-general] Re: How often to get element reference, best practice?

2018-09-13 Thread Titus Fortner
yes
On Thu, Sep 13, 2018 at 8:41 PM rajagopalan madasami
 wrote:
>
> Waiting for select list is added?
>
> On Fri 14 Sep, 2018, 7:18 AM Titus Fortner,  wrote:
>>
>> 6.14 was just released, hopefully it addresses your issues.
>> On Thu, Sep 13, 2018 at 9:57 AM rajagopalan madasami
>>  wrote:
>> >
>> > Yes, I saw this new change in your new article but I can't use WATIR 6.13 
>> > because as you know, its not waiting for select list.
>> >
>> > On Thu 13 Sep, 2018, 9:00 PM Titus Fortner,  wrote:
>> >>
>> >> As of 6.13 you can now that wait like this:
>> >>
>> >> b.label(id: 'something').wait_until(text: 'Expected Text')
>> >>
>> >>
>> >> On Thursday, September 13, 2018 at 4:40:53 AM UTC-7, rajagopalan madasami 
>> >> wrote:
>> >>>
>> >>> Hi Navi,
>> >>>
>> >>> yes, you are right with your understanding.
>> >>>
>> >>> WATIR locates elements completely different from Selenium
>> >>>
>> >>> When you write,
>> >>>
>> >>> element=b.span(id: 'click')
>> >>>
>> >>> It doesn't locate the element, but when you write
>> >>>
>> >>> element.click
>> >>>
>> >>> it locates the element and continue to perform the click operation, this 
>> >>> arrangement is useful to relocate the element when element goes to 
>> >>> stale, waiting until element is visible and likewise this arrangement is 
>> >>> useful for cases. Technically this should include even when I call text 
>> >>> method as well. But I do in my project here is,
>> >>>
>> >>> I write code like
>> >>>
>> >>> b.wait_until(b.label(id: 'something').text?'Expected Text')
>> >>>
>> >>> This will reexecute the statement for 30 seconds, otherwise it would 
>> >>> throw the error
>> >>>
>> >>> Or
>> >>>
>> >>> b.label(id: 'something').wait_until{|element| element.text.eql?'Expected 
>> >>> Text'}
>> >>>
>> >>>
>> >>>
>> >>> On Thu, Sep 13, 2018 at 11:16 AM NaviHan  wrote:
>> 
>>  Hi Titus
>> 
>>  Thats makes it very clear now :-)
>> 
>>  Just to confirm, action methods as in set, click, select
>>  And the reading attribute values like id, text, or any other custom 
>>  attribute are not auto covered and we need to use wait_until(&:present?)
>> 
>>  Is that correct?
>> 
>>  Cheers
>>  Navi
>> 
>>  On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>> >
>> > This is something that keeps me a bit sceptic when I write and read 
>> > the automation code in my project.
>> > This used PageObjects.
>> >
>> > I have seen extensive use of element referces, for example
>> >
>> > button(:add_to_bag, :css => '#add-to-cart')
>> > add_to_bag.element.when_present.click
>> >
>> >
>> >
>> > instead of
>> >
>> > add_to_bag
>> >
>> > which directly clicks the element
>> >
>> > I have also seen extensive use of referencing elements using 
>> > .when_present, .wait_until_present etc
>> >
>> > Im confused where we should draw the line when deciding to reference 
>> > the element and actually using it(as in directly calling "add_o_bag" 
>> > in the above example to click the element.
>> >
>> > Any thoughts?
>> >
>> >
>>  --
>>  --
>>  Before posting, please read 
>>  https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
>>  In short: search before you ask, be nice.
>> 
>>  watir-...@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.
>> >
>> > --
>> > --
>> > 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 

Re: [wtr-general] Re: How often to get element reference, best practice?

2018-09-13 Thread rajagopalan madasami
Waiting for select list is added?

On Fri 14 Sep, 2018, 7:18 AM Titus Fortner,  wrote:

> 6.14 was just released, hopefully it addresses your issues.
> On Thu, Sep 13, 2018 at 9:57 AM rajagopalan madasami
>  wrote:
> >
> > Yes, I saw this new change in your new article but I can't use WATIR
> 6.13 because as you know, its not waiting for select list.
> >
> > On Thu 13 Sep, 2018, 9:00 PM Titus Fortner, 
> wrote:
> >>
> >> As of 6.13 you can now that wait like this:
> >>
> >> b.label(id: 'something').wait_until(text: 'Expected Text')
> >>
> >>
> >> On Thursday, September 13, 2018 at 4:40:53 AM UTC-7, rajagopalan
> madasami wrote:
> >>>
> >>> Hi Navi,
> >>>
> >>> yes, you are right with your understanding.
> >>>
> >>> WATIR locates elements completely different from Selenium
> >>>
> >>> When you write,
> >>>
> >>> element=b.span(id: 'click')
> >>>
> >>> It doesn't locate the element, but when you write
> >>>
> >>> element.click
> >>>
> >>> it locates the element and continue to perform the click operation,
> this arrangement is useful to relocate the element when element goes to
> stale, waiting until element is visible and likewise this arrangement is
> useful for cases. Technically this should include even when I call text
> method as well. But I do in my project here is,
> >>>
> >>> I write code like
> >>>
> >>> b.wait_until(b.label(id: 'something').text?'Expected Text')
> >>>
> >>> This will reexecute the statement for 30 seconds, otherwise it would
> throw the error
> >>>
> >>> Or
> >>>
> >>> b.label(id: 'something').wait_until{|element|
> element.text.eql?'Expected Text'}
> >>>
> >>>
> >>>
> >>> On Thu, Sep 13, 2018 at 11:16 AM NaviHan  wrote:
> 
>  Hi Titus
> 
>  Thats makes it very clear now :-)
> 
>  Just to confirm, action methods as in set, click, select
>  And the reading attribute values like id, text, or any other custom
> attribute are not auto covered and we need to use wait_until(&:present?)
> 
>  Is that correct?
> 
>  Cheers
>  Navi
> 
>  On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
> >
> > This is something that keeps me a bit sceptic when I write and read
> the automation code in my project.
> > This used PageObjects.
> >
> > I have seen extensive use of element referces, for example
> >
> > button(:add_to_bag, :css => '#add-to-cart')
> > add_to_bag.element.when_present.click
> >
> >
> >
> > instead of
> >
> > add_to_bag
> >
> > which directly clicks the element
> >
> > I have also seen extensive use of referencing elements using
> .when_present, .wait_until_present etc
> >
> > Im confused where we should draw the line when deciding to reference
> the element and actually using it(as in directly calling "add_o_bag" in the
> above example to click the element.
> >
> > Any thoughts?
> >
> >
>  --
>  --
>  Before posting, please read
> https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group
> .
>  In short: search before you ask, be nice.
> 
>  watir-...@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.
> >
> > --
> > --
> > 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
> 

Re: [wtr-general] Re: How often to get element reference, best practice?

2018-09-13 Thread Titus Fortner
6.14 was just released, hopefully it addresses your issues.
On Thu, Sep 13, 2018 at 9:57 AM rajagopalan madasami
 wrote:
>
> Yes, I saw this new change in your new article but I can't use WATIR 6.13 
> because as you know, its not waiting for select list.
>
> On Thu 13 Sep, 2018, 9:00 PM Titus Fortner,  wrote:
>>
>> As of 6.13 you can now that wait like this:
>>
>> b.label(id: 'something').wait_until(text: 'Expected Text')
>>
>>
>> On Thursday, September 13, 2018 at 4:40:53 AM UTC-7, rajagopalan madasami 
>> wrote:
>>>
>>> Hi Navi,
>>>
>>> yes, you are right with your understanding.
>>>
>>> WATIR locates elements completely different from Selenium
>>>
>>> When you write,
>>>
>>> element=b.span(id: 'click')
>>>
>>> It doesn't locate the element, but when you write
>>>
>>> element.click
>>>
>>> it locates the element and continue to perform the click operation, this 
>>> arrangement is useful to relocate the element when element goes to stale, 
>>> waiting until element is visible and likewise this arrangement is useful 
>>> for cases. Technically this should include even when I call text method as 
>>> well. But I do in my project here is,
>>>
>>> I write code like
>>>
>>> b.wait_until(b.label(id: 'something').text?'Expected Text')
>>>
>>> This will reexecute the statement for 30 seconds, otherwise it would throw 
>>> the error
>>>
>>> Or
>>>
>>> b.label(id: 'something').wait_until{|element| element.text.eql?'Expected 
>>> Text'}
>>>
>>>
>>>
>>> On Thu, Sep 13, 2018 at 11:16 AM NaviHan  wrote:

 Hi Titus

 Thats makes it very clear now :-)

 Just to confirm, action methods as in set, click, select
 And the reading attribute values like id, text, or any other custom 
 attribute are not auto covered and we need to use wait_until(&:present?)

 Is that correct?

 Cheers
 Navi

 On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>
> This is something that keeps me a bit sceptic when I write and read the 
> automation code in my project.
> This used PageObjects.
>
> I have seen extensive use of element referces, for example
>
> button(:add_to_bag, :css => '#add-to-cart')
> add_to_bag.element.when_present.click
>
>
>
> instead of
>
> add_to_bag
>
> which directly clicks the element
>
> I have also seen extensive use of referencing elements using 
> .when_present, .wait_until_present etc
>
> Im confused where we should draw the line when deciding to reference the 
> element and actually using it(as in directly calling "add_o_bag" in the 
> above example to click the element.
>
> Any thoughts?
>
>
 --
 --
 Before posting, please read 
 https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
 In short: search before you ask, be nice.

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

Re: [wtr-general] Re: How often to get element reference, best practice?

2018-09-13 Thread Titus Fortner
Glad I could help, but now I'm going to go refactor everything so it
will be less confusing going forward. :)

On Thu, Sep 13, 2018 at 6:33 PM NaviHan  wrote:
>
> Got you, Titus
> The fundamental aspects are clear now.
>
> I will get back if I find a real case in my project that is not working as 
> per my understanding
>
> Thanks a million for taking time to clarify things. really appreciate it :-)
>
> Cheers
> Navi
>
> On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>>
>> This is something that keeps me a bit sceptic when I write and read the 
>> automation code in my project.
>> This used PageObjects.
>>
>> I have seen extensive use of element referces, for example
>>
>> button(:add_to_bag, :css => '#add-to-cart')
>> add_to_bag.element.when_present.click
>>
>>
>>
>> instead of
>>
>> add_to_bag
>>
>> which directly clicks the element
>>
>> I have also seen extensive use of referencing elements using 
>> .when_present, .wait_until_present etc
>>
>> Im confused where we should draw the line when deciding to reference the 
>> element and actually using it(as in directly calling "add_o_bag" in the 
>> above example to click the element.
>>
>> Any thoughts?
>>
>>
> --
> --
> Before posting, please read 
> https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
> In short: search before you ask, be nice.
>
> watir-general@googlegroups.com
> http://groups.google.com/group/watir-general
> watir-general+unsubscr...@googlegroups.com
> ---
> You received this message because you are subscribed to the Google Groups 
> "Watir General" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to watir-general+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

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


[wtr-general] Re: How often to get element reference, best practice?

2018-09-13 Thread NaviHan
Got you, Titus
The fundamental aspects are clear now.

I will get back if I find a real case in my project that is not working as 
per my understanding

Thanks a million for taking time to clarify things. really appreciate it :-)

Cheers
Navi

On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>
> This is something that keeps me a bit sceptic when I write and read the 
> automation code in my project.
> This used PageObjects.
>
> I have seen extensive use of element referces, for example 
>
> button(:add_to_bag, :css => '#add-to-cart')
> add_to_bag.element.when_present.click
>
>
>
> instead of 
>
> add_to_bag 
>
> which directly clicks the element
>
> I have also seen extensive use of referencing elements using 
> .when_present, .wait_until_present etc
>
> Im confused where we should draw the line when deciding to reference the 
> element and actually using it(as in directly calling "add_o_bag" in the above 
> example to click the element.
>
> Any thoughts?
>
>
>

-- 
-- 
Before posting, please read 
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
 
In short: search before you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: How often to get element reference, best practice?

2018-09-13 Thread Titus Fortner
I still don't understand the scenario. If it finds an element at the locator 
provided, it will stop on a wait_until_present and keep polling on a 
wait_while_present. Vice versa if an element is not found at that locator. If 
you have dynamic things happening, your test logic needs to handle it. That 
might mean a combination of the methods we're discussing, or a polite request 
of the app devs to add a class for after the transition has happened. 

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


[wtr-general] Re: How often to get element reference, best practice?

2018-09-13 Thread NaviHan
Oh no Titus. Havent encountered such a scenario in my project.
I just wanted to make my understanding clear.

Except this dynamic "here" thingy everything regarding Watir waits is clear 
now.. :-)

On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>
> This is something that keeps me a bit sceptic when I write and read the 
> automation code in my project.
> This used PageObjects.
>
> I have seen extensive use of element referces, for example 
>
> button(:add_to_bag, :css => '#add-to-cart')
> add_to_bag.element.when_present.click
>
>
>
> instead of 
>
> add_to_bag 
>
> which directly clicks the element
>
> I have also seen extensive use of referencing elements using 
> .when_present, .wait_until_present etc
>
> Im confused where we should draw the line when deciding to reference the 
> element and actually using it(as in directly calling "add_o_bag" in the above 
> example to click the element.
>
> Any thoughts?
>
>
>

-- 
-- 
Before posting, please read 
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
 
In short: search before you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: How often to get element reference, best practice?

2018-09-13 Thread Titus Fortner
What action are you trying to accomplish? It sometimes changes back which 
breaks things? I need to understand the scenario better. 

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


[wtr-general] Re: How often to get element reference, best practice?

2018-09-13 Thread NaviHan
Hi Titus

Let me explain in deatils

We define the selector in the code as
div(class: "here")



Dynamic action changed the class to 
"not-here"

in the DOM but but the the selector still remains the same in code
.(div(class: "here"))



Due to this reason 
element.wait_while(&:present?)

,will timeout as Watir just keeps verifying that the cached element is 
still there using the selector defined in code which is again
 (div(class: "here"))


As a solution we use 
element.wait_while_present 

which looks up the element from scratch.. But the class of the element in 
DOM is still
 "not_here" 

and the selector in code is
 "here"


So element.wait_while_present is never going to locate the element as the 
class has changed to
 "not-here" 

in DOM.

But if in the DOM the class has changed back to 
"here"

from 
"not-here"

then
 wait_while_present

will locate it.

I hope you see where the confusion is. We never talks about the dynamic 
action which changes the class back to "here"


On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:

> This is something that keeps me a bit sceptic when I write and read the 
> automation code in my project.
> This used PageObjects.
>
> I have seen extensive use of element referces, for example 
>
> button(:add_to_bag, :css => '#add-to-cart')
> add_to_bag.element.when_present.click
>
>
>
> instead of 
>
> add_to_bag 
>
> which directly clicks the element
>
> I have also seen extensive use of referencing elements using 
> .when_present, .wait_until_present etc
>
> Im confused where we should draw the line when deciding to reference the 
> element and actually using it(as in directly calling "add_o_bag" in the above 
> example to click the element.
>
> Any thoughts?
>
>
>

-- 
-- 
Before posting, please read 
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
 
In short: search before you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: How often to get element reference, best practice?

2018-09-13 Thread Titus Fortner
Ack, I was wrong about that.

`#wait_while_present` is equivalent to this:

Watir::Wait.while do
browser.element(class: 'here').present?
end

As soon as it does not find the element it is waiting while for, it will 
exit the waiting loop. If you want to wait for it to go away then come 
back, you'll need to wait_while_present then wait_until_present.


On Thursday, September 13, 2018 at 4:33:27 PM UTC-7, NaviHan wrote:
>
> Hi Titus
>
> This statement
>
> These are effectively equivalent because it is ignoring cache:
>
> my_element.wait_while_present
> browser.element(class: 'here').wait_while(&:present)
>
>
> Do you mean wait_while_present = wait_while(&:present)  --> "present 
> without question mark"
>
> To conclude
>
> wait_while_present will successfully wait when the class transition as 
> "here" to "not-here" to "here"
>
> Cheers
>
> On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>>
>> This is something that keeps me a bit sceptic when I write and read the 
>> automation code in my project.
>> This used PageObjects.
>>
>> I have seen extensive use of element referces, for example 
>>
>> button(:add_to_bag, :css => '#add-to-cart')
>> add_to_bag.element.when_present.click
>>
>>
>>
>> instead of 
>>
>> add_to_bag 
>>
>> which directly clicks the element
>>
>> I have also seen extensive use of referencing elements using 
>> .when_present, .wait_until_present etc
>>
>> Im confused where we should draw the line when deciding to reference the 
>> element and actually using it(as in directly calling "add_o_bag" in the 
>> above example to click the element.
>>
>> Any thoughts?
>>
>>
>>

-- 
-- 
Before posting, please read 
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
 
In short: search before you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: How often to get element reference, best practice?

2018-09-13 Thread NaviHan
Hi Titus

This statement

These are effectively equivalent because it is ignoring cache:

my_element.wait_while_present
browser.element(class: 'here').wait_while(&:present)


Do you mean wait_while_present = wait_while(&:present)  --> "present 
without question mark"

To conclude

wait_while_present will successfully wait when the class transition as 
"here" to "not-here" to "here"

Cheers

On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>
> This is something that keeps me a bit sceptic when I write and read the 
> automation code in my project.
> This used PageObjects.
>
> I have seen extensive use of element referces, for example 
>
> button(:add_to_bag, :css => '#add-to-cart')
> add_to_bag.element.when_present.click
>
>
>
> instead of 
>
> add_to_bag 
>
> which directly clicks the element
>
> I have also seen extensive use of referencing elements using 
> .when_present, .wait_until_present etc
>
> Im confused where we should draw the line when deciding to reference the 
> element and actually using it(as in directly calling "add_o_bag" in the above 
> example to click the element.
>
> Any thoughts?
>
>
>

-- 
-- 
Before posting, please read 
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
 
In short: search before you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: How often to get element reference, best practice?

2018-09-13 Thread Titus Fortner
If the element's class is changed to 'not-here' and Watir is looking for 
'here', then it won't find it and wait_while_present would exit.

This will exit immediately:

my_element = browser.element(class: 'here')
dynamically_change_class(my_element)
my_element.wait_while_present

These are effectively equivalent because it is ignoring cache:

my_element.wait_while_present
browser.element(class: 'here').wait_while(&:present)




On Thursday, September 13, 2018 at 2:39:50 PM UTC-7, NaviHan wrote:
>
> Yes Titus, I got that.
>
> But for that fresh retry from scratch to work, the class of the element 
> has to go back to "here" from "not-here" isnt it?
>
> On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>>
>> This is something that keeps me a bit sceptic when I write and read the 
>> automation code in my project.
>> This used PageObjects.
>>
>> I have seen extensive use of element referces, for example 
>>
>> button(:add_to_bag, :css => '#add-to-cart')
>> add_to_bag.element.when_present.click
>>
>>
>>
>> instead of 
>>
>> add_to_bag 
>>
>> which directly clicks the element
>>
>> I have also seen extensive use of referencing elements using 
>> .when_present, .wait_until_present etc
>>
>> Im confused where we should draw the line when deciding to reference the 
>> element and actually using it(as in directly calling "add_o_bag" in the 
>> above example to click the element.
>>
>> Any thoughts?
>>
>>
>>

-- 
-- 
Before posting, please read 
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
 
In short: search before you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: How often to get element reference, best practice?

2018-09-13 Thread NaviHan
Yes Titus, I got that.

But for that fresh retry from scratch to work, the class of the element has 
to go back to "here" from "not-here" isnt it?

On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>
> This is something that keeps me a bit sceptic when I write and read the 
> automation code in my project.
> This used PageObjects.
>
> I have seen extensive use of element referces, for example 
>
> button(:add_to_bag, :css => '#add-to-cart')
> add_to_bag.element.when_present.click
>
>
>
> instead of 
>
> add_to_bag 
>
> which directly clicks the element
>
> I have also seen extensive use of referencing elements using 
> .when_present, .wait_until_present etc
>
> Im confused where we should draw the line when deciding to reference the 
> element and actually using it(as in directly calling "add_o_bag" in the above 
> example to click the element.
>
> Any thoughts?
>
>
>

-- 
-- 
Before posting, please read 
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
 
In short: search before you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: How often to get element reference, best practice?

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

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




On Thursday, September 13, 2018 at 2:22:00 PM UTC-7, NaviHan wrote:
>
> Thanks a lot Titus and Rajagopalan.
>
> I want to wrap this up with one more question about wait_while_present. 
> Had this confusion while reading Titus's article on Watir waits (
> http://watir.com/guides/waiting/)
>
> you have this element, Foo and you locate it with 
> code "element = browser.div(class: "here")"
>
> Some dynamic event caused the element class to change: " class="not-here">Foo"
>
> In this case we want the element to be looked up from scratch during the 
> polling, which is what this does:
>
> element.wait_while_present
>
> But my question is becasue the class of the element has changed to 
> "not-here" how the wait_while_present is going to work, basically the 
> identifier has changed?
>
> Or did you mean that the class has changed from "here" to "not-here" and 
> again it changed back to "here" ??
>
> Cheers
> Navi
>
> On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>>
>> This is something that keeps me a bit sceptic when I write and read the 
>> automation code in my project.
>> This used PageObjects.
>>
>> I have seen extensive use of element referces, for example 
>>
>> button(:add_to_bag, :css => '#add-to-cart')
>> add_to_bag.element.when_present.click
>>
>>
>>
>> instead of 
>>
>> add_to_bag 
>>
>> which directly clicks the element
>>
>> I have also seen extensive use of referencing elements using 
>> .when_present, .wait_until_present etc
>>
>> Im confused where we should draw the line when deciding to reference the 
>> element and actually using it(as in directly calling "add_o_bag" in the 
>> above example to click the element.
>>
>> Any thoughts?
>>
>>
>>

-- 
-- 
Before posting, please read 
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
 
In short: search before you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: How often to get element reference, best practice?

2018-09-13 Thread NaviHan
Thanks a lot Titus and Rajagopalan.

I want to wrap this up with one more question about wait_while_present. Had 
this confusion while reading Titus's article on Watir waits 
(http://watir.com/guides/waiting/)

you have this element, Foo and you locate it with 
code "element = browser.div(class: "here")"

Some dynamic event caused the element class to change: "Foo"

In this case we want the element to be looked up from scratch during the 
polling, which is what this does:

element.wait_while_present

But my question is becasue the class of the element has changed to 
"not-here" how the wait_while_present is going to work, basically the 
identifier has changed?

Or did you mean that the class has changed from "here" to "not-here" and 
again it changed back to "here" ??

Cheers
Navi

On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>
> This is something that keeps me a bit sceptic when I write and read the 
> automation code in my project.
> This used PageObjects.
>
> I have seen extensive use of element referces, for example 
>
> button(:add_to_bag, :css => '#add-to-cart')
> add_to_bag.element.when_present.click
>
>
>
> instead of 
>
> add_to_bag 
>
> which directly clicks the element
>
> I have also seen extensive use of referencing elements using 
> .when_present, .wait_until_present etc
>
> Im confused where we should draw the line when deciding to reference the 
> element and actually using it(as in directly calling "add_o_bag" in the above 
> example to click the element.
>
> Any thoughts?
>
>
>

-- 
-- 
Before posting, please read 
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
 
In short: search before you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [wtr-general] Re: How often to get element reference, best practice?

2018-09-13 Thread rajagopalan madasami
Yes, I saw this new change in your new article but I can't use WATIR 6.13
because as you know, its not waiting for select list.

On Thu 13 Sep, 2018, 9:00 PM Titus Fortner,  wrote:

> As of 6.13 you can now that wait like this:
>
> b.label(id: 'something').wait_until(text: 'Expected Text')
>
>
> On Thursday, September 13, 2018 at 4:40:53 AM UTC-7, rajagopalan madasami
> wrote:
>>
>> Hi Navi,
>>
>> yes, you are right with your understanding.
>>
>> WATIR locates elements completely different from Selenium
>>
>> When you write,
>>
>> element=b.span(id: 'click')
>>
>> It doesn't locate the element, but when you write
>>
>> element.click
>>
>> it locates the element and continue to perform the click operation, this
>> arrangement is useful to relocate the element when element goes to stale,
>> waiting until element is visible and likewise this arrangement is useful
>> for cases. Technically this should include even when I call text method as
>> well. But I do in my project here is,
>>
>> I write code like
>>
>> b.wait_until(b.label(id: 'something').text?'Expected Text')
>>
>> This will reexecute the statement for 30 seconds, otherwise it would
>> throw the error
>>
>> Or
>>
>> b.label(id: 'something').wait_until{|element| element.text.eql?'Expected
>> Text'}
>>
>>
>>
>> On Thu, Sep 13, 2018 at 11:16 AM NaviHan  wrote:
>>
>>> Hi Titus
>>>
>>> Thats makes it very clear now :-)
>>>
>>> Just to confirm, action methods as in set, click, select
>>> And the reading attribute values like id, text, or any other custom
>>> attribute are not auto covered and we need to use wait_until(&:present?)
>>>
>>> Is that correct?
>>>
>>> Cheers
>>> Navi
>>>
>>> On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:

 This is something that keeps me a bit sceptic when I write and read the
 automation code in my project.
 This used PageObjects.

 I have seen extensive use of element referces, for example

 button(:add_to_bag, :css => '#add-to-cart')
 add_to_bag.element.when_present.click



 instead of

 add_to_bag

 which directly clicks the element

 I have also seen extensive use of referencing elements using 
 .when_present, .wait_until_present etc

 Im confused where we should draw the line when deciding to reference the 
 element and actually using it(as in directly calling "add_o_bag" in the 
 above example to click the element.

 Any thoughts?


 --
>>> --
>>> Before posting, please read
>>> https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
>>>
>>> In short: search before you ask, be nice.
>>>
>>> watir-...@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.
>

-- 
-- 
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: How often to get element reference, best practice?

2018-09-13 Thread Titus Fortner
As of 6.13 you can now that wait like this:

b.label(id: 'something').wait_until(text: 'Expected Text')


On Thursday, September 13, 2018 at 4:40:53 AM UTC-7, rajagopalan madasami 
wrote:
>
> Hi Navi,
>
> yes, you are right with your understanding.
>
> WATIR locates elements completely different from Selenium
>
> When you write, 
>
> element=b.span(id: 'click')
>
> It doesn't locate the element, but when you write
>
> element.click
>
> it locates the element and continue to perform the click operation, this 
> arrangement is useful to relocate the element when element goes to stale, 
> waiting until element is visible and likewise this arrangement is useful 
> for cases. Technically this should include even when I call text method as 
> well. But I do in my project here is,
>
> I write code like
>
> b.wait_until(b.label(id: 'something').text?'Expected Text')
>
> This will reexecute the statement for 30 seconds, otherwise it would throw 
> the error
>
> Or 
>
> b.label(id: 'something').wait_until{|element| element.text.eql?'Expected 
> Text'}
>
>
>
> On Thu, Sep 13, 2018 at 11:16 AM NaviHan  > wrote:
>
>> Hi Titus
>>
>> Thats makes it very clear now :-)
>>
>> Just to confirm, action methods as in set, click, select
>> And the reading attribute values like id, text, or any other custom 
>> attribute are not auto covered and we need to use wait_until(&:present?)
>>
>> Is that correct?
>>
>> Cheers
>> Navi
>>
>> On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>>>
>>> This is something that keeps me a bit sceptic when I write and read the 
>>> automation code in my project.
>>> This used PageObjects.
>>>
>>> I have seen extensive use of element referces, for example 
>>>
>>> button(:add_to_bag, :css => '#add-to-cart')
>>> add_to_bag.element.when_present.click
>>>
>>>
>>>
>>> instead of 
>>>
>>> add_to_bag 
>>>
>>> which directly clicks the element
>>>
>>> I have also seen extensive use of referencing elements using 
>>> .when_present, .wait_until_present etc
>>>
>>> Im confused where we should draw the line when deciding to reference the 
>>> element and actually using it(as in directly calling "add_o_bag" in the 
>>> above example to click the element.
>>>
>>> Any thoughts?
>>>
>>>
>>> -- 
>> -- 
>> Before posting, please read 
>> https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
>>  
>>
>> In short: search before you ask, be nice.
>>  
>> watir-...@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.


[wtr-general] Re: How often to get element reference, best practice?

2018-09-13 Thread Titus Fortner
Ok, yes. This is a slight simplification, but think of Watir waiting for 
what makes the most sense for the provided method.

1. Status Queries --> No automatic waits; immediate response or exception
#exists? / #visible? / #present? / #enabled? 

2. Information Queries --> Automatically waits until exists in DOM
#text / #value / #tag_name / #style / #attribute_value etc

3. Actions --> Automatically waits until displayed to user
#click / #submit / #set / #clear / #select



On Wednesday, September 12, 2018 at 10:46:27 PM UTC-7, NaviHan wrote:
>
> Hi Titus
>
> Thats makes it very clear now :-)
>
> Just to confirm, action methods as in set, click, select
> And the reading attribute values like id, text, or any other custom 
> attribute are not auto covered and we need to use wait_until(&:present?)
>
> Is that correct?
>
> Cheers
> Navi
>
> On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>>
>> This is something that keeps me a bit sceptic when I write and read the 
>> automation code in my project.
>> This used PageObjects.
>>
>> I have seen extensive use of element referces, for example 
>>
>> button(:add_to_bag, :css => '#add-to-cart')
>> add_to_bag.element.when_present.click
>>
>>
>>
>> instead of 
>>
>> add_to_bag 
>>
>> which directly clicks the element
>>
>> I have also seen extensive use of referencing elements using 
>> .when_present, .wait_until_present etc
>>
>> Im confused where we should draw the line when deciding to reference the 
>> element and actually using it(as in directly calling "add_o_bag" in the 
>> above example to click the element.
>>
>> Any thoughts?
>>
>>
>>

-- 
-- 
Before posting, please read 
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
 
In short: search before you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [wtr-general] Re: How often to get element reference, best practice?

2018-09-13 Thread rajagopalan madasami
Hi Navi,

yes, you are right with your understanding.

WATIR locates elements completely different from Selenium

When you write,

element=b.span(id: 'click')

It doesn't locate the element, but when you write

element.click

it locates the element and continue to perform the click operation, this
arrangement is useful to relocate the element when element goes to stale,
waiting until element is visible and likewise this arrangement is useful
for cases. Technically this should include even when I call text method as
well. But I do in my project here is,

I write code like

b.wait_until(b.label(id: 'something').text?'Expected Text')

This will reexecute the statement for 30 seconds, otherwise it would throw
the error

Or

b.label(id: 'something').wait_until{|element| element.text.eql?'Expected
Text'}



On Thu, Sep 13, 2018 at 11:16 AM NaviHan  wrote:

> Hi Titus
>
> Thats makes it very clear now :-)
>
> Just to confirm, action methods as in set, click, select
> And the reading attribute values like id, text, or any other custom
> attribute are not auto covered and we need to use wait_until(&:present?)
>
> Is that correct?
>
> Cheers
> Navi
>
> On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>>
>> This is something that keeps me a bit sceptic when I write and read the
>> automation code in my project.
>> This used PageObjects.
>>
>> I have seen extensive use of element referces, for example
>>
>> button(:add_to_bag, :css => '#add-to-cart')
>> add_to_bag.element.when_present.click
>>
>>
>>
>> instead of
>>
>> add_to_bag
>>
>> which directly clicks the element
>>
>> I have also seen extensive use of referencing elements using 
>> .when_present, .wait_until_present etc
>>
>> Im confused where we should draw the line when deciding to reference the 
>> element and actually using it(as in directly calling "add_o_bag" in the 
>> above example to click the element.
>>
>> Any thoughts?
>>
>>
>> --
> --
> Before posting, please read
> https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
>
> In short: search before you ask, be nice.
>
> watir-general@googlegroups.com
> http://groups.google.com/group/watir-general
> watir-general+unsubscr...@googlegroups.com
> ---
> You received this message because you are subscribed to the Google Groups
> "Watir General" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to watir-general+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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