lib/pagetience/platforms/page-object-gem.rb in pagetience-0.4.0 vs lib/pagetience/platforms/page-object-gem.rb in pagetience-0.4.2
- old
+ new
@@ -1,37 +1,35 @@
module Pagetience
- module ElementPlatforms
- class PageObjectGem < Base
- attr_reader :page_object_instance
-
+ module Platform
+ class PageObjectGem
class << self
- def present?(klazz)
- klazz.class.ancestors.include? PageObject
+ 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
- def initialize(klazz)
- super
+ attr_reader :page_object, :browser
- @page_object_instance = klazz
- @browser = @page_object_instance.browser
+ def initialize(page)
+ @page_object = page
+ @browser = @page_object.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
+ @page_object.send("#{sym}_element").element
end
def is_element_present?(sym)
- @page_object_instance.send("#{sym}_element").visible?
+ @page_object.send("#{sym}_element").visible?
end
end
end
end
\ No newline at end of file