Module: Kirchhoff::CommonInterface
- Included in:
- Driver, Selenium::WebDriver::Element
- Defined in:
- lib/kirchhoff/common_interface.rb
Instance Method Summary collapse
- #find(selector, maybe: true, wait: true) ⇒ Object
- #find_text(text, maybe: true, wait: true) ⇒ Object
- #multi_find(selector) ⇒ Object
- #multi_find_text(text) ⇒ Object
- #to_nokogiri ⇒ Object
Instance Method Details
#find(selector, maybe: true, wait: true) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/kirchhoff/common_interface.rb', line 3 def find selector, maybe: true, wait: true e = wait ? self.waiter.until { weak_find(selector) } : weak_find(selector) Kirchhoff::Logger.call :info, "find #{selector}..." block_given? ? yield(e) : e rescue Selenium::WebDriver::Error::NoSuchElementError, Selenium::WebDriver::Error::TimeOutError unless maybe raise Selenium::WebDriver::Error::NoSuchElementError, "selector: #{selector}" end end |
#find_text(text, maybe: true, wait: true) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/kirchhoff/common_interface.rb', line 21 def find_text text, maybe: true, wait: true e = wait ? self.waiter.until { weak_find_text(text) } : weak_find_text(text) Kirchhoff::Logger.call :info, "find text '#{text}'..." block_given? ? yield(e) : e rescue Selenium::WebDriver::Error::NoSuchElementError, Selenium::WebDriver::Error::TimeOutError unless maybe raise Selenium::WebDriver::Error::NoSuchElementError, "text: #{text}" end end |
#multi_find(selector) ⇒ Object
15 16 17 18 19 |
# File 'lib/kirchhoff/common_interface.rb', line 15 def multi_find selector weak_multi_find(selector).tap do Kirchhoff::Logger.call :info, "multi find #{selector}..." end end |
#multi_find_text(text) ⇒ Object
33 34 35 36 37 |
# File 'lib/kirchhoff/common_interface.rb', line 33 def multi_find_text text weak_multi_find_text(text).tap do Kirchhoff::Logger.call :info, "multi find text '#{text}'..." end end |
#to_nokogiri ⇒ Object
39 40 41 |
# File 'lib/kirchhoff/common_interface.rb', line 39 def to_nokogiri Nokogiri::HTML self.to_html end |