Module: OnlyofficeWebdriverWrapper::WebdriverNavigationMethods
- Extended by:
- Gem::Deprecate
- Included in:
- WebDriver
- Defined in:
- lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_navigation_methods.rb
Overview
Methods for webdriver navigations
Instance Method Summary collapse
-
#current_url ⇒ String
(also: #get_url)
Url of current frame, or browser url if it is a root frame.
-
#go_back ⇒ nil
Go back like pressing ‘Back` button in browser.
-
#open(url) ⇒ nil
Open specific url.
-
#quit ⇒ nil
Quit current browser session.
-
#refresh ⇒ nil
Refresh current page.
Instance Method Details
#current_url ⇒ String Also known as: get_url
Returns url of current frame, or browser url if it is a root frame.
23 24 25 26 27 |
# File 'lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_navigation_methods.rb', line 23 def current_url execute_javascript('return window.location.href') rescue Selenium::WebDriver::Error::NoSuchFrameError, Timeout::Error => e raise(e.class, "Browser is crushed or hangup with #{e}") end |
#go_back ⇒ nil
Go back like pressing ‘Back` button in browser
42 43 44 45 |
# File 'lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_navigation_methods.rb', line 42 def go_back @driver.navigate.back OnlyofficeLoggerHelper.log('Go back to previous page') end |
#open(url) ⇒ nil
Open specific url
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_navigation_methods.rb', line 9 def open(url) url = "http://#{url}" unless url.include?('http') || url.include?('file://') ensure_url_available(url) @driver.navigate.to url sleep(1) # Correct wait for Page to init focus OnlyofficeLoggerHelper.log("Opened page: #{url}") rescue StandardError => e = "Received error `#{e}` while opening page `#{url}`" OnlyofficeLoggerHelper.log() raise e.class, , e.backtrace end |
#quit ⇒ nil
Quit current browser session
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_navigation_methods.rb', line 49 def quit return unless browser_running begin @driver.execute_script('window.onbeforeunload = null') # off popup window rescue StandardError StandardError end begin @driver.quit rescue StandardError => e OnlyofficeLoggerHelper.log("Some error happened on webdriver.quit #{e.backtrace}") end alert_confirm @headless.stop cleanup_download_folder @browser_running = false end |
#refresh ⇒ nil
Refresh current page
35 36 37 38 |
# File 'lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_navigation_methods.rb', line 35 def refresh @driver.navigate.refresh OnlyofficeLoggerHelper.log('Refresh page') end |