Hi Navi,

How is #delete_coupon_elements defined? I would have expected it to 
re-determine the collection each time it was called.

Titus made some fixes around collections in 6.13 and 6.14. You could see if 
that resolves your issue.

I suppose it could be a timing issue - eg :
1. The first coupon button is clicked (but not immediately removed from the 
UI due to asychronous code)
2. The coupon collection is re-calculated (still 2 since the first is still 
not deleted)
3. The first coupon actually gets removed
4. The locating of the second button is no longer possible.

Alternatively, there isn't a benefit of iterating over the collection of 
coupons. Technically, it's slower. You could locate and delete the specific 
coupon:

def remove_voucher_from_bag coupon_id
  browser.button(id: 'delete-coupon', value: coupon_id).click
end

Justin

On Thursday, September 20, 2018 at 6:50:21 AM UTC-4, NaviHan wrote:
>
> I have a bag page where I have applied two coupons. Once the coupons are 
> applied the source looks like this
> <div class="small-12 all-applied-coupons column promo-codes-list">
>
>
> <h5 class="applied-promo-codes-title">Applied codes:</h5>
>
> <div class="row promo-code-row">
> <div class="small-8 large-6 xxlarge-8 column small-text-left 
> promo-code-column">
> <span class="promo-code-item">
> 9840150120702065
> </span>
> </div>
> <div class="column small-text-right">
> <button type="button" class="pointer" value="9840150120702065" id=
> "delete-coupon">
> <span class="icon icon-cross-standard-small-black"></span>
> <span class="underline align-text remove-promo-code">Remove</span>
> </button>
> </div>
> </div>
>
>
> <div class="row promo-code-row">
> <div class="small-8 large-6 xxlarge-8 column small-text-left 
> promo-code-column">
> <span class="promo-code-item">
> autotest_order
> </span>
> </div>
> <div class="column small-text-right">
> <button type="button" class="pointer" value="autotest_order" id=
> "delete-coupon">
> <span class="icon icon-cross-standard-small-black"></span>
> <span class="underline align-text remove-promo-code">Remove</span>
> </button>
> </div>
> </div>
>
> </div>
>
>
>
> There is a remove link(button) against each coupon. Basically my test 
> clicks these buttons to remove them
>
> I have the page object defined as and the step def and method as follows
>
> buttons(:delete_coupon, :id => 'delete-coupon')
>
>
>
>
> And(/^the customer removes the coupons\/vouchers from Bag Page$/) do |
> table|
>   on(MybagPage) do |page|
>     @remove_voucher_list = table.hashes
>     @remove_voucher_list.each {|data|
>       page.remove_voucher_from_bag data['voucher_id']
>     }
>   end
>
>
> def remove_voucher_from_bag coupon_id
>   delete_coupon_elements.find{|el| el.value.to_s == coupon_id.to_s}.click
> end
>
>
> The script removes the coupon "9840150120702065", but when trying to 
> remove the next coupon fails with folowing message
> Watir::Exception::UnknownObjectException: timed out after 30 seconds, 
> waiting for #<Watir::Button: located: false; {:id=>"delete-coupon", 
> :tag_name=>"button", :index=>1}> to be located; Maybe look in an iframe?
> ./features/support/pages/Frontend/Cotton_On/Mybag_Page.rb:141:in `block 
> in remove_voucher_from_bag'
>
>
>
> Any clue whats missing 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.

Reply via email to