Selenium WebDriver - 如何按住鼠标右键? [英] Selenium WebDriver - How to Holds down the RIGHT mouse button?

查看:1059
本文介绍了Selenium WebDriver - 如何按住鼠标右键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Selenium 2.0 WebDriver(java),我需要测试一些导航(旋转,平移......)

Using Selenium 2.0 WebDriver (java), I need to test some navigation (rotate, pan...)

我需要能够保持正确移动鼠标时按钮。

I need to be able to Holds down the RIGHT button while moving the mouse.

同样,我需要能够在移动鼠标的同时按住MIDDLE按钮。

Similarly, I need to be able to holds down the MIDDLE button while moving the mouse.

似乎只能使用LEFT按钮。

It seems to be possible only with the LEFT button.

Actions actions = new Actions(driver);
actions.clickAndHold().perform();

以下问题,我没有处理任何菜单,按钮,小部件,但是像3D环境一样GoogleMap,我需要使用MIDDLE按钮,RIGHT按钮甚至鼠标滚轮模拟平移,旋转和缩放...

Following question, i'm not dealing with any menu, button, widget but with a 3D Environment like GoogleMap where I need to simulate pan, rotate and zoom using MIDDLE button, RIGHT button and even Mouse wheel...

任何帮助?

推荐答案

您可以使用机器人类来执行相同操作。
对于右键单击使用Button3和中间使用Button2

You can use robot class to perform same. For Right click use Button3 and for middle use Button2

右键单击代码

Robot robot=new Robot();
robot.mousePress(InputEvent.BUTTON3_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK);

中键代码

Robot robot=new Robot();
robot.mousePress(InputEvent.BUTTON2_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON2_DOWN_MASK);

这篇关于Selenium WebDriver - 如何按住鼠标右键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆