I'm trying to write tests for managing focus in a dialog modal. How to simulate pressing the keyboard Tab
key in Rspec Capybara?
CodePudding user response:
Use the send_keys
method, eg:
body = find('body')
body.send_keys(:tab)
body.send_keys([:shift, :tab])
Out of all the capybara docs pages for send_keys
, the Capybara::Node::Element class has the best write up.