mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Use geckodrivers is_element_displayed endpoint when available
This commit is contained in:
parent
1ffe240c2c
commit
28d845facd
2 changed files with 14 additions and 0 deletions
|
@ -5,12 +5,20 @@ require 'capybara/selenium/nodes/firefox_node'
|
|||
module Capybara::Selenium::Driver::FirefoxDriver
|
||||
def self.extended(driver)
|
||||
driver.extend Capybara::Selenium::Driver::W3CFirefoxDriver if w3c?(driver)
|
||||
bridge = driver.send(:bridge)
|
||||
bridge.extend Capybara::Selenium::IsDisplayed unless bridge.commands(:is_element_displayed)
|
||||
end
|
||||
|
||||
def self.w3c?(driver)
|
||||
(defined?(Selenium::WebDriver::VERSION) && (Selenium::WebDriver::VERSION.to_f >= 4)) ||
|
||||
driver.browser.capabilities.is_a?(::Selenium::WebDriver::Remote::W3C::Capabilities)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def bridge
|
||||
browser.send(:bridge)
|
||||
end
|
||||
end
|
||||
|
||||
module Capybara::Selenium::Driver::W3CFirefoxDriver
|
||||
|
|
|
@ -65,6 +65,12 @@ class Capybara::Selenium::FirefoxNode < Capybara::Selenium::Node
|
|||
click unless selected_or_disabled
|
||||
end
|
||||
|
||||
def visible?
|
||||
return super if ENV['DISABLE_CAPYBARA_SELENIUM_OPTIMIZATIONS']
|
||||
|
||||
bridge.send(:execute, :is_element_displayed, id: native.ref)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def click_with_options(click_options)
|
||||
|
|
Loading…
Reference in a new issue