Discussion:
[wtr-general] Trouble Locating elements using PageObject
Navi
2018-07-03 10:58:09 UTC
Permalink
This is my first post here. Apologies if there is a mistake.

I have a section of a page as attached in the pic.


The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>

I need to assert two value here

1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"

The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.

I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"

I tried to capture this with the code
Enter code ***@var =
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")

This isnt working

Any clue?
--
--
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-07-03 12:06:15 UTC
Permalink
Hi All

In fact I nailed it in parts by using

div(:nav_div, class: "row applied-voucers-list")
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end


This gives me the first div.

But how do I access the second div using index parameter?
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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-07-03 12:16:55 UTC
Permalink
I will write in watir and then you may convert that code into your
pageobject code

p b.divs(class: "row applied-voucers-list").map {|div| div.div.span.text}




This will print two span text, look at carefully I used b.divs not b.div
Post by NaviHan
Hi All
In fact I nailed it in parts by using
div(:nav_div, class: "row applied-voucers-list")
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end
This gives me the first div.
But how do I access the second div using index parameter?
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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-07-03 12:18:14 UTC
Permalink
Ah sorry, I made a small mistake in last mail

Use this


p b.divs(class: "row applied-voucers-list".split).map {|div| div.div.span.
Post by NaviHan
text}
Hi All
In fact I nailed it in parts by using
div(:nav_div, class: "row applied-voucers-list")
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end
This gives me the first div.
But how do I access the second div using index parameter?
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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.
Navi
2018-07-03 12:21:16 UTC
Permalink
Thanks.
The query is posted in the group now.
https://groups.google.com/forum/#!topic/watir-general/mJ1IhrQWCxg

Hi Raja

In fact I nailed it in parts by using

div(:nav_div, class: "row applied-voucers-list")
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end


This gives me the first div.

But how do I access the second div using index parameter?

Cheers
Navi
Post by r***@gmail.com
Ah sorry, I made a small mistake in last mail
Use this
p b.divs(class: "row applied-voucers-list".split).map {|div| div.div.span.
Post by NaviHan
text}
Hi All
In fact I nailed it in parts by using
div(:nav_div, class: "row applied-voucers-list")
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end
This gives me the first div.
But how do I access the second div using index parameter?
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
ent.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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.
r***@gmail.com
2018-07-03 12:24:36 UTC
Permalink
What are you saying me? I gave you the answer, did you try?
Post by Navi
Thanks.
The query is posted in the group now.
https://groups.google.com/forum/#!topic/watir-general/mJ1IhrQWCxg
Hi Raja
In fact I nailed it in parts by using
div(:nav_div, class: "row applied-voucers-list")
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end
This gives me the first div.
But how do I access the second div using index parameter?
Cheers
Navi
Post by r***@gmail.com
Ah sorry, I made a small mistake in last mail
Use this
p b.divs(class: "row applied-voucers-list".split).map {|div| div.div.span
Post by r***@gmail.com
.text}
Hi All
In fact I nailed it in parts by using
div(:nav_div, class: "row applied-voucers-list")
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end
This gives me the first div.
But how do I access the second div using index parameter?
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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.
Navi
2018-07-03 12:27:32 UTC
Permalink
I would like to use the PageObject gem..
Post by r***@gmail.com
What are you saying me? I gave you the answer, did you try?
Post by Navi
Thanks.
The query is posted in the group now.
https://groups.google.com/forum/#!topic/watir-general/mJ1IhrQWCxg
Hi Raja
In fact I nailed it in parts by using
div(:nav_div, class: "row applied-voucers-list")
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end
This gives me the first div.
But how do I access the second div using index parameter?
Cheers
Navi
Post by r***@gmail.com
Ah sorry, I made a small mistake in last mail
Use this
p b.divs(class: "row applied-voucers-list".split).map {|div| div.div.
Post by r***@gmail.com
span.text}
Hi All
In fact I nailed it in parts by using
div(:nav_div, class: "row applied-voucers-list")
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end
This gives me the first div.
But how do I access the second div using index parameter?
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2
doesnt have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
ent.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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.
r***@gmail.com
2018-07-03 12:31:39 UTC
Permalink
I am not stopping you, I asked you to convert that into your model.
Post by Navi
I would like to use the PageObject gem..
Post by r***@gmail.com
What are you saying me? I gave you the answer, did you try?
Post by Navi
Thanks.
The query is posted in the group now.
https://groups.google.com/forum/#!topic/watir-general/mJ1IhrQWCxg
Hi Raja
In fact I nailed it in parts by using
div(:nav_div, class: "row applied-voucers-list")
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end
This gives me the first div.
But how do I access the second div using index parameter?
Cheers
Navi
Post by r***@gmail.com
Ah sorry, I made a small mistake in last mail
Use this
p b.divs(class: "row applied-voucers-list".split).map {|div| div.div.
Post by r***@gmail.com
span.text}
Hi All
In fact I nailed it in parts by using
div(:nav_div, class: "row applied-voucers-list")
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end
This gives me the first div.
But how do I access the second div using index parameter?
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2
doesnt have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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.
Navi
2018-07-03 12:38:50 UTC
Permalink
Will try that.

But how to use the index parameter. To explain further

Im defining the div element as

div(:nav_div, class: "row applied-voucers-list")

And the span element as

span (:applied_voucher) do |page|
page.nav_div_element.span_element
end

This gives the span element using default index of 0
How do I identify the second span element with index of 1?

Cheers
Post by r***@gmail.com
I am not stopping you, I asked you to convert that into your model.
Post by Navi
I would like to use the PageObject gem..
Post by r***@gmail.com
What are you saying me? I gave you the answer, did you try?
Post by Navi
Thanks.
The query is posted in the group now.
https://groups.google.com/forum/#!topic/watir-general/mJ1IhrQWCxg
Hi Raja
In fact I nailed it in parts by using
div(:nav_div, class: "row applied-voucers-list")
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end
This gives me the first div.
But how do I access the second div using index parameter?
Cheers
Navi
Post by r***@gmail.com
Ah sorry, I made a small mistake in last mail
Use this
p b.divs(class: "row applied-voucers-list".split).map {|div| div.div.
Post by r***@gmail.com
span.text}
Hi All
In fact I nailed it in parts by using
div(:nav_div, class: "row applied-voucers-list")
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end
This gives me the first div.
But how do I access the second div using index parameter?
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 &
9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2
doesnt have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].i
nnerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
ent.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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
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.
NaviHan
2018-07-03 12:49:56 UTC
Permalink
Here is a reference to where Im coming from
https://github.com/cheezy/page-object/wiki/Nested-Elements
Post by Navi
Will try that.
But how to use the index parameter. To explain further
Im defining the div element as
div(:nav_div, class: "row applied-voucers-list")
And the span element as
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end
This gives the span element using default index of 0
How do I identify the second span element with index of 1?
Cheers
Post by r***@gmail.com
I am not stopping you, I asked you to convert that into your model.
Post by Navi
I would like to use the PageObject gem..
Post by r***@gmail.com
What are you saying me? I gave you the answer, did you try?
Post by Navi
Thanks.
The query is posted in the group now.
https://groups.google.com/forum/#!topic/watir-general/mJ1IhrQWCxg
Hi Raja
In fact I nailed it in parts by using
div(:nav_div, class: "row applied-voucers-list")
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end
This gives me the first div.
But how do I access the second div using index parameter?
Cheers
Navi
Post by r***@gmail.com
Ah sorry, I made a small mistake in last mail
Use this
p b.divs(class: "row applied-voucers-list".split).map {|div| div.div.
Post by r***@gmail.com
span.text}
Hi All
In fact I nailed it in parts by using
div(:nav_div, class: "row applied-voucers-list")
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end
This gives me the first div.
But how do I access the second div using index parameter?
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 &
9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2
doesnt have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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,
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
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.
rajagopalan madasami
2018-07-03 13:00:40 UTC
Permalink
Kindly wait for sometime there is an another guy here named JustinKo, he
will come here soon he knows page object. If he doesn't come here please
post your question on stackoverflow he will surely answer. Sorry to say I
am not using Page object .
Post by NaviHan
Here is a reference to where Im coming from
https://github.com/cheezy/page-object/wiki/Nested-Elements
Post by Navi
Will try that.
But how to use the index parameter. To explain further
Im defining the div element as
div(:nav_div, class: "row applied-voucers-list")
And the span element as
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end
This gives the span element using default index of 0
How do I identify the second span element with index of 1?
Cheers
Post by r***@gmail.com
I am not stopping you, I asked you to convert that into your model.
Post by Navi
I would like to use the PageObject gem..
Post by r***@gmail.com
What are you saying me? I gave you the answer, did you try?
Post by Navi
Thanks.
The query is posted in the group now.
https://groups.google.com/forum/#!topic/watir-general/mJ1IhrQWCxg
Hi Raja
In fact I nailed it in parts by using
div(:nav_div, class: "row applied-voucers-list")
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end
This gives me the first div.
But how do I access the second div using index parameter?
Cheers
Navi
Post by r***@gmail.com
Ah sorry, I made a small mistake in last mail
Use this
p b.divs(class: "row applied-voucers-list".split).map {|div| div.div
Post by r***@gmail.com
.span.text}
Hi All
In fact I nailed it in parts by using
div(:nav_div, class: "row applied-voucers-list")
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end
This gives me the first div.
But how do I access the second div using index parameter?
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 &
9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2
doesnt have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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,
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
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
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-07-03 13:56:26 UTC
Permalink
Yes, how Page Object provides for the ability to manage dynamic references
is one of my major frustrations with the gem's API.

Firstly, Watir (and Page Object) allow you to pass in multiple parameters
in a hash format:
div(:nav_div, {class: 'applied-vouchers-list', index: 1})
nav_div_element

This can also be done with less hard coding using collections:
divs(:nav_divs, {class: 'applied-vouchers-list')
nav_divs_element[1]

Note that you can't put multiple classes (space separated values) into the
class locator, without using an array.

What it appears you actually want is to find if a specific value is
present, though, which is poorly suited for hard coding an element in the
PO gem. So I'd recommend creating a separate method for it:

def code_removable?(id)
button_element(data_gift_id: id)
el.exists? && el.parent.text == 'Remove'
end
Post by NaviHan
Hi All
In fact I nailed it in parts by using
div(:nav_div, class: "row applied-voucers-list")
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end
This gives me the first div.
But how do I access the second div using index parameter?
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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-07-03 15:14:13 UTC
Permalink
Hi Titus

Tried this

Enter code here...divs(:nav_divs, class: "row applied-voucers-list")

and

Enter code ***@voucher_val = Watir::Wait.until {nav_divs_element[index].
span_element}.attribute_value("innerText")

index = 0 as passed by the caller

However Im getting the error
Enter code here...NoMethodError: undefined method `nav_divs_element' for
#<Watir::Browser:0x0000000005b407f8>


Any clue?
Post by Titus Fortner
Yes, how Page Object provides for the ability to manage dynamic references
is one of my major frustrations with the gem's API.
Firstly, Watir (and Page Object) allow you to pass in multiple parameters
div(:nav_div, {class: 'applied-vouchers-list', index: 1})
nav_div_element
divs(:nav_divs, {class: 'applied-vouchers-list')
nav_divs_element[1]
Note that you can't put multiple classes (space separated values) into the
class locator, without using an array.
What it appears you actually want is to find if a specific value is
present, though, which is poorly suited for hard coding an element in the
def code_removable?(id)
button_element(data_gift_id: id)
el.exists? && el.parent.text == 'Remove'
end
Post by NaviHan
Hi All
In fact I nailed it in parts by using
div(:nav_div, class: "row applied-voucers-list")
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end
This gives me the first div.
But how do I access the second div using index parameter?
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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-07-03 15:25:14 UTC
Permalink
Yeah, wow, your code is kind of all over the place. What are you actually
trying to do?

Notes:
1. Don't use multiple classes as a string value in a class locator
2. innerText isn't an attribute
3. did you include PageObject module?
4. Did you define `nav_divs`?
5. Using `Watir::Wait` directly is not recommended
6. Ugh, PO gem makes all of this so much harder than it needs to be
Post by NaviHan
Hi Titus
Tried this
Enter code here...divs(:nav_divs, class: "row applied-voucers-list")
and
].span_element}.attribute_value("innerText")
index = 0 as passed by the caller
However Im getting the error
Enter code here...NoMethodError: undefined method `nav_divs_element' for
#<Watir::Browser:0x0000000005b407f8>
Any clue?
Post by Titus Fortner
Yes, how Page Object provides for the ability to manage dynamic
references is one of my major frustrations with the gem's API.
Firstly, Watir (and Page Object) allow you to pass in multiple parameters
div(:nav_div, {class: 'applied-vouchers-list', index: 1})
nav_div_element
divs(:nav_divs, {class: 'applied-vouchers-list')
nav_divs_element[1]
Note that you can't put multiple classes (space separated values) into
the class locator, without using an array.
What it appears you actually want is to find if a specific value is
present, though, which is poorly suited for hard coding an element in the
def code_removable?(id)
button_element(data_gift_id: id)
el.exists? && el.parent.text == 'Remove'
end
Post by NaviHan
Hi All
In fact I nailed it in parts by using
div(:nav_div, class: "row applied-voucers-list")
span (:applied_voucher) do |page|
page.nav_div_element.span_element
end
This gives me the first div.
But how do I access the second div using index parameter?
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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-07-03 23:41:19 UTC
Permalink
Hi Titus

I have declared the element as

divs(:nav_divs, class: "row applied-voucers-list")



and accessing span as

nav_divs_element[index].span_element

index = 0

Error is

NoMethodError: undefined method `nav_divs_element' for
#<Watir::Browser:0x000000000537f5c8>
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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-07-04 00:30:38 UTC
Permalink
Hi Titus

Job done. used "elements" instead of "element" as below.

nav_divs_elements[index].span_element

Thanks a million
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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-07-10 06:54:01 UTC
Permalink
Hi Titus

I have got a related query

I have a section of page
<div class="perk-validation-error">
<div class="close-button close-button-icon">
<span class="icon icon-cross-standard-small-black"></span>
</div>
<div class="error-msg small-text-center">
<span>Sorry, your Perks Payday Voucher will be removed if you
proceed to checkout</span>
<p>This reward is only available on orders AUD 10.00 and over.</p>
</div>
</div>

If I define the outer div as div (:minimum_spend_threshold_error, :class =>
'perk-validation-error'), how do I access the first span and second span?

Thanks in advance
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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-07-10 17:49:12 UTC
Permalink
Hi,

Accessing the spans within minimum_spend_threshold_error would be similar
to what you did with nav_div_elements:

page.minimum_spend_threshold_error_element.span_elements[0].html
#=> "<span class=\"icon icon-cross-standard-small-black\"></span>"

page.minimum_spend_threshold_error_element.span_elements[1].html
#=> "<span>Sorry, your Perks Payday Voucher will be removed if you proceed
to checkout</span>"

You could also define them in the page object to make the usage easier:

class MyPage
include PageObject

div(:minimum_spend_threshold_error, :class => 'perk-validation-error')
div(:first_span) { minimum_spend_threshold_error_element.span_elements[0]
}
div(:second_span) { minimum_spend_threshold_error_element.span_elements[1]
}
end

page.first_span_element.html
#=> "<span class=\"icon icon-cross-standard-small-black\"></span>"

page.second_span_element.html
#=> "<span>Sorry, your Perks Payday Voucher will be removed if you proceed
to checkout</span>"

Hope that helps,
Justin
Post by NaviHan
Hi Titus
I have got a related query
I have a section of page
<div class="perk-validation-error">
<div class="close-button close-button-icon">
<span class="icon icon-cross-standard-small-black"></span>
</div>
<div class="error-msg small-text-center">
<span>Sorry, your Perks Payday Voucher will be removed if you
proceed to checkout</span>
<p>This reward is only available on orders AUD 10.00 and over.</p>
</div>
</div>
If I define the outer div as div (:minimum_spend_threshold_error, :class
=> 'perk-validation-error'), how do I access the first span and second span?
Thanks in advance
--
--
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-07-11 03:48:56 UTC
Permalink
Hi Justin

That worked like a charm. PageObject gem is amazing :-)
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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-07-11 09:49:41 UTC
Permalink
Hi Justin/Titus

Facing another challenge here.

I have a section of a page with multiple outer div which has lots of inner
divs/spans etc of which Im interested in a select with an attribute named
"data-product-id" which has a specific value.

<div class="row cart-product-row ">
----
----
----
<select class="input-select has-value custom-input valid" id=
"dwfrm_cart_shipments_i0_items_i0_quantity" name=
"dwfrm_cart_shipments_i0_items_i0_quantity" data-product-id="9350486558733"
data-item-position="1" aria-invalid="false">
<option value="1" selected="selected">1</option>

<option value="2">2</option>

<option value="3">3</option>

<option value="4">4</option>

<option value="5">5</option>

<option value="6">6</option>

<option value="7">7</option>

<option value="8">8</option>

<option value="9">9</option>

<option value="10">10</option>

<div class="row cart-product-row ">
----
----
----
<select class="input-select has-value custom-input valid" id=
"dwfrm_cart_shipments_i0_items_i0_quantity" name=
"dwfrm_cart_shipments_i0_items_i0_quantity" data-product-id="9350486558734"
data-item-position="1" aria-invalid="false">
<option value="1" selected="selected">1</option>

<option value="2">2</option>

<option value="3">3</option>

<option value="4">4</option>

<option value="5">5</option>

<option value="6">6</option>

<option value="7">7</option>

<option value="8">8</option>

<option value="9">9</option>

<option value="10">10</option>

<div class="row cart-product-row ">
----
----
----
<select class="input-select has-value custom-input valid" id=
"dwfrm_cart_shipments_i0_items_i0_quantity" name=
"dwfrm_cart_shipments_i0_items_i0_quantity" data-product-id="9350486558735"
data-item-position="1" aria-invalid="false">
<option value="1" selected="selected">1</option>

<option value="2">2</option>

<option value="3">3</option>

<option value="4">4</option>

<option value="5">5</option>

<option value="6">6</option>

<option value="7">7</option>

<option value="8">8</option>

<option value="9">9</option>

<option value="10">10</option>



My requirement is to find the select element with a particular value of
"data-product-id" attribute and set it to say 2

Any clue on how to achieve this?
Post by NaviHan
Hi Justin
That worked like a charm. PageObject gem is amazing :-)
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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-07-11 09:58:30 UTC
Permalink
I tried this way. but got error

ArgumentError: wrong number of arguments (given 1, expected 0)

elements(:product_line_items_in_bag, :name => 'dwfrm_cart_shipments')
product_line_items_in_bag_elements(:"data-product-id" => '9350486827327').set(2)
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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-07-11 10:22:20 UTC
Permalink
Hi Justin/Titus

There is a correction in the html code

<div class="row cart-product-row ">
----
----
----
<select class="input-select has-value custom-input valid"
id="dwfrm_cart_shipments_i0_items_i0_quantity"
name="dwfrm_cart_shipments_i0_items_i0_quantity"
data-product-id="9350486558733" data-item-position="1" aria-invalid="false">


<option value="2">2</option>

<option value="3">3</option>

<option value="4">4</option>

<option value="5">5</option>

<option value="6">6</option>

<option value="7">7</option>

<option value="8">8</option>

<option value="9">9</option>

<option value="10">10</option>

<div class="row cart-product-row ">
----
----
----
<select class="input-select has-value custom-input"
id="dwfrm_cart_shipments_i0_items_i1_quantity"
name="dwfrm_cart_shipments_i0_items_i1_quantity"
data-product-id="9351533670743" data-item-position="2">


<option value="2">2</option>

<option value="3">3</option>

<option value="4">4</option>

<option value="5">5</option>

<option value="6">6</option>

<option value="7">7</option>

<option value="8">8</option>

<option value="9">9</option>

<option value="10">10</option>

<div class="row cart-product-row ">
----
----
----
<select class="input-select has-value custom-input valid"
id="dwfrm_cart_shipments_i0_items_i2_quantity"
name="dwfrm_cart_shipments_i0_items_i2_quantity"
data-product-id="9351533671290" data-item-position="3" aria-invalid="false">


<option value="2">2</option>

<option value="3">3</option>

<option value="4">4</option>

<option value="5">5</option>

<option value="6">6</option>

<option value="7">7</option>

<option value="8">8</option>

<option value="9">9</option>

<option value="10">10</option>
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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-07-11 18:13:21 UTC
Permalink
The accessors do not provide a mechanism for filtering the element
collection. In other words, the exception is from
`product_line_items_in_bag_elements(:"data-product-id" => '9350486827327')`.

You can filter the elements manually using `#find`:

class MyPage
include PageObject

elements(:product_line_items_in_bag, :name => /^dwfrm_cart_shipments/) #
note that you need a regex here
end

page = MyPage.new(browser)
products = page.product_line_items_in_bag_elements
product = products.find { |e| e.data_product_id == '9351533670743' }
product.select('2')

However, it'd be easier to skip the accessor and define a method. This
allows locating the select list directly, which can save execution time.

class MyPage
include PageObject

def product_element(product_id)
browser.select_list(data_product_id: product_id)
end
end

Justin
Post by NaviHan
Hi Justin/Titus
There is a correction in the html code
<div class="row cart-product-row ">
----
----
----
<select class="input-select has-value custom-input valid"
id="dwfrm_cart_shipments_i0_items_i0_quantity"
name="dwfrm_cart_shipments_i0_items_i0_quantity"
data-product-id="9350486558733" data-item-position="1" aria-invalid="false">
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<div class="row cart-product-row ">
----
----
----
<select class="input-select has-value custom-input"
id="dwfrm_cart_shipments_i0_items_i1_quantity"
name="dwfrm_cart_shipments_i0_items_i1_quantity"
data-product-id="9351533670743" data-item-position="2">
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<div class="row cart-product-row ">
----
----
----
<select class="input-select has-value custom-input valid"
id="dwfrm_cart_shipments_i0_items_i2_quantity"
name="dwfrm_cart_shipments_i0_items_i2_quantity"
data-product-id="9351533671290" data-item-position="3" aria-invalid="false">
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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-07-11 18:17:48 UTC
Permalink
Hey Justin, tell me what else you do not know in automation? You are
awesome dude! Thanks for contributing all your knowledge to WATIR.
Post by Justin Ko
The accessors do not provide a mechanism for filtering the element
collection. In other words, the exception is from
`product_line_items_in_bag_elements(:"data-product-id" => '9350486827327')`.
class MyPage
include PageObject
elements(:product_line_items_in_bag, :name => /^dwfrm_cart_shipments/) #
note that you need a regex here
end
page = MyPage.new(browser)
products = page.product_line_items_in_bag_elements
product = products.find { |e| e.data_product_id == '9351533670743' }
product.select('2')
However, it'd be easier to skip the accessor and define a method. This
allows locating the select list directly, which can save execution time.
class MyPage
include PageObject
def product_element(product_id)
browser.select_list(data_product_id: product_id)
end
end
Justin
Post by NaviHan
Hi Justin/Titus
There is a correction in the html code
<div class="row cart-product-row ">
----
----
----
<select class="input-select has-value custom-input valid"
id="dwfrm_cart_shipments_i0_items_i0_quantity"
name="dwfrm_cart_shipments_i0_items_i0_quantity"
data-product-id="9350486558733" data-item-position="1" aria-invalid="false">
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<div class="row cart-product-row ">
----
----
----
<select class="input-select has-value custom-input"
id="dwfrm_cart_shipments_i0_items_i1_quantity"
name="dwfrm_cart_shipments_i0_items_i1_quantity"
data-product-id="9351533670743" data-item-position="2">
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<div class="row cart-product-row ">
----
----
----
<select class="input-select has-value custom-input valid"
id="dwfrm_cart_shipments_i0_items_i2_quantity"
name="dwfrm_cart_shipments_i0_items_i2_quantity"
data-product-id="9351533671290" data-item-position="3" aria-invalid="false">
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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-07-12 15:06:32 UTC
Permalink
Thanks a lot Justin. Your knowledge of PageObject gem is amazing. Hats Off
to 'cheezy' too.

I have a few clarifications.

1. Just like we do plural for div, I mean divs, isnt there plural version
for select_list i:e select_lists? Similarly buttons?
How do we know if there is a plural version at all. I couldn't find the
documentation.

2. If two elements have the same attribute, for example say there are
multiple divs and multiple select lists with class name starting with "dwfrm_cart_shipments"
and if we define the object as below

elements(:product_line_items_in_bag, :name => /^dwfrm_cart_shipments/)

Does this identify both the divs and the select_lists.
And later we pass this to a block and filter the specific element by a
specific attribute. (Like you identified the select_list with attribute "
data_product_id"

3. With the attribute "data_product_id", is there a reason you have used
underscore(_) instead of hyphens (-)

4. Could you please explain the use of "map(&:text)" called on elements?

Thanks in advance
Post by Justin Ko
The accessors do not provide a mechanism for filtering the element
collection. In other words, the exception is from
`product_line_items_in_bag_elements(:"data-product-id" => '9350486827327')`.
class MyPage
include PageObject
elements(:product_line_items_in_bag, :name => /^dwfrm_cart_shipments/) #
note that you need a regex here
end
page = MyPage.new(browser)
products = page.product_line_items_in_bag_elements
product = products.find { |e| e.data_product_id == '9351533670743' }
product.select('2')
However, it'd be easier to skip the accessor and define a method. This
allows locating the select list directly, which can save execution time.
class MyPage
include PageObject
def product_element(product_id)
browser.select_list(data_product_id: product_id)
end
end
Justin
Post by NaviHan
Hi Justin/Titus
There is a correction in the html code
<div class="row cart-product-row ">
----
----
----
<select class="input-select has-value custom-input valid"
id="dwfrm_cart_shipments_i0_items_i0_quantity"
name="dwfrm_cart_shipments_i0_items_i0_quantity"
data-product-id="9350486558733" data-item-position="1" aria-invalid="false">
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<div class="row cart-product-row ">
----
----
----
<select class="input-select has-value custom-input"
id="dwfrm_cart_shipments_i0_items_i1_quantity"
name="dwfrm_cart_shipments_i0_items_i1_quantity"
data-product-id="9351533670743" data-item-position="2">
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<div class="row cart-product-row ">
----
----
----
<select class="input-select has-value custom-input valid"
id="dwfrm_cart_shipments_i0_items_i2_quantity"
name="dwfrm_cart_shipments_i0_items_i2_quantity"
data-product-id="9351533671290" data-item-position="3" aria-invalid="false">
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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-07-12 19:20:44 UTC
Permalink
Post by NaviHan
1. Just like we do plural for div, I mean divs, isnt there plural version
for select_list i:e select_lists? Similarly buttons?
How do we know if there is a plural version at all. I couldn't find
the documentation.
The plural version `#select_lists` does exist. I don't think there is any
up-to-date documentation for the list of accessors, but I believe the
plural version is always defined. You can see what is defined in the
Accessors module - `#select_lists` is dynamically defined at the end of the
module
(https://github.com/cheezy/page-object/blob/master/lib/page-object/accessors.rb#L1162-L1172).
Post by NaviHan
2. If two elements have the same attribute, for example say there are
multiple divs and multiple select lists with class name starting with "dwfrm_cart_shipments"
and if we define the object as below
elements(:product_line_items_in_bag, :name => /^dwfrm_cart_shipments/)
Does this identify both the divs and the select_lists.
And later we pass this to a block and filter the specific element by a
specific attribute. (Like you identified the select_list with attribute "
data_product_id"
Yes, `#elements` will include all tag types - ie you'll have a collection
of divs and selects. If you know you only want a specific tag, you should
use that respective method.
Post by NaviHan
3. With the attribute "data_product_id", is there a reason you have used
underscore(_) instead of hyphens (-)
Hyphens are not valid characters in method and symbol names. As a result,
Watir chose to use underscores. Watir will switch all of the underscores to
hypens when looking up the attribute value.
Post by NaviHan
4. Could you please explain the use of "map(&:text)" called on elements?
`elements.map(&:text)` will return an Array containing the text of each
element. It's equivalent to:
texts = []
elements.each { |e| texts << e.text }

Justin
--
--
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-07-23 07:00:17 UTC
Permalink
Having yet another roadblock wrt Watir/PageObject gem automation

Im having a parent unordered list with child list elements and child links
as shown below
<ul class="swatches online size open row small-up-3 large-up-4 xlarge-up-4
xxlarge-up-5 columns" data-tooltip="" aria-haspopup="true"
data-disable-hover="true" tabindex="1" title="Please select a size">

<li class="unselectable column">

<a class="swatchanchor value-cont" title="undefined
XXS is not available for this combination">
<span class="swatchanchor-value">XXS</span>
</a>

</li>

<li class="selectable column">

<a class="swatchanchor value-cont" href=
"http://ci.cottonon.com/AU/show-variation/?pid=2003013&amp;dwvar_2003013_size=XS"
title="Select Size: XS" data-attribute-type="size" data-size="XS">
<span class="swatchanchor-value">XS</span>
</a>

</li>

<li class="selectable selected column">

<a class="swatchanchor value-cont" href=
"http://ci.cottonon.com/AU/show-variation/?pid=2003013" title="Select Size:
S" data-attribute-type="size" data-size="S">
<span class="swatchanchor-value">S</span>
</a>

</li>

<li class="selectable column">

<a class="swatchanchor value-cont" href=
"http://ci.cottonon.com/AU/show-variation/?pid=2003013&amp;dwvar_2003013_size=M"
title="Select Size: M" data-attribute-type="size" data-size="M">
<span class="swatchanchor-value">M</span>
</a>

</li>

<li class="selectable column">

<a class="swatchanchor value-cont" href=
"http://ci.cottonon.com/AU/show-variation/?pid=2003013&amp;dwvar_2003013_size=L"
title="Select Size: L" data-attribute-type="size" data-size="L">
<span class="swatchanchor-value">L</span>
</a>

</li>

<li class="unselectable column">

<a class="swatchanchor value-cont" title="undefined
XL is not available for this combination">
<span class="swatchanchor-value">XL</span>
</a>

</li>

<li class="unselectable column">

<a class="swatchanchor value-cont" title="undefined
XXL is not available for this combination">
<span class="swatchanchor-value">XXL</span>
</a>

</li>

</ul>

The unordered list is defined as

unordered_list(:sizes, :class => /swatches online/)

On the page object class I have a method defined as below which basically
gets the nth selected list element and clicks it.
def select_size (size_position)
count = 0
sizes_element.list_items.map do |el|
if (el.attribute('class') =~ /^selectable/)
count = count +1
if (count == size_position)
sleep 5
el.a.wait_while_present.click
end
end
end
end

Without wait_while_present the script was complaing "Element is not
clickable due to another element that would receive the click", hence I put
the wait.
When the script runs this gives me an error
Watir::Wait::TimeoutError: timed out after 30 seconds, waiting for false
condition on #<Watir::Anchor: located: false; {:class=>/swatches online/,
:tag_name=>"ul"} --> {:tag_name=>"li", :adjacent=>:child, :index=>1} -->
{:tag_name=>"a"}>

Any clue?
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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-07-23 07:12:13 UTC
Permalink
Having yet another roadblock wrt Watir/PageObject gem automation
Im having a parent unordered list with child list elements and child links
as shown below

<ul class="swatches online size open row small-up-3 large-up-4 xlarge-up-4
xxlarge-up-5 columns" data-tooltip="" aria-haspopup="true"
data-disable-hover="true" tabindex="1" title="Please select a size">

<li class="unselectable column">

<a class="swatchanchor value-cont"
title="undefined XXS is not available for this combination">
<span class="swatchanchor-value">XXS</span>
</a>

</li>

<li class="selectable column">

<a class="swatchanchor value-cont"
href="/AU/show-variation/?pid=2003013&amp;dwvar_2003013_size=XS"
title="Select Size: XS" data-attribute-type="size" data-size="XS">
<span class="swatchanchor-value">XS</span>
</a>

</li>

<li class="selectable selected column">

<a class="swatchanchor value-cont"
href="/AU/show-variation/?pid=2003013" title="Select Size: S"
data-attribute-type="size" data-size="S">
<span class="swatchanchor-value">S</span>
</a>

</li>

<li class="selectable column">

<a class="swatchanchor value-cont"
href="/AU/show-variation/?pid=2003013&amp;dwvar_2003013_size=M"
title="Select Size: M" data-attribute-type="size" data-size="M">
<span class="swatchanchor-value">M</span>
</a>

</li>

<li class="selectable column">

<a class="swatchanchor value-cont"
href="/AU/show-variation/?pid=2003013&amp;dwvar_2003013_size=L"
title="Select Size: L" data-attribute-type="size" data-size="L">
<span class="swatchanchor-value">L</span>
</a>

</li>

<li class="unselectable column">

<a class="swatchanchor value-cont"
title="undefined XL is not available for this combination">
<span class="swatchanchor-value">XL</span>
</a>

</li>

<li class="unselectable column">

<a class="swatchanchor value-cont"
title="undefined XXL is not available for this combination">
<span class="swatchanchor-value">XXL</span>
</a>

</li>

</ul>


The unordered list is defined as

unordered_list(:sizes, :class => /swatches online/)


On the page object class I have a method defined as below which basically
gets the nth selected list element and clicks it.
def select_size (size_position)
count = 0
sizes_element.list_items.map do |el|
if (el.attribute('class') =~ /^selectable/)
count = count +1
if (count == size_position)
sleep 5
el.a.wait_while_present.click
end
end
end
end


Without wait_while_present the script was complaing "Element is not
clickable due to another element that would receive the click", hence I put
the wait.
When the script runs this gives me an error

Watir::Wait::TimeoutError: timed out after 30 seconds, waiting for false
condition on #<Watir::Anchor: located: false; {:class=>/swatches online/,
:tag_name=>"ul"} --> {:tag_name=>"li", :adjacent=>:child, :index=>1} -->
{:tag_name=>"a"}>


Any clue?
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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-07-23 11:04:09 UTC
Permalink
Made a slight modification in method "select_size (size_position)"

el.link_element.when_visible.click


This gives me the error
Selenium::WebDriver::Error::UnknownError: unknown error: Element <a
class="swatchanchor value-cont"
href="https://ci.cottonon.com/AU/show-variation/?dwvar_2003013_color=2003013-05&amp;pid=2003013&amp;dwvar_2003013_size=XS&amp;originalPid=2003013-05"
title="Select Size: XS" data-attribute-type="size" data-size="XS">...</a>
is not clickable at point (659, 593). Other element would receive the
click: <div id="feedback-row" class="small-12 large-4 xlarge-5"
data-sticky-container="">...</div>
(Session info: chrome=67.0.3396.99)
(Driver info: chromedriver=2.36.540470
(e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 6.1.7601 SP1
x86_64)
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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-07-23 11:25:11 UTC
Permalink
Put a debugger point in this line, once program reaches this line, wait for
sometime and execute it, if it works fine, then you can rescue the
exception ElementClickInterceptedError, this is possible only if you run in
Firefox because Chrome is not having this Exception.
Post by NaviHan
Made a slight modification in method "select_size (size_position)"
el.link_element.when_visible.click
This gives me the error
Selenium::WebDriver::Error::UnknownError: unknown error: Element <a
class="swatchanchor value-cont" href="
https://ci.cottonon.com/AU/show-variation/?dwvar_2003013_color=2003013-05&amp;pid=2003013&amp;dwvar_2003013_size=XS&amp;originalPid=2003013-05"
title="Select Size: XS" data-attribute-type="size" data-size="XS">...</a>
is not clickable at point (659, 593). Other element would receive the
click: <div id="feedback-row" class="small-12 large-4 xlarge-5"
data-sticky-container="">...</div>
(Session info: chrome=67.0.3396.99)
(Driver info: chromedriver=2.36.540470
(e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 6.1.7601 SP1
x86_64)
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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-07-24 04:59:32 UTC
Permalink
Luckily I found the issue with the below problem. There was a small popup
that showed up on the page, once I dismiss that Im able to successfully
click the link

Used the call:-)

el.link_element}.click

Enter code here...
Post by Navi
This is my first post here. Apologies if there is a mistake.
I have a section of a page as attached in the pic.
The html code for the section is as follows
Enter code here...<div class="small-12 applied-evouchers">
<div class="row applied-voucers-list">
<div class="small-6">
<span>9830318220466018</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9830318220466018">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
<div class="row applied-voucers-list">
<div class="small-6">
<span>9831228610400260</span>
</div>
<div class="small-6 small-text-right">
<button type="button" class="remove-gift-cert"
data-gift-id="9831228610400260">
<span class="icon icon-cross-standard-small-black"></span>
<span class="underline remove-evoucher-button-text">Remove</span>
</button>
</div>
</div>
<hr>
</div>
I need to assert two value here
1. The vouchers applied, which are 9830318220466018 & 9831228610400260
2. The span "Remove"
The issue Im facing is as these two divs are identical and 1 & 2 doesnt
have a unique identifier I cannt locate them using PageObjects.
I can locate the element using the following Java script
document.getElementsByClassName('applied-voucers-list')[0].innerText;
This returns
Enter code here..."9830318220466018
Remove
"
I tried to capture this with the code
@browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
This isnt working
Any clue?
--
--
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...