Module: SeleniumRecord::Preconditions
- Included in:
- Base
- Defined in:
- lib/selenium_record/preconditions.rb
Overview
Selenium helpers for doing an action after a precondition takes place
Instance Method Summary collapse
-
#when_clickable(locator) ⇒ Selenium::WebDriver::Element
Once the element is clickable.
-
#when_hidden(locator) ⇒ Selenium::WebDriver::Element
Once the element is hidden.
- #when_modal_present(title, &block) ⇒ Object
-
#when_present(locator) ⇒ Object
Returns the first element matching the given arguments once this element is displayed in the DOM.
Instance Method Details
#when_clickable(locator) ⇒ Selenium::WebDriver::Element
Returns once the element is clickable.
22 23 24 25 26 |
# File 'lib/selenium_record/preconditions.rb', line 22 def when_clickable(locator) element = wait_clickable(locator) yield if block_given? element end |
#when_hidden(locator) ⇒ Selenium::WebDriver::Element
Returns once the element is hidden.
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/selenium_record/preconditions.rb', line 38 def when_hidden(locator) self.class.wait_for do begin element = root_el.find_element(locator) element unless element.displayed? rescue => error raise if error.is_a? Selenium::WebDriver::Error::TimeOutError true end end end |
#when_modal_present(title, &block) ⇒ Object
28 29 30 |
# File 'lib/selenium_record/preconditions.rb', line 28 def when_modal_present(title, &block) when_present(:xpath, modal_header_xpath(title), &block) end |
#when_present(locator) ⇒ Object
Returns the first element matching the given arguments once this element is displayed in the DOM
10 11 12 13 14 |
# File 'lib/selenium_record/preconditions.rb', line 10 def when_present(locator) element = wait_displayed(locator) yield if block_given? element end |