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?



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

Reply via email to