[wtr-general] Re: Maybe look in an iframe? error when clicking button
Hi Justin and Titus tap(&:click) did the trick Now its successfully removing the second voucher as well Thanks for the detailed explanation.. Cheers Navi -- -- 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: Maybe look in an iframe? error when clicking button
Ah, yes, it's a Ruby object method and has nothing to do with tapping a screen or the like: https://ruby-doc.org/core-2.5.1/Object.html#method-i-tap foo.click ==> nil foo.tap(&:click} ==> foo For example: def foo result = do_something puts "We did something" result end can be written on one line: def foo do_something.tap { puts "We did something" } end On Thursday, September 20, 2018 at 7:47:35 AM UTC-7, NaviHan wrote: > > Ok, Titus, but why use click on self? > Just searched the web for documentation on tap, couldnt find it. > > Could you please point me to if any? > > On Thursday, 20 September 2018 20:50:21 UTC+10, NaviHan wrote: >> >> I have a bag page where I have applied two coupons. Once the coupons are >> applied the source looks like this >> >> >> >> Applied codes: >> >> >> >> >> 9840150120702065 >> >> >> >> > "delete-coupon"> >> >> Remove >> >> >> >> >> >> >> >> >> autotest_order >> >> >> >> > "delete-coupon"> >> >> Remove >> >> >> >> >> >> >> >> >> 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 #"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. 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: Maybe look in an iframe? error when clicking button
Ok, Titus, but why use click on self? Just searched the web for documentation on tap, couldnt find it. Could you please point me to if any? On Thursday, 20 September 2018 20:50:21 UTC+10, NaviHan wrote: > > I have a bag page where I have applied two coupons. Once the coupons are > applied the source looks like this > > > > Applied codes: > > > > > 9840150120702065 > > > > "delete-coupon"> > > Remove > > > > > > > > > autotest_order > > > > "delete-coupon"> > > Remove > > > > > > > > > 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 #"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. 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: Maybe look in an iframe? error when clicking button
The tap methods returns self after doing whatever is in the block. It lets you chain methods more easily. -- -- 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: Maybe look in an iframe? error when clicking button
Sure Justin, Let me try that But what does tap(&:click)do? On Thursday, 20 September 2018 20:50:21 UTC+10, NaviHan wrote: > I have a bag page where I have applied two coupons. Once the coupons are > applied the source looks like this > > > > Applied codes: > > > > > 9840150120702065 > > > > "delete-coupon"> > > Remove > > > > > > > > > autotest_order > > > > "delete-coupon"> > > Remove > > > > > > > > > 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 #"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. 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: Maybe look in an iframe? error when clicking button
Sounds like the timing issue. Maybe try waiting for the coupon to be removed before continuing: delete_coupon_elements.find{|el| el.value.to_s == coupon_id.to_s}.tap(&: click).wait_while(&:present?) Justin On Thursday, September 20, 2018 at 9:30:17 AM UTC-4, NaviHan wrote: > > Hi Justin > > The button collection is defined as > > buttons(:delete_coupon, :id => 'delete-coupon') > > > On Thursday, 20 September 2018 20:50:21 UTC+10, NaviHan wrote: >> >> I have a bag page where I have applied two coupons. Once the coupons are >> applied the source looks like this >> >> >> >> Applied codes: >> >> >> >> >> 9840150120702065 >> >> >> >> > "delete-coupon"> >> >> Remove >> >> >> >> >> >> >> >> >> autotest_order >> >> >> >> > "delete-coupon"> >> >> Remove >> >> >> >> >> >> >> >> >> 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 #"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. 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: Maybe look in an iframe? error when clicking button
Hi Justin The button collection is defined as buttons(:delete_coupon, :id => 'delete-coupon') On Thursday, 20 September 2018 20:50:21 UTC+10, NaviHan wrote: > > I have a bag page where I have applied two coupons. Once the coupons are > applied the source looks like this > > > > Applied codes: > > > > > 9840150120702065 > > > > "delete-coupon"> > > Remove > > > > > > > > > autotest_order > > > > "delete-coupon"> > > Remove > > > > > > > > > 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 #"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. 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: Maybe look in an iframe? error when clicking button
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 > > > > Applied codes: > > > > > 9840150120702065 > > > > "delete-coupon"> > > Remove > > > > > > > > > autotest_order > > > > "delete-coupon"> > > Remove > > > > > > > > > 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 #"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. 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.