Posted 8 months ago. Visible to the public.

Bug in Chrome 56 prevents filling in fields with slashes using selenium-webdriver/Capybara

There seems to be a nasty bug in Chrome 56 when testing with Selenium and Capybara: Slashes are not written to input fields with fill_in. A workaround is to use javascript / jquery to change the contents of an input field.

Use the following code or add the attached file to your features/support/-directory to overwrite fill_in.

Copy
module ChromedriverWorkarounds def fill_in(locator, options = {}) text = options[:with].to_s if Capybara.current_driver == :selenium && text.include?('/') # There is a nasty Bug in Chrome 56 which fails to write slashes into # text fields for unknown reasons. field = find_field(locator) id = field[:id].presence if id execute_script "$('##{id}').val(#{text.to_json}).change()" else raise "Tried to work around a Chromedriver bug, but that requires the #{locator.inspect} field to have an ID." end else super(locator, options) end end end World(ChromedriverWorkarounds)

makandra has been working exclusively with Ruby on Rails since 2007. Our laser focus on a single technology has made us a leader in this space.

Author of this card:

Avatar
Judith Roth
Last edit:
8 months ago
by Henning Koch
Attachments:
chromedriver.rb
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Judith Roth to makandropedia