Search code examples
htmlrubyseleniumcucumbercapybara

How do I send_keys a down arrow in capybara


I have a special listbox that I could automate best by sending a down arrow and pressing enter.

I can press enter like so:

listbox_example = find(input, "listbox-example")
listbox-example.set("stuff")
#down arrow command goes here
listbox-example.native.send_keys :return

How do I write the down arrow command?


Solution

  • If I remember correctly the correct way to send the down arrow command is to use arrow_down

    So your code should look like this

    listbox-example.native.sendkeys :arrow_down
    

    If you would like a list of all the available keys that you can send, then docs are your friend here

    http://www.ruby-doc.org/gems/docs/f/frameworks-capybara-0.2.18/SendKeys.html

    EDIT: This link might have the intended content. https://www.omniref.com/ruby/gems/frameworks-capybara/0.2.18/symbols/SendKeys