module PageMagic::InstanceMethods
module InstanceMethods
- provides instance level methods for page objects
Attributes
browser[R]
browser_element[R]
session[R]
Public Class Methods
new(session = Session.new(Capybara.current_session))
click to toggle source
Creates a new instance @param [Session] session session that provides gateway to the browser throw the users chosen browser
# File lib/page_magic/instance_methods.rb, line 15 def initialize(session = Session.new(Capybara.current_session)) @browser = session.raw_session @session = session @browser_element = browser end
Public Instance Methods
element_definitions()
click to toggle source
@return [Array<ElementDefinitionBuilder>] class level defined element definitions
# File lib/page_magic/instance_methods.rb, line 23 def element_definitions self.class.element_definitions end
execute_on_load()
click to toggle source
executes block stored using {ClassMethods#on_load} against self @return [Element] self
# File lib/page_magic/instance_methods.rb, line 29 def execute_on_load instance_eval(&self.class.on_load) self end
method_missing(method, *args)
click to toggle source
proxy to the defined page element definitions @return [Object] the result of accessing the requested page element through its definition
# File lib/page_magic/instance_methods.rb, line 36 def method_missing(method, *args) element_context.send(method, *args) end
respond_to_missing?(*args)
click to toggle source
Calls superclass method
# File lib/page_magic/instance_methods.rb, line 40 def respond_to_missing?(*args) contains_element?(args.first) || super end
text()
click to toggle source
@return the page text
# File lib/page_magic/instance_methods.rb, line 50 def text browser.text end
text_on_page?(string)
click to toggle source
check for the presense of specific text on the page @param [String] string the string to check for @return [Boolean]
# File lib/page_magic/instance_methods.rb, line 57 def text_on_page?(string) text.downcase.include?(string.downcase) end
title()
click to toggle source
@return the current page title
# File lib/page_magic/instance_methods.rb, line 45 def title browser.title end
Private Instance Methods
contains_element?(method)
click to toggle source
# File lib/page_magic/instance_methods.rb, line 63 def contains_element?(method) element_definitions.keys.include?(method) end
element_context()
click to toggle source
# File lib/page_magic/instance_methods.rb, line 67 def element_context ElementContext.new(self) end