Discussion:
[wtr-general] How often to get element reference, best practice?
NaviHan
2018-09-11 04:52:32 UTC
Permalink
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Justin Ko
2018-09-11 13:40:28 UTC
Permalink
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
Post by NaviHan
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
NaviHan
2018-09-11 13:50:05 UTC
Permalink
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
Post by NaviHan
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Justin Ko
2018-09-11 15:39:32 UTC
Permalink
Hi Navi,

(This is just response to your first reply. I'll have a look at your other
replies when I have more time.)

`add_to_bag_element.when_present.click` would be Page-Object code rather
than Watir code. There are no warnings that would be thrown from it.

Switching to `add_to_bag` will increase the timeout from 5 to 30 seconds
(assuming you haven't overridden the defaults):
- Page Object's `#when_present` only waits 5 seconds
- Watir's `#click` waits 30 seconds

You should only need to wait when inspecting the element (rather than
taking a user action). For example, checking the element's text waits for
the element to exist, but not for it to be present. Keep in mind that you
would only need to wait if the thing you are inspecting would change based
on being hidden or not. #text can matter since it only shows visible text
nodes. Checking most attributes, ex #id, presumably wouldn't matter. In
general, the hope of Watir 6.0 is that you would rarely need to add the
waits.

Justin
Post by 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
"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
Post by NaviHan
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
NaviHan
2018-09-11 14:40:29 UTC
Permalink
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?
Post by NaviHan
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Titus Fortner
2018-09-11 16:10:14 UTC
Permalink
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.
Post by NaviHan
Hi Justin/Titus
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?
Post by NaviHan
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
NaviHan
2018-09-11 14:59:25 UTC
Permalink
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
Post by NaviHan
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
NaviHan
2018-09-12 04:49:36 UTC
Permalink
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
Post by NaviHan
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Titus Fortner
2018-09-12 15:25:27 UTC
Permalink
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?
Post by 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
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
Post by NaviHan
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
NaviHan
2018-09-13 03:19:11 UTC
Permalink
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
Post by NaviHan
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Titus Fortner
2018-09-13 05:21:24 UTC
Permalink
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.
Post by 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*
"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
Post by NaviHan
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 <element>.when_present, <element>.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.
http://groups.google.com/group/watir-general
---
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
For more options, visit https://groups.google.com/d/optout.
--
--
Before posting, please read https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
NaviHan
2018-09-13 05:46:26 UTC
Permalink
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
Post by NaviHan
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
rajagopalan madasami
2018-09-13 11:40:37 UTC
Permalink
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'}
Post by 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
Post by NaviHan
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 <element>.when_present, <element>.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.
http://groups.google.com/group/watir-general
---
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
For more options, visit https://groups.google.com/d/optout.
--
--
Before posting, please read https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Titus Fortner
2018-09-13 15:29:58 UTC
Permalink
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
Post by Justin Ko
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'}
Post by 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
Post by NaviHan
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 <element>.when_present, <element>.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.
http://groups.google.com/group/watir-general
---
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
For more options, visit https://groups.google.com/d/optout.
--
--
Before posting, please read https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
rajagopalan madasami
2018-09-13 16:57:21 UTC
Permalink
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.
Post by Titus Fortner
b.label(id: 'something').wait_until(text: 'Expected Text')
On Thursday, September 13, 2018 at 4:40:53 AM UTC-7, rajagopalan madasami
Post by Justin Ko
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'}
Post by 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
Post by NaviHan
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 <element>.when_present, <element>.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.
http://groups.google.com/group/watir-general
---
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
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.
http://groups.google.com/group/watir-general
---
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
For more options, visit https://groups.google.com/d/optout.
--
--
Before posting, please read https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Titus Fortner
2018-09-14 01:48:30 UTC
Permalink
6.14 was just released, hopefully it addresses your issues.
On Thu, Sep 13, 2018 at 9:57 AM 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.
Post by Titus Fortner
b.label(id: 'something').wait_until(text: 'Expected Text')
Post by Justin Ko
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'}
Post by 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
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 <element>.when_present, <element>.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.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google Groups "Watir General" group.
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.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google Groups "Watir General" group.
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.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google Groups "Watir General" group.
For more options, visit https://groups.google.com/d/optout.
--
--
Before posting, please read https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
rajagopalan madasami
2018-09-14 03:41:09 UTC
Permalink
Waiting for select list is added?
Post by Titus Fortner
6.14 was just released, hopefully it addresses your issues.
On Thu, Sep 13, 2018 at 9:57 AM rajagopalan madasami
Post by 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.
Post by rajagopalan madasami
Post by Titus Fortner
b.label(id: 'something').wait_until(text: 'Expected Text')
On Thursday, September 13, 2018 at 4:40:53 AM UTC-7, rajagopalan
Post by Justin Ko
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,
Post by rajagopalan madasami
Post by Titus Fortner
Post by Justin Ko
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
Post by rajagopalan madasami
Post by Titus Fortner
Post by Justin Ko
Or
b.label(id: 'something').wait_until{|element|
element.text.eql?'Expected Text'}
Post by rajagopalan madasami
Post by Titus Fortner
Post by Justin Ko
Post by 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?)
Post by rajagopalan madasami
Post by Titus Fortner
Post by Justin Ko
Post by NaviHan
Is that correct?
Cheers
Navi
Post by NaviHan
This is something that keeps me a bit sceptic when I write and read
the automation code in my project.
Post by rajagopalan madasami
Post by Titus Fortner
Post by Justin Ko
Post by NaviHan
Post by NaviHan
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
<element>.when_present, <element>.wait_until_present etc
Post by rajagopalan madasami
Post by Titus Fortner
Post by Justin Ko
Post by NaviHan
Post by NaviHan
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.
Post by rajagopalan madasami
Post by Titus Fortner
Post by Justin Ko
Post by NaviHan
Post by NaviHan
Any thoughts?
--
--
Before posting, please read
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group
.
Post by rajagopalan madasami
Post by Titus Fortner
Post by Justin Ko
Post by NaviHan
In short: search before you ask, be nice.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google
Groups "Watir General" group.
Post by rajagopalan madasami
Post by Titus Fortner
Post by Justin Ko
Post by NaviHan
To unsubscribe from this group and stop receiving emails from it,
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
.
Post by rajagopalan madasami
Post by Titus Fortner
In short: search before you ask, be nice.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google
Groups "Watir General" group.
Post by rajagopalan madasami
Post by Titus Fortner
To unsubscribe from this group and stop receiving emails from it, send
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
.
Post by rajagopalan madasami
In short: search before you ask, be nice.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google
Groups "Watir General" group.
Post by rajagopalan madasami
To unsubscribe from this group and stop receiving emails from it, send
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.
http://groups.google.com/group/watir-general
---
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
For more options, visit https://groups.google.com/d/optout.
--
--
Before posting, please read https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Titus Fortner
2018-09-14 03:50:43 UTC
Permalink
yes
On Thu, Sep 13, 2018 at 8:41 PM rajagopalan madasami
Post by rajagopalan madasami
Waiting for select list is added?
Post by Titus Fortner
6.14 was just released, hopefully it addresses your issues.
On Thu, Sep 13, 2018 at 9:57 AM 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.
Post by Titus Fortner
b.label(id: 'something').wait_until(text: 'Expected Text')
Post by Justin Ko
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'}
Post by 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
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 <element>.when_present, <element>.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.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google Groups "Watir General" group.
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.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google Groups "Watir General" group.
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.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google Groups "Watir General" group.
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.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google Groups "Watir General" group.
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.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google Groups "Watir General" group.
For more options, visit https://groups.google.com/d/optout.
--
--
Before posting, please read https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
rajagopalan madasami
2018-09-14 04:04:28 UTC
Permalink
Beautiful, thanks!
Post by Titus Fortner
yes
On Thu, Sep 13, 2018 at 8:41 PM rajagopalan madasami
Post by rajagopalan madasami
Waiting for select list is added?
Post by Titus Fortner
6.14 was just released, hopefully it addresses your issues.
On Thu, Sep 13, 2018 at 9:57 AM rajagopalan madasami
Post by 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.
Post by rajagopalan madasami
Post by Titus Fortner
Post by rajagopalan madasami
Post by Titus Fortner
b.label(id: 'something').wait_until(text: 'Expected Text')
On Thursday, September 13, 2018 at 4:40:53 AM UTC-7, rajagopalan
Post by Justin Ko
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,
Post by rajagopalan madasami
Post by Titus Fortner
Post by rajagopalan madasami
Post by Titus Fortner
Post by Justin Ko
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
Post by rajagopalan madasami
Post by Titus Fortner
Post by rajagopalan madasami
Post by Titus Fortner
Post by Justin Ko
Or
b.label(id: 'something').wait_until{|element|
element.text.eql?'Expected Text'}
Post by rajagopalan madasami
Post by Titus Fortner
Post by rajagopalan madasami
Post by Titus Fortner
Post by Justin Ko
Post by 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?)
Post by rajagopalan madasami
Post by Titus Fortner
Post by rajagopalan madasami
Post by Titus Fortner
Post by Justin Ko
Post by NaviHan
Is that correct?
Cheers
Navi
Post by NaviHan
This is something that keeps me a bit sceptic when I write and
read the automation code in my project.
Post by rajagopalan madasami
Post by Titus Fortner
Post by rajagopalan madasami
Post by Titus Fortner
Post by Justin Ko
Post by NaviHan
Post by NaviHan
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
<element>.when_present, <element>.wait_until_present etc
Post by rajagopalan madasami
Post by Titus Fortner
Post by rajagopalan madasami
Post by Titus Fortner
Post by Justin Ko
Post by NaviHan
Post by NaviHan
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.
Post by rajagopalan madasami
Post by Titus Fortner
Post by rajagopalan madasami
Post by Titus Fortner
Post by Justin Ko
Post by NaviHan
Post by NaviHan
Any thoughts?
--
--
Before posting, please read
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group
.
Post by rajagopalan madasami
Post by Titus Fortner
Post by rajagopalan madasami
Post by Titus Fortner
Post by Justin Ko
Post by NaviHan
In short: search before you ask, be nice.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google
Groups "Watir General" group.
Post by rajagopalan madasami
Post by Titus Fortner
Post by rajagopalan madasami
Post by Titus Fortner
Post by Justin Ko
Post by NaviHan
To unsubscribe from this group and stop receiving emails from it,
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
.
Post by rajagopalan madasami
Post by Titus Fortner
Post by rajagopalan madasami
Post by Titus Fortner
In short: search before you ask, be nice.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google
Groups "Watir General" group.
Post by rajagopalan madasami
Post by Titus Fortner
Post by rajagopalan madasami
Post by Titus Fortner
To unsubscribe from this group and stop receiving emails from it,
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
.
Post by rajagopalan madasami
Post by Titus Fortner
Post by rajagopalan madasami
In short: search before you ask, be nice.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google
Groups "Watir General" group.
Post by rajagopalan madasami
Post by Titus Fortner
Post by rajagopalan madasami
To unsubscribe from this group and stop receiving emails from it,
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
.
Post by rajagopalan madasami
Post by Titus Fortner
In short: search before you ask, be nice.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google
Groups "Watir General" group.
Post by rajagopalan madasami
Post by Titus Fortner
To unsubscribe from this group and stop receiving emails from it, send
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
.
Post by rajagopalan madasami
In short: search before you ask, be nice.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google
Groups "Watir General" group.
Post by rajagopalan madasami
To unsubscribe from this group and stop receiving emails from it, send
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.
http://groups.google.com/group/watir-general
---
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
For more options, visit https://groups.google.com/d/optout.
--
--
Before posting, please read https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Titus Fortner
2018-09-13 15:27:57 UTC
Permalink
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
Post by 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
Post by NaviHan
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
r***@gmail.com
2018-09-14 09:15:36 UTC
Permalink
I would like to say , this is such a perfect clarity! Yes this is the way
wait has to work.
Post by Titus Fortner
Ok, yes. This is a slight simplification, but think of Watir waiting for
what makes the most sense for the provided method.
1. Status Queries --> No automatic waits; immediate response or exception
#exists? / #visible? / #present? / #enabled?
2. Information Queries --> Automatically waits until exists in DOM
#text / #value / #tag_name / #style / #attribute_value etc
3. Actions --> Automatically waits until displayed to user
#click / #submit / #set / #clear / #select
Post by 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
Post by NaviHan
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
NaviHan
2018-09-13 21:22:00 UTC
Permalink
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, <div class="here">Foo</div> and you locate it with
code "element = browser.div(class: "here")"

Some dynamic event caused the element class to change: "<div
class="not-here">Foo</div>"

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
Post by NaviHan
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Titus Fortner
2018-09-13 21:35:35 UTC
Permalink
#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.
Post by 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, <div class="here">Foo</div> and you locate it with
code "element = browser.div(class: "here")"
Some dynamic event caused the element class to change: "<div
class="not-here">Foo</div>"
In this case we want the element to be looked up from scratch during the
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
Post by NaviHan
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
NaviHan
2018-09-13 21:39:50 UTC
Permalink
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?
Post by NaviHan
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Titus Fortner
2018-09-13 21:58:22 UTC
Permalink
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)
Post by 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?
Post by NaviHan
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
NaviHan
2018-09-13 23:33:27 UTC
Permalink
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
Post by NaviHan
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
rajagopalan madasami
2018-09-14 00:12:53 UTC
Permalink
It will wait until it changed from here to not here , thats all.
Post by NaviHan
Hi Titus
This statement
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
Post by NaviHan
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 <element>.when_present, <element>.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.
http://groups.google.com/group/watir-general
---
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
For more options, visit https://groups.google.com/d/optout.
--
--
Before posting, please read https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Titus Fortner
2018-09-14 00:23:06 UTC
Permalink
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.
Post by NaviHan
Hi Titus
This statement
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
Post by NaviHan
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
NaviHan
2018-09-14 00:45:36 UTC
Permalink
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"
Post by NaviHan
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Titus Fortner
2018-09-14 00:56:40 UTC
Permalink
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-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
NaviHan
2018-09-14 01:03:30 UTC
Permalink
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.. :-)
Post by NaviHan
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Titus Fortner
2018-09-14 01:24:11 UTC
Permalink
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-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
NaviHan
2018-09-14 01:33:28 UTC
Permalink
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
Post by NaviHan
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 <element>.when_present, <element>.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-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Titus Fortner
2018-09-14 01:41:09 UTC
Permalink
Glad I could help, but now I'm going to go refactor everything so it
will be less confusing going forward. :)
Post by 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
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 <element>.when_present, <element>.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.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google Groups "Watir General" group.
For more options, visit https://groups.google.com/d/optout.
--
--
Before posting, please read https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...