Module: SeleniumRecord::Lookup
- Included in:
- Base
- Defined in:
- lib/selenium_record/lookup.rb
Overview
Responsible methods for looking up the root element for each selenium object
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#lookup ⇒ Webdriver::Element
Searchs for root element of current object based on other element.
-
#lookup_sequence ⇒ Object
Clasess extending SeleniumRecord::Base should overwrite this method or call to class method ‘lookup_strategy` defined in `SeleniumRecord::Lookup` in order to search for Selenium::WebDriver::Element used as scope for finding elements inside the instance object.
-
#lookup_step(locator) ⇒ Object
Given the current root element for the view, applies a scoped search for the web element identified by the locator passed as parameter.
Class Method Details
.included(base) ⇒ Object
4 5 6 |
# File 'lib/selenium_record/lookup.rb', line 4 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#lookup ⇒ Webdriver::Element
Searchs for root element of current object based on other element
10 11 12 13 14 15 16 |
# File 'lib/selenium_record/lookup.rb', line 10 def lookup @root_el = parent_el || browser lookup_sequence.each { |locator| @root_el = lookup_step(locator) } rescue @root_el = nil raise end |
#lookup_sequence ⇒ Object
Clasess extending SeleniumRecord::Base should overwrite this method or call to class method ‘lookup_strategy` defined in `SeleniumRecord::Lookup` in order to search for Selenium::WebDriver::Element used as scope for finding elements inside the instance object
42 43 44 |
# File 'lib/selenium_record/lookup.rb', line 42 def lookup_sequence fail 'LookupUndefinedSequenceError' end |
#lookup_step(locator) ⇒ Object
Given the current root element for the view, applies a scoped search for the web element identified by the locator passed as parameter
30 31 32 33 34 35 36 |
# File 'lib/selenium_record/lookup.rb', line 30 def lookup_step(locator) lookup_elements = find_elements(locator) size = lookup_elements.size fail 'LookupMultipleElementsError' if size > 1 fail 'LookupUndefinedElementError' if size == 0 lookup_elements.first end |