class SeleniumRecord::Base

@abstract Subclass and override {#run} to implement

a custom Selenium object

Attributes

__rootel__[R]
browser[R]
object[R]
parent_el[R]
root_el[R]

Public Class Methods

extract_klass(subject, opts) click to toggle source

@param [Hash] opts the options for the new view created @option opts [Module] :namespace The namespace in which the new view

should be created

@option opts [String] :suffix The suffix to be appended to the new view

class name

@return [SeleniumRecord::Base]

# File lib/selenium_record/base.rb, line 94
def self.extract_klass(subject, opts)
  namespace = opts[:namespace] || Object
  suffix = opts[:suffix] || ''
  namespace.const_get("#{subject}#{suffix}")
end
new(browser, opts = {}) click to toggle source

@params browser [Selenium::WebDriver::Driver] @param [Hash] opts the options to create a new record @option opts [Selenium::WebDriver::Element] :parent_el The parent element @option opts [Selenium::WebDriver::Element] :root_el The root element @option opts [PORO] :object Plain Old Ruby Object contains main info

related to the record
# File lib/selenium_record/base.rb, line 49
def initialize(browser, opts = {})
  @browser = browser
  @parent_el = opts[:parent_el]
  @root_el = opts[:root_el]
  @object = opts[:object]
end

Public Instance Methods

create_record(object, opts = {}) click to toggle source

Creates a view in the scope of current instance based on object model

passed as parameter

@param object [ActiveRecord::Base] the object related to the new view @param [Hash] opts the options for the new view created @option opts [Module] :namespace The namespace in which the new view

should be created

@option opts [String] :suffix The suffix to be appended to the new view

class name
# File lib/selenium_record/base.rb, line 64
def create_record(object, opts = {})
  subject = opts[:subject] || object.class.name
  klass = self.class.extract_klass(subject, opts)
  klass.new(@browser, parent_el: root_el, object: object)
end
create_record_for_action(action, opts = {}) click to toggle source

Creates a view in the scope of current instance based on the action name @param action [Symbol] @param [Hash] opts the options for the new view created @option opts [Module] :namespace The namespace in which the new view

should be created

@option opts [String] :suffix The suffix to be appended to the new view

class name
# File lib/selenium_record/base.rb, line 77
def create_record_for_action(action, opts = {})
  klass = self.class.extract_klass(action.to_s.camelize, opts)
  klass.new(@browser, parent_el: root_el)
end
exist?() click to toggle source

@return [Boolean] returns whether the view is attached to the dom

# File lib/selenium_record/base.rb, line 83
def exist?
  load_dom if respond_to? :lookup_sequence
  root_el != nil
end