[wtr-general] Re: How often to get element reference, best practice?
I would like to say , this is such a perfect clarity! Yes this is the way wait has to work. On Thursday, September 13, 2018 at 8:57:57 PM UTC+5:30, Titus Fortner wrote: > > 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?
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?
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?
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?
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?
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?
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?
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?
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?
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?
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?
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?
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?
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?
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?
#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?
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?
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?
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?
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?
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.
[wtr-general] Re: How often to get element reference, best practice?
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?
Yeah, it is automatic only for action methods, which does not include text. There's a case to be made to extend that behavior to text since it will return an empty string if it isn't displayed, but for now you'll need to keep the wait. On Wed, Sep 12, 2018, 8:19 PM NaviHan wrote: > Hi Titus > > Thanks for the detailed explanation and the documentation link. > Unfortunately my confusion doesnt get clarified. > > As you said for an element which eventually displays, for example a pop up > that appears due to a user action, we can read the text by > > *scenario 1* > "my_element.when_present.text" because when_present get info from element > that eventually *displays* > > The above changed to my_element.text, post Watir6.0 as the wait was made > automatic > > *scenario 2* > "my_element.wait_until(&:present?).text" also waits for the element to be > displayed like "my_element.when_present.text" > So they are one and the same. > > Because they are one and the same and post Watir6.0 the when_present wait > was made automatic we can achieve the above objective with "my_element.text" > > So there will never be a case where we have to use wait_until(&:present?). > > This is my theory. > 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.
[wtr-general] Re: How often to get element reference, best practice?
Hi Titus Thanks for the detailed explanation and the documentation link. Unfortunately my confusion doesnt get clarified. As you said for an element which eventually displays, for example a pop up that appears due to a user action, we can read the text by *scenario 1* "my_element.when_present.text" because when_present get info from element that eventually *displays* The above changed to my_element.text, post Watir6.0 as the wait was made automatic *scenario 2* "my_element.wait_until(&:present?).text" also waits for the element to be displayed like "my_element.when_present.text" So they are one and the same. Because they are one and the same and post Watir6.0 the when_present wait was made automatic we can achieve the above objective with "my_element.text" So there will never be a case where we have to use wait_until(&:present?). This is my theory. 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.
[wtr-general] Re: How often to get element reference, best practice?
Hey Navi, I'm sorry there is so much confusion around the waits. If there is something that would make this article (http://watir.com/guides/waiting/) more clear, please let me know so I can make it better. Maybe I spend too much time focusing on history and implementation details that don't matter to you? Best practice before Watir 6: Scenario one, click element that eventually displays: my_element.when_present.click Scenario two, get info from element that eventually displays: my_element.when_present.get_attribute('class') Secnario three, wait for one element then act on another: my_element1.wait_until_present my_element2.click For the first scenario, since your test shouldn't attempt to click an element that isn't present, Watir 6 made the waiting automatic. This will now do the exact same thing: my_element.click Scenario 2: Watir waits for the element to exist, but not for it to be displayed. So if it needs to be displayed first (usually some kind of dynamic activity on the page): element.wait_until(&:present?).attribute_value('class') Scenario 3: element_one.wait_until(&:present?) element_two.click We are encouraging everyone to move to the to_proc notation `&:` with the wait methods. This drastically simplifies the code we have to maintain relative to the benefit to our users. We do still have `#wait_until_present` and `#wait_while_present` methods to handle some special use cases, but these may go away as well. Does this clarify things more? On Tuesday, September 11, 2018 at 9:49:37 PM UTC-7, NaviHan wrote: > > > Hi Titus > > You said "when_present" and 'wait_until(&:present?)" does the same thing, > which is Waits for element to be present, the former is deprecated and > latter is recommended. > > Why is that if bot does the same thing > > Im trying to understand if "wait_until(&:present?)" is in any ways > different from "when_present" eventhough its deprecated. > > > Justin also mentioned on version 6.0 of Watir you made changes to > automatically wait for elements before taking actions which let us do away > ith "when_present". So I still do not understand why we should ever use > wait_until(&:present?) at all. > > Sorry if I sound stupid, becasue there is so much cinfusion around waits > :-( > > 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?
Hi Titus You said "when_present" and 'wait_until(&:present?)" does the same thing, which is Waits for element to be present, the former is deprecated and latter is recommended. Why is that if bot does the same thing Im trying to understand if "wait_until(&:present?)" is in any ways different from "when_present" eventhough its deprecated. Justin also mentioned on version 6.0 of Watir you made changes to automatically wait for elements before taking actions which let us do away ith "when_present". So I still do not understand why we should ever use wait_until(&:present?) at all. Sorry if I sound stupid, becasue there is so much cinfusion around waits :-( 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?
Oh man, that FAQ is kind of dated, and more confusing than I remember it being. I should tidy a couple things there. The specific use case detailed in "Why are my tests taking so long?" section of that FAQ is going to be rare, and very unlikely to apply to you. So you should just ignore that one. :) when_present - Waits for element to be present, now deprecated wait_until(&:present?) - Waits for element to be present; this is recommended usage. wait_until_present - this one is slightly trickier, and hopefully the need for it goes away in a future release. Essentially this method is needed in a very rare use case: the element is located, then goes away, and you want to wait for it to come back. http://watir.com/guides/waiting/#wait-until-present-and-wait-while-present relaxed_locate = true is the default. Relaxed means that it will automatically wait for elements to be present if they are not. relaxed_locate = false is for people who want to use Watir 6, but do not want the automatic waiting behaviors. (these are the people who had issues with the "Why are my tests taking so long?" section of the FAQ) Watir 7 will be deprecating this setting entirely, and relaxed_locate will be true for everyone. On Tuesday, September 11, 2018 at 7:40:29 AM UTC-7, NaviHan wrote: > > Hi Justin/Titus > > I have read the watit 6.0 release notes and FAQ @ > http://watir.com/watir-6-faq/#H > Thanks a lot for giving the valuable info. > > Until now I was under the impression that "element.when_present" & > "element.wait_until(&:present)", but reading the notes I understood that > they are different. > > Arent both waiting for deafult of "30" seconds for the element to be > present? What is the difference between the two? > > 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?
Sorry to too many replies. But this is really killing me. I see there is anothet wait which is wait_until_present? Someone please clarify the difference between the 3 1. element.when_present, which is deprecated and auto included from watir 6.0 onwards 2. element.wait_until(&:present) which is same as element.wait_until {|el el.present?)|} & 3. element.wait_until_present I have read that two is used when Watir.relaxed_locate = false two but why would someone ever set this to true? which means watir doesnt wait for an element to be found or present before taking an action. Thanks 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?
Hi Justin/Titus I have read the watit 6.0 release notes and FAQ @ http://watir.com/watir-6-faq/#H Thanks a lot for giving the valuable info. Until now I was under the impression that "element.when_present" & "element.wait_until(&:present)", but reading the notes I understood that they are different. Arent both waiting for deafult of "30" seconds for the element to be present? What is the difference between the two? 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?
Hi Justin Unfortunately thats not the truth. We started automation for our project approximately an year back, and Im pretty sure the version since the start is post 6.0. We are doing these kind of duplication out of ignorance. Coming to the question, does watir show any warnings if we use "add_to_bag_element.when_present.click" instead of "add_to_bag"? And is the wait the default of 30 seconds? Can you give an example where we have to explicitly wait? 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?
In that example, you should just #add_to_bag. I'm guessing that you are working with a code base that is older than Watir 6.0. Before v6.0, add_to_bag_element.when_present.click was required for elements that were not immediately present on page load (ie you needed to wait for them to appear). In Watir 6.0, Titus made changes to automatically wait for elements before taking actions. As a result, pre-6.0 add_to_bag_element.when_present.click would be equivalent to v6.0 add_to_bag_element.click. add_to_bag_element.click is equivalent to the accessor created add_to_bag. In general, I would say: - You do not need the waits when taking actions (eg click, inputting, etc) on an element. - Use the page object accessor's methods if available (ie don't duplicate the framework) Justin On Tuesday, September 11, 2018 at 12:52:33 AM UTC-4, 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.