Class: SeleniumRecord::Base Abstract
- Inherits:
-
Object
- Object
- SeleniumRecord::Base
- Includes:
- ActionBuilder, Actions, Axis, ComponentAutoload, Configuration, Core, Html, Lookup, Preconditions, Scopes, Theme, Translations, Waits
- Defined in:
- lib/selenium_record/base.rb
Overview
Subclass and override #run to implement a custom Selenium object
Direct Known Subclasses
Constant Summary
Constants included from Waits
Constants included from Core
Instance Attribute Summary collapse
-
#browser ⇒ Object
readonly
Returns the value of attribute browser.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#parent_el ⇒ Object
readonly
Returns the value of attribute parent_el.
-
#root_el ⇒ Object
(also: #__rootel__)
readonly
Returns the value of attribute root_el.
Class Method Summary collapse
Instance Method Summary collapse
-
#create_record(object, opts = {}) ⇒ Object
Creates a view in the scope of current instance based on object model passed as parameter.
-
#create_record_for_action(action, opts = {}) ⇒ Object
Creates a view in the scope of current instance based on the action name.
-
#exist? ⇒ Boolean
Returns whether the view is attached to the dom.
-
#initialize(browser, opts = {}) ⇒ Base
constructor
A new instance of Base.
Methods included from ComponentAutoload
component_loader, extract_group, extract_namespace, extract_options, included, #method_missing, #modal_for, #panel_for, #pill_for, #tab_for, #view_for
Methods included from Translations
Methods included from Theme
#dropdown_menu_xpath, #dropdown_xpath, #find_headline, #modal_header_xpath, #section_xpath, #select_option_xpath, #select_xpath
Methods included from Html
Methods included from Axis
#after?, #before?, #following_sibling_elements, #ordered?, #preceding_sibling_elements
Methods included from Preconditions
#when_clickable, #when_hidden, #when_modal_present, #when_present
Methods included from Waits
included, #wait_displayed, #wait_fade_in, #wait_hidden, #wait_js_inactive, #wait_page_load
Methods included from Scopes
Methods included from ActionBuilder
Methods included from Actions
#accept_popup, #choose_menu, choose_option, #clear, #click, #click_link, #click_on, #click_wait, #fill, #focus, #pop_last, #select_from_chosen, #submit, #textarea_content
Methods included from Lookup
included, #lookup, #lookup_sequence, #lookup_step
Methods included from Core
#find, #find!, #find_elements, #first_last, #load_dom, #load_dom!
Methods included from Configuration
Constructor Details
#initialize(browser, opts = {}) ⇒ Base
Returns a new instance of Base.
49 50 51 52 53 54 |
# 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class SeleniumRecord::ComponentAutoload
Instance Attribute Details
#browser ⇒ Object (readonly)
Returns the value of attribute browser.
40 41 42 |
# File 'lib/selenium_record/base.rb', line 40 def browser @browser end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
40 41 42 |
# File 'lib/selenium_record/base.rb', line 40 def object @object end |
#parent_el ⇒ Object (readonly)
Returns the value of attribute parent_el.
40 41 42 |
# File 'lib/selenium_record/base.rb', line 40 def parent_el @parent_el end |
#root_el ⇒ Object (readonly) Also known as: __rootel__
Returns the value of attribute root_el.
40 41 42 |
# File 'lib/selenium_record/base.rb', line 40 def root_el @root_el end |
Class Method Details
.extract_klass(subject, opts) ⇒ SeleniumRecord::Base
94 95 96 97 98 |
# 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 |
Instance Method Details
#create_record(object, opts = {}) ⇒ Object
Creates a view in the scope of current instance based on object model
passed as parameter
64 65 66 67 68 |
# 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 = {}) ⇒ Object
Creates a view in the scope of current instance based on the action name
77 78 79 80 |
# 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? ⇒ Boolean
Returns whether the view is attached to the dom
83 84 85 86 |
# File 'lib/selenium_record/base.rb', line 83 def exist? load_dom if respond_to? :lookup_sequence root_el != nil end |