Module: PageMagic::InstanceMethods
- Includes:
- Element::Locators, SessionMethods, WaitMethods, Watchers
- Defined in:
- lib/page_magic/instance_methods.rb
Overview
module InstanceMethods - provides instance level methods for page objects
Constant Summary
Constants included from Watchers
Constants included from Element::Locators
Element::Locators::ELEMENT_NOT_DEFINED_MSG
Instance Attribute Summary collapse
-
#browser ⇒ Object
readonly
Returns the value of attribute browser.
-
#browser_element ⇒ Object
readonly
Returns the value of attribute browser_element.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
-
#element_definitions ⇒ Array
Class level defined element definitions.
-
#execute_on_load ⇒ Element
executes block stored using ClassMethods#on_load against self.
-
#initialize(session = Session.new(Capybara.current_session)) ⇒ Object
Creates a new instance.
-
#method_missing(method, *args) ⇒ Object
proxy to the defined page element definitions.
- #respond_to?(*args) ⇒ Boolean
-
#text ⇒ Object
The page text.
-
#text_on_page?(string) ⇒ Boolean
check for the presense of specific text on the page.
-
#title ⇒ Object
The current page title.
Methods included from Watchers
#changed?, #watch, #watcher, #watchers
Methods included from SessionMethods
#execute_script, #page, #path, #url
Methods included from WaitMethods
Methods included from Element::Locators
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
proxy to the defined page element definitions
31 32 33 |
# File 'lib/page_magic/instance_methods.rb', line 31 def method_missing(method, *args) element_context.send(method, *args) end |
Instance Attribute Details
#browser ⇒ Object (readonly)
Returns the value of attribute browser.
4 5 6 |
# File 'lib/page_magic/instance_methods.rb', line 4 def browser @browser end |
#browser_element ⇒ Object (readonly)
Returns the value of attribute browser_element.
4 5 6 |
# File 'lib/page_magic/instance_methods.rb', line 4 def browser_element @browser_element end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
4 5 6 |
# File 'lib/page_magic/instance_methods.rb', line 4 def session @session end |
Instance Method Details
#element_definitions ⇒ Array
Returns class level defined element definitions.
18 19 20 |
# File 'lib/page_magic/instance_methods.rb', line 18 def element_definitions self.class.element_definitions end |
#execute_on_load ⇒ Element
executes block stored using ClassMethods#on_load against self
24 25 26 27 |
# File 'lib/page_magic/instance_methods.rb', line 24 def execute_on_load instance_eval(&self.class.on_load) self end |
#initialize(session = Session.new(Capybara.current_session)) ⇒ Object
Creates a new instance
10 11 12 13 14 15 |
# File 'lib/page_magic/instance_methods.rb', line 10 def initialize(session = Session.new(Capybara.current_session)) @browser = session.raw_session @session = session @browser_element = browser end |
#respond_to?(*args) ⇒ Boolean
35 36 37 |
# File 'lib/page_magic/instance_methods.rb', line 35 def respond_to?(*args) super || element_context.respond_to?(*args) end |
#text ⇒ Object
Returns the page text.
45 46 47 |
# File 'lib/page_magic/instance_methods.rb', line 45 def text browser.text end |
#text_on_page?(string) ⇒ Boolean
check for the presense of specific text on the page
52 53 54 |
# File 'lib/page_magic/instance_methods.rb', line 52 def text_on_page?(string) text.downcase.include?(string.downcase) end |
#title ⇒ Object
Returns the current page title.
40 41 42 |
# File 'lib/page_magic/instance_methods.rb', line 40 def title browser.title end |