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

2018-09-14 Thread rajagopalanmadasami
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

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

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

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

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

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

[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

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

[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

[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

[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

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

[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

[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

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

[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

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

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

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

[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

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

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

2018-09-12 Thread NaviHan
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

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

2018-09-12 Thread Titus Fortner
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 >

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

2018-09-12 Thread NaviHan
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*

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

2018-09-12 Thread Titus Fortner
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

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

2018-09-11 Thread NaviHan
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

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

2018-09-11 Thread Titus Fortner
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

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

2018-09-11 Thread NaviHan
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

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

2018-09-11 Thread NaviHan
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

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

2018-09-11 Thread NaviHan
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

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

2018-09-11 Thread Justin Ko
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).