You are correct that #reward_history? calls #exists?. There is no 
auto-generated method for #present?.

It is rather unfortunate. Checking presence is probably more common than 
checking existence. As a backwards incompatible change, it'll take some 
time to change.

If you want, you could monkey-patch to use #present? instead of #exists?:

module PageObject
  module Accessors
    def standard_methods(name, identifier, method, &block)
      define_method("#{name}_element") do
        return call_block(&block) if block_given?
        platform.send(method, identifier.clone)
      end
      define_method("#{name}?") do
        return call_block(&block).present? if block_given?
        platform.send(method, identifier.clone).present?
      end
    end
  end
end

I created a feature request 
(https://github.com/cheezy/page-object/issues/476), but like I said before, 
it'd take some time to roll out.

- Justin


On Thursday, January 31, 2019 at 8:11:33 AM UTC-5, NaviHan wrote:
>
> I have an element defined as
>
> div(:reward_history, :class => 'reward-history-header')
>
>
> The page-object gem generated four methods for this element which are
>
>
> 'reward_history', 'reward_history_element', and 'reward_history?'
>
>
>
> The fourth method 'reward_history?' check if the element exists in the 
> DOM?
>
>
> But what if the element exists in the DOM but is hidden, which is 
> basically checking if the element is present?
>
>
> Is there an autogenerated method for this?
>
> I tried 'reward_history(:&present?)' but didn't work
>
> As of now I have to write a method separately which does this
>
>   def is_reward_history_present?
>     return reward_history_element.present?
>   end
>
>
>
>

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