Sha256: 37e2c22e38572d6bdef1b690deaa2b8cec947f764ba080dd6e974f9d430e6448

Contents?: true

Size: 805 Bytes

Versions: 4

Compression:

Stored size: 805 Bytes

Contents

module Pagetience
  module ElementPlatforms
    class PageObjectGem < Base
      attr_reader :page_object_instance

      class << self
        def present?(klazz)
          klazz.class.ancestors.include? PageObject
        end
      end

      def initialize(klazz)
        super

        @page_object_instance = klazz
        @browser = @page_object_instance.browser
      end

      def platform_initialize(args=[])
        @page_object_instance.class.send(:define_method, :visit) do
          args[0] || false
        end
        @page_object_instance.instance_eval do
          PageObject.instance_method(:initialize).bind(self).call(@browser, visit)
        end
      end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pagetience-0.3.2 lib/pagetience/platforms/page-object-gem.rb
pagetience-0.3.1 lib/pagetience/platforms/page-object-gem.rb
pagetience-0.3.0 lib/pagetience/platforms/page-object-gem.rb
pagetience-0.2.1 lib/pagetience/platforms/page-object-gem.rb