开发者

How to simulate CTRL+Click with watir-webdriver?

I want to simulate ctrl keydown and c开发者_StackOverflowtrl 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.


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!


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/


After some playing around with Ruby 1.9.2 and the Watir Webdriver I found this worked for sending multiple keys to the browser simultaneously:

browser.send_keys [:alt, :arrow_left]

OS: Win64 Browser: Firefox

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜