Sha256: 677fc679e204d26a346c77523f9a379f98b69a21eb59c9f7c9ea5bec89606533

Contents?: true

Size: 786 Bytes

Versions: 2

Compression:

Stored size: 786 Bytes

Contents

module Pagetience
  module Platform
    class PageObjectGem
      class << self
        def init(base, *args)
          args.flatten! if args

          base.class.send(:define_method, :visit) do
            args[1] || false
          end
          base.instance_eval do
            PageObject.instance_method(:initialize).bind(self).call(base.browser, visit)
          end

          self.new base
        end
      end

      attr_reader :page_object, :browser

      def initialize(page)
        @page_object = page
        @browser = @page_object.browser
      end

      def underlying_element_for(sym)
        @page_object.send("#{sym}_element").element
      end

      def is_element_present?(sym)
        @page_object.send("#{sym}_element").visible?
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pagetience-0.4.3 lib/pagetience/platforms/page-object-gem.rb
pagetience-0.4.2 lib/pagetience/platforms/page-object-gem.rb