Sha256: 0f4133852538fd7a0a27c5c155abaa5299ef7ad32f23fe410a043698ea4d3d63

Contents?: true

Size: 913 Bytes

Versions: 1

Compression:

Stored size: 913 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

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

Version data entries

1 entries across 1 versions & 1 rubygems

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