[wtr-general] Re: Trouble Locating elements using PageObject

2018-07-23 Thread NaviHan
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...



On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>
> 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...
> 
> 
> 9830318220466018
> 
>  
>  data-gift-id="9830318220466018">
> 
> Remove
> 
> 
> 
> 
> 
> 
> 9831228610400260
> 
>  
>  data-gift-id="9831228610400260">
> 
> Remove
> 
> 
> 
> 
> 
>
> 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 here...@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-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [wtr-general] Re: Trouble Locating elements using PageObject

2018-07-23 Thread rajagopalan madasami
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.

On Mon 23 Jul, 2018, 4:34 PM NaviHan,  wrote:

> 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  class="swatchanchor value-cont" href="
> https://ci.cottonon.com/AU/show-variation/?dwvar_2003013_color=2003013-05pid=2003013dwvar_2003013_size=XSoriginalPid=2003013-05;
> title="Select Size: XS" data-attribute-type="size" data-size="XS">...
> is not clickable at point (659, 593). Other element would receive the
> click:  data-sticky-container="">...
>   (Session info: chrome=67.0.3396.99)
>   (Driver info: chromedriver=2.36.540470
> (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 6.1.7601 SP1
> x86_64)
>
>
>
> On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>>
>> 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...
>> 
>> 
>> 9830318220466018
>> 
>> 
>> > data-gift-id="9830318220466018">
>> 
>> Remove
>> 
>> 
>> 
>> 
>> 
>> 
>> 9831228610400260
>> 
>> 
>> > data-gift-id="9831228610400260">
>> 
>> Remove
>> 
>> 
>> 
>> 
>> 
>>
>> 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 here...@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-general@googlegroups.com
> http://groups.google.com/group/watir-general
> watir-general+unsubscr...@googlegroups.com
> ---
> You received this message because you are subscribed to the Google Groups
> "Watir General" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to watir-general+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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

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


[wtr-general] Re: Trouble Locating elements using PageObject

2018-07-23 Thread NaviHan
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





XXS






http://ci.cottonon.com/AU/show-variation/?pid=2003013dwvar_2003013_size=XS;
 
title="Select Size: XS" data-attribute-type="size" data-size="XS">
XS






http://ci.cottonon.com/AU/show-variation/?pid=2003013; title="Select Size: 
S" data-attribute-type="size" data-size="S">
S






http://ci.cottonon.com/AU/show-variation/?pid=2003013dwvar_2003013_size=M;
 
title="Select Size: M" data-attribute-type="size" data-size="M">
M






http://ci.cottonon.com/AU/show-variation/?pid=2003013dwvar_2003013_size=L;
 
title="Select Size: L" data-attribute-type="size" data-size="L">
L







XL







XXL






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 #/swatches online/, 
:tag_name=>"ul"} --> {:tag_name=>"li", :adjacent=>:child, :index=>1} --> 
{:tag_name=>"a"}>

Any clue?


On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>
> 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...
> 
> 
> 9830318220466018
> 
>  
>  data-gift-id="9830318220466018">
> 
> Remove
> 
> 
> 
> 
> 
> 
> 9831228610400260
> 
>  
>  data-gift-id="9831228610400260">
> 
> Remove
> 
> 
> 
> 
> 
>
> 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 here...@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-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Trouble Locating elements using PageObject

2018-07-12 Thread Justin Ko

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

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

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

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


[wtr-general] Re: Trouble Locating elements using PageObject

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

On Thursday, 12 July 2018 04:13:21 UTC+10, Justin Ko wrote:
>
> 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
>
>
> On Wednesday, July 11, 2018 at 6:22:20 AM UTC-4, NaviHan wrote:
>>
>> Hi Justin/Titus
>>
>> There is a correction in the html code
>>
>> 
>> 
>> 
>> 
>> > 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">
>>
>>
>> 2
>>
>> 3
>>
>> 4
>>
>> 5
>>
>> 6
>>
>> 7
>>
>> 8
>>
>> 9
>>
>> 10
>>
>> 
>> 
>> 
>> 
>> > id="dwfrm_cart_shipments_i0_items_i1_quantity" 
>> name="dwfrm_cart_shipments_i0_items_i1_quantity" 
>> data-product-id="9351533670743" data-item-position="2">
>>
>>
>> 2
>>
>> 3
>>
>> 4
>>
>> 5
>>
>> 6
>>
>> 7
>>
>> 8
>>
>> 9
>>
>> 10
>>
>> 
>> 
>> 
>> 
>> > 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">
>>
>>
>> 2
>>
>> 3
>>
>> 4
>>
>> 5
>>
>> 6
>>
>> 7
>>
>> 8
>>
>> 9
>>
>> 10
>>
>>
>>
>> On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>>>
>>> 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...
>>> 
>>> 
>>> 9830318220466018
>>> 
>>>  
>>> >> data-gift-id="9830318220466018">
>>> 
>>> Remove
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 9831228610400260
>>> 
>>>  
>>> >> data-gift-id="9831228610400260">
>>> 
>>> Remove
>>> 
>>> 
>>> 
>>> 
>>> 
>>>
>>> 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 here...@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-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [wtr-general] Re: Trouble Locating elements using PageObject

2018-07-11 Thread rajagopalan madasami
Hey Justin, tell me what else you do not know in automation? You are
awesome dude! Thanks for contributing all your knowledge to WATIR.

On Wed 11 Jul, 2018, 11:43 PM Justin Ko,  wrote:

> 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
>
>
> On Wednesday, July 11, 2018 at 6:22:20 AM UTC-4, NaviHan wrote:
>>
>> Hi Justin/Titus
>>
>> There is a correction in the html code
>>
>> 
>> 
>> 
>> 
>> > 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">
>>
>>
>> 2
>>
>> 3
>>
>> 4
>>
>> 5
>>
>> 6
>>
>> 7
>>
>> 8
>>
>> 9
>>
>> 10
>>
>> 
>> 
>> 
>> 
>> > id="dwfrm_cart_shipments_i0_items_i1_quantity"
>> name="dwfrm_cart_shipments_i0_items_i1_quantity"
>> data-product-id="9351533670743" data-item-position="2">
>>
>>
>> 2
>>
>> 3
>>
>> 4
>>
>> 5
>>
>> 6
>>
>> 7
>>
>> 8
>>
>> 9
>>
>> 10
>>
>> 
>> 
>> 
>> 
>> > 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">
>>
>>
>> 2
>>
>> 3
>>
>> 4
>>
>> 5
>>
>> 6
>>
>> 7
>>
>> 8
>>
>> 9
>>
>> 10
>>
>>
>>
>> On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>>>
>>> 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...
>>> 
>>> 
>>> 9830318220466018
>>> 
>>> 
>>> >> data-gift-id="9830318220466018">
>>> 
>>> Remove
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 9831228610400260
>>> 
>>> 
>>> >> data-gift-id="9831228610400260">
>>> 
>>> Remove
>>> 
>>> 
>>> 
>>> 
>>> 
>>>
>>> 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 here...@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-general@googlegroups.com
> http://groups.google.com/group/watir-general
> watir-general+unsubscr...@googlegroups.com
> ---
> You received this message because you are subscribed to the Google Groups
> "Watir General" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to watir-general+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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

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


[wtr-general] Re: Trouble Locating elements using PageObject

2018-07-11 Thread 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')`.

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


On Wednesday, July 11, 2018 at 6:22:20 AM UTC-4, NaviHan wrote:
>
> Hi Justin/Titus
>
> There is a correction in the html code
>
> 
> 
> 
> 
>  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">
>
>
> 2
>
> 3
>
> 4
>
> 5
>
> 6
>
> 7
>
> 8
>
> 9
>
> 10
>
> 
> 
> 
> 
>  id="dwfrm_cart_shipments_i0_items_i1_quantity" 
> name="dwfrm_cart_shipments_i0_items_i1_quantity" 
> data-product-id="9351533670743" data-item-position="2">
>
>
> 2
>
> 3
>
> 4
>
> 5
>
> 6
>
> 7
>
> 8
>
> 9
>
> 10
>
> 
> 
> 
> 
>  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">
>
>
> 2
>
> 3
>
> 4
>
> 5
>
> 6
>
> 7
>
> 8
>
> 9
>
> 10
>
>
>
> On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>>
>> 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...
>> 
>> 
>> 9830318220466018
>> 
>>  
>> > data-gift-id="9830318220466018">
>> 
>> Remove
>> 
>> 
>> 
>> 
>> 
>> 
>> 9831228610400260
>> 
>>  
>> > data-gift-id="9831228610400260">
>> 
>> Remove
>> 
>> 
>> 
>> 
>> 
>>
>> 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 here...@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-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Trouble Locating elements using PageObject

2018-07-11 Thread NaviHan
Hi Justin/Titus

There is a correction in the html code








2

3

4

5

6

7

8

9

10








2

3

4

5

6

7

8

9

10








2

3

4

5

6

7

8

9

10



On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>
> 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...
> 
> 
> 9830318220466018
> 
>  
>  data-gift-id="9830318220466018">
> 
> Remove
> 
> 
> 
> 
> 
> 
> 9831228610400260
> 
>  
>  data-gift-id="9831228610400260">
> 
> Remove
> 
> 
> 
> 
> 
>
> 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 here...@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-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Trouble Locating elements using PageObject

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






On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>
> 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...
> 
> 
> 9830318220466018
> 
>  
>  data-gift-id="9830318220466018">
> 
> Remove
> 
> 
> 
> 
> 
> 
> 9831228610400260
> 
>  
>  data-gift-id="9831228610400260">
> 
> Remove
> 
> 
> 
> 
> 
>
> 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 here...@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-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Trouble Locating elements using PageObject

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






1

2

3

4

5

6

7

8

9

10






1

2

3

4

5

6

7

8

9

10






1

2

3

4

5

6

7

8

9

10



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?


On Wednesday, 11 July 2018 13:48:56 UTC+10, NaviHan wrote:
>
> Hi Justin
>
> That worked like a charm. PageObject gem is amazing :-)
>
> On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>>
>> 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...
>> 
>> 
>> 9830318220466018
>> 
>>  
>> > data-gift-id="9830318220466018">
>> 
>> Remove
>> 
>> 
>> 
>> 
>> 
>> 
>> 9831228610400260
>> 
>>  
>> > data-gift-id="9831228610400260">
>> 
>> Remove
>> 
>> 
>> 
>> 
>> 
>>
>> 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 here...@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-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Trouble Locating elements using PageObject

2018-07-10 Thread NaviHan
Hi Justin

That worked like a charm. PageObject gem is amazing :-)

On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>
> 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...
> 
> 
> 9830318220466018
> 
>  
>  data-gift-id="9830318220466018">
> 
> Remove
> 
> 
> 
> 
> 
> 
> 9831228610400260
> 
>  
>  data-gift-id="9831228610400260">
> 
> Remove
> 
> 
> 
> 
> 
>
> 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 here...@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-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Trouble Locating elements using PageObject

2018-07-10 Thread Justin Ko
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
#=> ""

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

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
#=> ""

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

Hope that helps,
Justin


On Tuesday, July 10, 2018 at 2:54:01 AM UTC-4, NaviHan wrote:
>
> Hi Titus
>
> I have got a related query
>
> I have a section of page
> 
> 
> 
> 
> 
> Sorry, your Perks Payday Voucher will be removed if you 
> proceed to checkout
> This reward is only available on orders AUD 10.00 and over.
> 
> 
>
> 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-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Trouble Locating elements using PageObject

2018-07-10 Thread NaviHan
Hi Titus

I have got a related query

I have a section of page





Sorry, your Perks Payday Voucher will be removed if you 
proceed to checkout
This reward is only available on orders AUD 10.00 and over.



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


On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>
> 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...
> 
> 
> 9830318220466018
> 
>  
>  data-gift-id="9830318220466018">
> 
> Remove
> 
> 
> 
> 
> 
> 
> 9831228610400260
> 
>  
>  data-gift-id="9831228610400260">
> 
> Remove
> 
> 
> 
> 
> 
>
> 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 here...@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-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Trouble Locating elements using PageObject

2018-07-03 Thread NaviHan
Hi Titus

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

nav_divs_elements[index].span_element

Thanks a million

On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>
> 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...
> 
> 
> 9830318220466018
> 
>  
>  data-gift-id="9830318220466018">
> 
> Remove
> 
> 
> 
> 
> 
> 
> 9831228610400260
> 
>  
>  data-gift-id="9831228610400260">
> 
> Remove
> 
> 
> 
> 
> 
>
> 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 here...@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-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Trouble Locating elements using PageObject

2018-07-03 Thread NaviHan
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 
#


On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>
> 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...
> 
> 
> 9830318220466018
> 
>  
>  data-gift-id="9830318220466018">
> 
> Remove
> 
> 
> 
> 
> 
> 
> 9831228610400260
> 
>  
>  data-gift-id="9831228610400260">
> 
> Remove
> 
> 
> 
> 
> 
>
> 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 here...@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-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Trouble Locating elements using PageObject

2018-07-03 Thread Titus Fortner
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



On Tuesday, July 3, 2018 at 10:14:13 AM UTC-5, NaviHan wrote:
>
> Hi Titus
>
> Tried this
>
> Enter code here...divs(:nav_divs, class: "row applied-voucers-list")
>
> and
>
> Enter code here...@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 
> #
>
>
> Any clue?
>
> On Tuesday, 3 July 2018 23:56:26 UTC+10, Titus Fortner wrote:
>>
>> 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
>>
>>
>>
>>
>>
>> On Tuesday, July 3, 2018 at 7:06:15 AM UTC-5, NaviHan wrote:
>>>
>>> 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?
>>>
>>> On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:

 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...
 
 
 9830318220466018
 
  
 >>> data-gift-id="9830318220466018">
 
 Remove
 
 
 
 
 
 
 9831228610400260
 
  
 >>> data-gift-id="9831228610400260">
 
 Remove
 
 
 
 
 

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


[wtr-general] Re: Trouble Locating elements using PageObject

2018-07-03 Thread NaviHan
Hi Titus

Tried this

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

and

Enter code here...@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 
#


Any clue?

On Tuesday, 3 July 2018 23:56:26 UTC+10, Titus Fortner wrote:
>
> 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
>
>
>
>
>
> On Tuesday, July 3, 2018 at 7:06:15 AM UTC-5, NaviHan wrote:
>>
>> 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?
>>
>> On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>>>
>>> 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...
>>> 
>>> 
>>> 9830318220466018
>>> 
>>>  
>>> >> data-gift-id="9830318220466018">
>>> 
>>> Remove
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 9831228610400260
>>> 
>>>  
>>> >> data-gift-id="9831228610400260">
>>> 
>>> Remove
>>> 
>>> 
>>> 
>>> 
>>> 
>>>
>>> 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 here...@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-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Trouble Locating elements using PageObject

2018-07-03 Thread 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 
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





On Tuesday, July 3, 2018 at 7:06:15 AM UTC-5, NaviHan wrote:
>
> 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?
>
> On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>>
>> 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...
>> 
>> 
>> 9830318220466018
>> 
>>  
>> > data-gift-id="9830318220466018">
>> 
>> Remove
>> 
>> 
>> 
>> 
>> 
>> 
>> 9831228610400260
>> 
>>  
>> > data-gift-id="9831228610400260">
>> 
>> Remove
>> 
>> 
>> 
>> 
>> 
>>
>> 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 here...@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-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [wtr-general] Re: Trouble Locating elements using PageObject

2018-07-03 Thread rajagopalan madasami
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 .

On Tue 3 Jul, 2018, 6:20 PM NaviHan,  wrote:

> Here is a reference to where Im coming from
> https://github.com/cheezy/page-object/wiki/Nested-Elements
>
> On Tuesday, 3 July 2018 22:38:58 UTC+10, NaviHan wrote:
>>
>> 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
>>
>>
>> On Tue, Jul 3, 2018 at 10:31 PM,  wrote:
>>
>>> I am not stopping you, I asked you to convert that into your model.
>>>
>>> On Tuesday, July 3, 2018 at 5:57:35 PM UTC+5:30, NaviHan wrote:

 I would like to use the PageObject gem..

 On Tue, Jul 3, 2018 at 10:24 PM,  wrote:

> What are you saying me? I gave you the answer, did you try?
>
> On Tuesday, July 3, 2018 at 5:51:20 PM UTC+5:30, NaviHan wrote:
>>
>> 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
>>
>> On Tue, Jul 3, 2018 at 10:18 PM,  wrote:
>>
>>> 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.text}
>>>
>>>
>>> On Tuesday, July 3, 2018 at 5:36:15 PM UTC+5:30, NaviHan wrote:

 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?

 On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>
> 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...
> 
> 
> 9830318220466018
> 
> 
>  data-gift-id="9830318220466018">
> 
> Remove
> 
> 
> 
> 
> 
> 
> 9831228610400260
> 
> 
>  data-gift-id="9831228610400260">
> 
> Remove
> 
> 
> 
> 
> 
>
> 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 here...@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-genera...@googlegroups.com
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Watir General" group.
>>> To unsubscribe from this group and stop receiving emails from it,
>>> send an email to watir-genera...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> --
> Before posting, please read
> 

Re: [wtr-general] Re: Trouble Locating elements using PageObject

2018-07-03 Thread NaviHan
Here is a reference to where Im coming from
https://github.com/cheezy/page-object/wiki/Nested-Elements

On Tuesday, 3 July 2018 22:38:58 UTC+10, NaviHan wrote:
>
> 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
>
>
> On Tue, Jul 3, 2018 at 10:31 PM,  wrote:
>
>> I am not stopping you, I asked you to convert that into your model. 
>>
>> On Tuesday, July 3, 2018 at 5:57:35 PM UTC+5:30, NaviHan wrote:
>>>
>>> I would like to use the PageObject gem..
>>>
>>> On Tue, Jul 3, 2018 at 10:24 PM,  wrote:
>>>
 What are you saying me? I gave you the answer, did you try? 

 On Tuesday, July 3, 2018 at 5:51:20 PM UTC+5:30, NaviHan wrote:
>
> 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
>
> On Tue, Jul 3, 2018 at 10:18 PM,  wrote:
>
>> 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.text}
>>
>>
>> On Tuesday, July 3, 2018 at 5:36:15 PM UTC+5:30, NaviHan wrote:
>>>
>>> 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?
>>>
>>> On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:

 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...
 
 
 9830318220466018
 
  
 >>> data-gift-id="9830318220466018">
 
 Remove
 
 
 
 
 
 
 9831228610400260
 
  
 >>> data-gift-id="9831228610400260">
 
 Remove
 
 
 
 
 

 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 here...@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-genera...@googlegroups.com
>> --- 
>> You received this message because you are subscribed to the Google 
>> Groups "Watir General" group.
>> To unsubscribe from this group and stop receiving emails from it, 
>> send an email to watir-genera...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> -- 
 -- 
 Before posting, please read 
 https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
  

 In short: search before you ask, be nice.
  
 watir-...@googlegroups.com
 http://groups.google.com/group/watir-general
 watir-genera...@googlegroups.com
 --- 
 You received this message because you are subscribed to the Google 
 Groups "Watir General" group.
 To unsubscribe from this group and stop receiving 

Re: [wtr-general] Re: Trouble Locating elements using PageObject

2018-07-03 Thread 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


On Tue, Jul 3, 2018 at 10:31 PM,  wrote:

> I am not stopping you, I asked you to convert that into your model.
>
> On Tuesday, July 3, 2018 at 5:57:35 PM UTC+5:30, NaviHan wrote:
>>
>> I would like to use the PageObject gem..
>>
>> On Tue, Jul 3, 2018 at 10:24 PM,  wrote:
>>
>>> What are you saying me? I gave you the answer, did you try?
>>>
>>> On Tuesday, July 3, 2018 at 5:51:20 PM UTC+5:30, NaviHan wrote:

 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

 On Tue, Jul 3, 2018 at 10:18 PM,  wrote:

> 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.text}
>
>
> On Tuesday, July 3, 2018 at 5:36:15 PM UTC+5:30, NaviHan wrote:
>>
>> 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?
>>
>> On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>>>
>>> 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...
>>> 
>>> 
>>> 9830318220466018
>>> 
>>> 
>>> >> data-gift-id="9830318220466018">
>>> 
>>> Remove
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 9831228610400260
>>> 
>>> 
>>> >> data-gift-id="9831228610400260">
>>> 
>>> Remove
>>> 
>>> 
>>> 
>>> 
>>> 
>>>
>>> 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
>>> Enter code here...@var = @browser.execute_script("docum
>>> 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.
>
> watir-...@googlegroups.com
> http://groups.google.com/group/watir-general
> watir-genera...@googlegroups.com
> ---
> You received this message because you are subscribed to the Google
> Groups "Watir General" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to watir-genera...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

 --
>>> --
>>> Before posting, please read https://github.com/watir/watir
>>> _meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
>>> In short: search before you ask, be nice.
>>>
>>> watir-...@googlegroups.com
>>> http://groups.google.com/group/watir-general
>>> watir-genera...@googlegroups.com
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Watir General" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to watir-genera...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> --
> Before posting, please read https://github.com/watir/
> watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
> In short: search before you ask, be nice.
>
> watir-general@googlegroups.com
> 

Re: [wtr-general] Re: Trouble Locating elements using PageObject

2018-07-03 Thread rajagopalanmadasami
I am not stopping you, I asked you to convert that into your model. 

On Tuesday, July 3, 2018 at 5:57:35 PM UTC+5:30, NaviHan wrote:
>
> I would like to use the PageObject gem..
>
> On Tue, Jul 3, 2018 at 10:24 PM, > 
> wrote:
>
>> What are you saying me? I gave you the answer, did you try? 
>>
>> On Tuesday, July 3, 2018 at 5:51:20 PM UTC+5:30, NaviHan wrote:
>>>
>>> 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
>>>
>>> On Tue, Jul 3, 2018 at 10:18 PM,  wrote:
>>>
 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.text}


 On Tuesday, July 3, 2018 at 5:36:15 PM UTC+5:30, NaviHan wrote:
>
> 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?
>
> On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>>
>> 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...
>> 
>> 
>> 9830318220466018
>> 
>>  
>> > data-gift-id="9830318220466018">
>> 
>> Remove
>> 
>> 
>> 
>> 
>> 
>> 
>> 9831228610400260
>> 
>>  
>> > data-gift-id="9831228610400260">
>> 
>> Remove
>> 
>> 
>> 
>> 
>> 
>>
>> 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 here...@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-genera...@googlegroups.com
 --- 
 You received this message because you are subscribed to the Google 
 Groups "Watir General" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to watir-genera...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>>
>>> -- 
>> -- 
>> Before posting, please read 
>> https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
>>  
>>
>> In short: search before you ask, be nice.
>>  
>> watir-...@googlegroups.com 
>> http://groups.google.com/group/watir-general
>> watir-genera...@googlegroups.com 
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Watir General" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to watir-genera...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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

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


Re: [wtr-general] Re: Trouble Locating elements using PageObject

2018-07-03 Thread Navi
I would like to use the PageObject gem..

On Tue, Jul 3, 2018 at 10:24 PM,  wrote:

> What are you saying me? I gave you the answer, did you try?
>
> On Tuesday, July 3, 2018 at 5:51:20 PM UTC+5:30, NaviHan wrote:
>>
>> 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
>>
>> On Tue, Jul 3, 2018 at 10:18 PM,  wrote:
>>
>>> 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.text}
>>>
>>>
>>> On Tuesday, July 3, 2018 at 5:36:15 PM UTC+5:30, NaviHan wrote:

 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?

 On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>
> 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...
> 
> 
> 9830318220466018
> 
> 
>  data-gift-id="9830318220466018">
> 
> Remove
> 
> 
> 
> 
> 
> 
> 9831228610400260
> 
> 
>  data-gift-id="9831228610400260">
> 
> Remove
> 
> 
> 
> 
> 
>
> 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 here...@var = @browser.execute_script("docum
> 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.
>>>
>>> watir-...@googlegroups.com
>>> http://groups.google.com/group/watir-general
>>> watir-genera...@googlegroups.com
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Watir General" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to watir-genera...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> --
> Before posting, please read https://github.com/watir/
> watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
> In short: search before you ask, be nice.
>
> watir-general@googlegroups.com
> http://groups.google.com/group/watir-general
> watir-general+unsubscr...@googlegroups.com
> ---
> You received this message because you are subscribed to the Google Groups
> "Watir General" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to watir-general+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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

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


Re: [wtr-general] Re: Trouble Locating elements using PageObject

2018-07-03 Thread rajagopalanmadasami
What are you saying me? I gave you the answer, did you try? 

On Tuesday, July 3, 2018 at 5:51:20 PM UTC+5:30, NaviHan wrote:
>
> 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
>
> On Tue, Jul 3, 2018 at 10:18 PM, > 
> wrote:
>
>> 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
>>> .text}
>>
>>
>> On Tuesday, July 3, 2018 at 5:36:15 PM UTC+5:30, NaviHan wrote:
>>>
>>> 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?
>>>
>>> On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:

 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...
 
 
 9830318220466018
 
  
 >>> data-gift-id="9830318220466018">
 
 Remove
 
 
 
 
 
 
 9831228610400260
 
  
 >>> data-gift-id="9831228610400260">
 
 Remove
 
 
 
 
 

 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 here...@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-genera...@googlegroups.com 
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Watir General" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to watir-genera...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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

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


Re: [wtr-general] Re: Trouble Locating elements using PageObject

2018-07-03 Thread 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

On Tue, Jul 3, 2018 at 10:18 PM,  wrote:

> 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.
>> text}
>
>
> On Tuesday, July 3, 2018 at 5:36:15 PM UTC+5:30, NaviHan wrote:
>>
>> 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?
>>
>> On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>>>
>>> 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...
>>> 
>>> 
>>> 9830318220466018
>>> 
>>> 
>>> >> data-gift-id="9830318220466018">
>>> 
>>> Remove
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 9831228610400260
>>> 
>>> 
>>> >> data-gift-id="9831228610400260">
>>> 
>>> Remove
>>> 
>>> 
>>> 
>>> 
>>> 
>>>
>>> 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 here...@var = @browser.execute_script("docum
>>> 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.
>
> watir-general@googlegroups.com
> http://groups.google.com/group/watir-general
> watir-general+unsubscr...@googlegroups.com
> ---
> You received this message because you are subscribed to the Google Groups
> "Watir General" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to watir-general+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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

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


[wtr-general] Re: Trouble Locating elements using PageObject

2018-07-03 Thread rajagopalanmadasami
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.
> text}


On Tuesday, July 3, 2018 at 5:36:15 PM UTC+5:30, NaviHan wrote:
>
> 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?
>
> On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>>
>> 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...
>> 
>> 
>> 9830318220466018
>> 
>>  
>> > data-gift-id="9830318220466018">
>> 
>> Remove
>> 
>> 
>> 
>> 
>> 
>> 
>> 9831228610400260
>> 
>>  
>> > data-gift-id="9831228610400260">
>> 
>> Remove
>> 
>> 
>> 
>> 
>> 
>>
>> 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 here...@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-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Trouble Locating elements using PageObject

2018-07-03 Thread rajagopalanmadasami
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

On Tuesday, July 3, 2018 at 5:36:15 PM UTC+5:30, NaviHan wrote:
>
> 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?
>
> On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>>
>> 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...
>> 
>> 
>> 9830318220466018
>> 
>>  
>> > data-gift-id="9830318220466018">
>> 
>> Remove
>> 
>> 
>> 
>> 
>> 
>> 
>> 9831228610400260
>> 
>>  
>> > data-gift-id="9831228610400260">
>> 
>> Remove
>> 
>> 
>> 
>> 
>> 
>>
>> 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 here...@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-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Trouble Locating elements using PageObject

2018-07-03 Thread 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?

On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>
> 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...
> 
> 
> 9830318220466018
> 
>  
>  data-gift-id="9830318220466018">
> 
> Remove
> 
> 
> 
> 
> 
> 
> 9831228610400260
> 
>  
>  data-gift-id="9831228610400260">
> 
> Remove
> 
> 
> 
> 
> 
>
> 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 here...@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-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.