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