How to simulate CTRL + Click using watir-webdriver?

I want to simulate ctrl keydown and ctrl keyup.

My use case is as follows:

The user can select from the list (build using the table) several elements by pressing the CTRL key and clicking the desired line. When the CTRL key is released, an AJAX call will be made.

I need a watir test to simulate this. How can i do this? Any ideas? I need a solution that works under Linux

Thank you very much.

+4
source share
3 answers

I believe the best way to send commands is to do the following:

require 'watir-webdriver'

browser.send_keys[:control].send_keys[: arrow_up] browser.send_keys[:control].send_keys[: arrow_down]

If you want to check out a few more key options, here is the link:

Link to other keypress options

Hope this helps!

+5
source

Understanding that this is old, but the original question was not completely answered how I did it:

browser.a.click (: control)

If you are on a Mac, you can use the command :.

See http://watirwebdriver.com/sending-special-keys/

+4
source

After some games with Ruby 1.9.2 and Watir Webdriver, I found that it worked to send multiple keys to the browser at the same time:

 browser.send_keys [:alt, :arrow_left] 

OS: Win64 Browser: Firefox

+2
source

All Articles