Check if field is already focused when sending keys with FF

This commit is contained in:
Thomas Walpole 2020-12-28 09:18:18 -08:00
parent 46b5a1fc4a
commit 3a471e5f0a
2 changed files with 7 additions and 2 deletions

View File

@ -66,7 +66,7 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
end
end
processed_options = options.reject { |key, _val| SPECIAL_OPTIONS.include?(key) }
@browser = Selenium::WebDriver.for(options[:browser], processed_options)
@browser = Selenium::WebDriver.for(options[:browser], **processed_options)
specialize_driver
setup_exit_handler

View File

@ -40,11 +40,16 @@ class Capybara::Selenium::FirefoxNode < Capybara::Selenium::Node
path_names.each { |path| native.send_keys(path) }
end
def focused?
driver.evaluate_script('arguments[0] == document.activeElement', self)
end
def send_keys(*args)
# https://github.com/mozilla/geckodriver/issues/846
return super(*args.map { |arg| arg == :space ? ' ' : arg }) if args.none?(Array)
native.click
native.click unless focused?
_send_keys(args).perform
end