twalpole / apparition

Capybara driver for Chrome using CDP
MIT License
363 stars 46 forks source link

Filling the "ß" Character causes Error #6

Closed 3wille closed 5 years ago

3wille commented 5 years ago

Hey there, thanks for your project 👍 I ran into an issue when filling the german letter ß. The error shown by rspec is

Failure/Error: fill_in "Street", with: "Retourestraße"

Capybara::Apparition::KeyError:
       Unknown key: ß

The screenshot generated shows that fill_in successfully filled every character until the ß: Screen Shot 2019-03-21 at 16 09 58 This happens in any spec where we use this character and it also happens for other german special characters like ü. Here is the stacktrace from the point where fill_in is called with that character:

     # ./vendor/bundle/ruby/2.5.0/gems/apparition-0.1.0/lib/capybara/apparition/page/keyboard.rb:106:in `key_description'
     # ./vendor/bundle/ruby/2.5.0/gems/apparition-0.1.0/lib/capybara/apparition/page/keyboard.rb:22:in `press'
     # ./vendor/bundle/ruby/2.5.0/gems/apparition-0.1.0/lib/capybara/apparition/page/keyboard.rb:76:in `block (2 levels) in type_with_modifiers'
     # ./vendor/bundle/ruby/2.5.0/gems/apparition-0.1.0/lib/capybara/apparition/page/keyboard.rb:75:in `each_char'
     # ./vendor/bundle/ruby/2.5.0/gems/apparition-0.1.0/lib/capybara/apparition/page/keyboard.rb:75:in `block in type_with_modifiers'
     # ./vendor/bundle/ruby/2.5.0/gems/apparition-0.1.0/lib/capybara/apparition/page/keyboard.rb:72:in `each'
     # ./vendor/bundle/ruby/2.5.0/gems/apparition-0.1.0/lib/capybara/apparition/page/keyboard.rb:72:in `type_with_modifiers'
     # ./vendor/bundle/ruby/2.5.0/gems/apparition-0.1.0/lib/capybara/apparition/page/keyboard.rb:14:in `type'
     # ./vendor/bundle/ruby/2.5.0/gems/apparition-0.1.0/lib/capybara/apparition/node.rb:238:in `send_keys'
     # ./vendor/bundle/ruby/2.5.0/gems/apparition-0.1.0/lib/capybara/apparition/node.rb:432:in `set_text'
     # ./vendor/bundle/ruby/2.5.0/gems/apparition-0.1.0/lib/capybara/apparition/node.rb:121:in `set'
     # ./vendor/bundle/ruby/2.5.0/gems/capybara-3.14.0/lib/capybara/node/element.rb:119:in `block in set'
     # ./vendor/bundle/ruby/2.5.0/gems/capybara-3.14.0/lib/capybara/node/base.rb:83:in `synchronize'
     # ./vendor/bundle/ruby/2.5.0/gems/capybara-3.14.0/lib/capybara/node/element.rb:119:in `set'
     # ./vendor/bundle/ruby/2.5.0/gems/capybara-3.14.0/lib/capybara/node/actions.rb:90:in `fill_in'
     # ./vendor/bundle/ruby/2.5.0/gems/capybara-3.14.0/lib/capybara/session.rb:744:in `block (2 levels) in <class:Session>'
     # ./vendor/bundle/ruby/2.5.0/gems/capybara-3.14.0/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
     # ./spec/features/some_spec:120:in `fill_in_address'

Versions: apparition: 0.1.0 and 1f57ba0 capybara: 3.14.0 chrome: 73.0.3683.67 (Official Build) beta (64-bit) OS: MacOS 10.14.3 (18D109)

The same specs run fine with selenium and chromedriver-helper. Thanks for any help 👍

twalpole commented 5 years ago

@3wille Thanks for the issue report. PR #7 should "fix" the issue and correctly set the character in an input. Please give it a try and let me know. There is a slight issue in that the key code may not be set correctly in key events (may not matter in your use case). A more complete solution would be to update the key definitions at https://github.com/twalpole/apparition/blob/master/lib/capybara/apparition/page/keyboard.rb#L147 with the correct info for the german specific keyboard keys. If you have the relevant info available a PR would be appreciated, or if you could point me to german keyboard info that would also work.

twalpole commented 5 years ago

Closing since this was fixed by PR #7