Hi Justin
The collection was the first thing I tried. But the issue is when there is
only one gift card applied, meaning only one div with class <div class="row
gift-cards-list"
then applied_gift_card_elements[0] gave me error.
Will the collection work when there is just one div?
On Friday, 23 November 2018 13:06:07 UTC+11, NaviHan wrote:
>
> Having trouble using index.
>
> I have a section of a page as below.
> <div class="gc-list">
> <div class="row cards-list-titles" style="display: flex;">
> <div class="small-6 large-5">Card</div>
> <div class="small-5">Amount Taken</div>
> </div>
> <div class="row gift-cards-list" data-gcid="2790030163867647149" style
> ="display: flex;">
> <div class="small-6 large-5">...163867647149</div>
> <div class="small-5 large-6">$20.00</div>
> <div class="small-1 large-1 small-text-right">
> <button type="button" class="remove-gift-cert pointer"
> data-gcid="2790030163867647149">
> <span class="icon icon-cross-standard-small-black"></span>
> </button>
> </div>
> </div>
> <hr class="gc-separator" style="display: block;">
> <div class="row gift-cards-list" data-gcid="2790030169169063156"
> style="display: flex;">
> <div class="small-6 large-5">...169169063156</div>
> <div class="small-5 large-6">$25.90
> <br class="hide-for-large">
> <span class="gc-amount-left">($74.10 left on card)
> </span>
> </div>
> <div class="small-1 large-1 small-text-right">
> <button type="button" class="remove-gift-cert pointer"
> data-gcid="2790030169169063156">
> <span class="icon icon-cross-standard-small-black"
> ></span>
> </button>
> </div>
> </div>
> <hr class="gc-separator" style="display: block;">
> </div>
>
>
> The pageobject is defined as
>
> div(:applied_gift_cards, :class => 'gc-list')
>
>
>
>
> And Im trying to access "...163867647149 " and "$20.00" as which gave
> error
>
> return applied_gift_cards_element.div_element(:index => 1).div_element(:index
> =>0).text
>
> return applied_gift_cards_element.div_element(:index => 1).div_element(:index
> =>0).text
>
> Watir::Exception::UnknownObjectException: timed out after 30 seconds,
> waiting for #<Watir::Div: located: false; {:class=>"gc-list",
> :tag_name=>"div"} --> {:index=>1, :tag_name=>"div"} --> {:index=>0,
> :tag_name=>"div"}> to be located
>
> When printing the same element actually prints the Pageobect
> puts applied_gift_cards_element.div_element(:index => 1).div_element(:index
> =>0)
> #<PageObject::Elements::Div:0x0000000003b66388>
>
>
> A puts of the following printed as below which is again confusing
>
> puts applied_gift_cards_element.div_element(:index => 0).inner_html
> puts applied_gift_cards_element.div_element(:index => 1).inner_html
> puts applied_gift_cards_element.div_element(:index => 2).inner_html
> puts applied_gift_cards_element.div_element(:index => 3).inner_html
>
> <div class="small-6 large-5">Card</div>
> <div class="small-5">Amount Taken</div>
> Card
> Amount Taken
> <div class="small-6 large-5">...163867647149</div><div class="small-5
> large-6">$20.00</div><div class="small-1 large-1 small-text-right"><button
> type="button" class="remove-gift-cert pointer"
> data-gcid="2790030163867647149"><span class="icon
> icon-cross-standard-small-black"></span></button></div>
>
>
>
>
> Am I doing something wrong here?
>
>
--
--
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.
[email protected]
http://groups.google.com/group/watir-general
[email protected]
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.