Module: Capybara::Selenium::Driver::W3CFirefoxDriver
- Defined in:
- lib/capybara/selenium/driver_specializations/firefox_driver.rb
Class Method Summary collapse
Instance Method Summary collapse
- #refresh ⇒ Object
- #reset! ⇒ Object
- #resize_window_to(handle, width, height) ⇒ Object
- #switch_to_frame(frame) ⇒ Object
Class Method Details
.extended(driver) ⇒ Object
18 19 20 |
# File 'lib/capybara/selenium/driver_specializations/firefox_driver.rb', line 18 def extended(driver) require 'capybara/selenium/patches/pause_duration_fix' if pause_broken?(driver.browser) end |
.pause_broken?(sel_driver) ⇒ Boolean
22 23 24 |
# File 'lib/capybara/selenium/driver_specializations/firefox_driver.rb', line 22 def pause_broken?(sel_driver) sel_driver.capabilities['moz:geckodriverVersion']&.start_with?('0.22.') end |
Instance Method Details
#refresh ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/capybara/selenium/driver_specializations/firefox_driver.rb', line 56 def refresh # Accept any "will repost content" confirmation that occurs accept_modal :confirm, wait: 0.1 do super end rescue ::ModalNotFound # rubocop:disable Lint/HandleExceptions # No modal was opened - page has refreshed - ignore end |
#reset! ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/capybara/selenium/driver_specializations/firefox_driver.rb', line 38 def reset! # Use instance variable directly so we avoid starting the browser just to reset the session return unless @browser if browser_version >= 68 begin # Firefox 68 hangs if we try to switch windows while a modal is visible browser.switch_to.alert&.dismiss rescue Selenium::WebDriver::Error::NoSuchAlertError # rubocop:disable Lint/HandleExceptions # Swallow end end switch_to_window(window_handles.first) window_handles.slice(1..-1).each { |win| close_window(win) } super end |
#resize_window_to(handle, width, height) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/capybara/selenium/driver_specializations/firefox_driver.rb', line 27 def resize_window_to(handle, width, height) within_given_window(handle) do # Don't set the size if already set - See https://github.com/mozilla/geckodriver/issues/643 if window_size(handle) == [width, height] {} else super end end end |
#switch_to_frame(frame) ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/capybara/selenium/driver_specializations/firefox_driver.rb', line 65 def switch_to_frame(frame) return super unless frame == :parent # geckodriver/firefox has an issue if the current frame is removed from within it # so we have to move to the default_content and iterate back through the frames handles = @frame_handles[current_window_handle] browser.switch_to.default_content handles.tap(&:pop).each { |fh| browser.switch_to.frame(fh.native) } end |