Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to simulate CTRL+Click with watir-webdriver?

I want to simulate ctrl keydown and ctrl keyup.

My use-case is the following:

The user can select from a list (build with a table) multiple elements by pressing CTRL key and clicking on the desired row. 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 would need a solution that works under Linux

Thanks a lot.

like image 490
Szilard Avatar asked Dec 16 '22 14:12

Szilard


2 Answers

I believe the best way to send comands would be 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 some more key options here is a link:

Link to other key stroke options

Hope this helps!

like image 138
Curtis Miller Avatar answered Feb 16 '23 17:02

Curtis Miller


Realising this is old, but the original question didn't quite get answered, the way I have completed this is to do:

browser.a.click(:control)

If you are on a mac system you may want to use :command.

See http://watir.com/guides/special-keys/

like image 34
Lloyd Watkin Avatar answered Feb 16 '23 17:02

Lloyd Watkin