Class: Pagetience::ElementPlatforms::PageObjectGem

Inherits:
Base
  • Object
show all
Defined in:
lib/pagetience/platforms/page-object-gem.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#browser

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

find

Constructor Details

#initialize(klazz) ⇒ PageObjectGem

Returns a new instance of PageObjectGem.



12
13
14
15
16
17
# File 'lib/pagetience/platforms/page-object-gem.rb', line 12

def initialize(klazz)
  super

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

Instance Attribute Details

#page_object_instanceObject (readonly)

Returns the value of attribute page_object_instance.



4
5
6
# File 'lib/pagetience/platforms/page-object-gem.rb', line 4

def page_object_instance
  @page_object_instance
end

Class Method Details

.present?(klazz) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/pagetience/platforms/page-object-gem.rb', line 7

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

Instance Method Details

#platform_initialize(args = []) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/pagetience/platforms/page-object-gem.rb', line 19

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

#underlying_element_for(sym) ⇒ Object



28
29
30
# File 'lib/pagetience/platforms/page-object-gem.rb', line 28

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