mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Check if field is already focused when sending keys with FF
This commit is contained in:
parent
46b5a1fc4a
commit
3a471e5f0a
2 changed files with 7 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue