Module: Aranha::Selenium::Session::Wait
- Defined in:
- lib/aranha/selenium/session/wait.rb
Constant Summary collapse
- WAIT_DEFAULT_TIMEOUT =
15
Instance Method Summary collapse
- #wait(timeout = nil) ⇒ Object
- #wait_default_timeout ⇒ Object
- #wait_for_click(find_element_args, timeout = nil) ⇒ Object
- #wait_for_download(timeout = nil) ⇒ Object
- #wait_for_element(find_element_args) ⇒ Object
- #wait_for_url_change(&block) ⇒ Object
Instance Method Details
#wait(timeout = nil) ⇒ Object
11 12 13 14 |
# File 'lib/aranha/selenium/session/wait.rb', line 11 def wait(timeout = nil) timeout ||= wait_default_timeout ::Selenium::WebDriver::Wait.new(timeout: timeout) end |
#wait_default_timeout ⇒ Object
16 17 18 |
# File 'lib/aranha/selenium/session/wait.rb', line 16 def wait_default_timeout WAIT_DEFAULT_TIMEOUT end |
#wait_for_click(find_element_args, timeout = nil) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/aranha/selenium/session/wait.rb', line 20 def wait_for_click(find_element_args, timeout = nil) wait(timeout).until do element = find_element(find_element_args) element ? element_click(element) : nil end end |
#wait_for_download(timeout = nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/aranha/selenium/session/wait.rb', line 31 def wait_for_download(timeout = nil) initial_downloads = downloads.current yield new_downloads = [] wait(timeout).until do new_downloads = downloads.current - initial_downloads new_downloads.any? end new_downloads.first end |
#wait_for_element(find_element_args) ⇒ Object
27 28 29 |
# File 'lib/aranha/selenium/session/wait.rb', line 27 def wait_for_element(find_element_args) wait.until { find_element(find_element_args) } end |
#wait_for_url_change(&block) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/aranha/selenium/session/wait.rb', line 42 def wait_for_url_change(&block) previous_url = current_url block&.call wait.until { current_url != previous_url } end |