Selenium 2.2 中的上下文单击
在 Selenium 2 中使用高级用户交互 API 打开自定义上下文菜单时遇到问题 (http:// code.google.com/p/selenium/wiki/AdvancedUserInteractions)。
这是 C# 代码:
var driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.flickr.com/photos/davidcampbellphotography/4581594452/");
IWebElement photoDiv = driver.FindElement(By.Id("photo"));
Actions actions = new Actions(driver);
var context = actions.ContextClick(photoDiv).Build();
context.Perform();
该代码仍然不会打开上下文菜单,而只是单击图像。
还有许多其他交互工作正常,例如 这篇博文。
我在 Windows XP 上使用 Firefox 5,Selenium 版本 2.2。
预先感谢您提供有关如何使其发挥作用的任何建议。
更新: 但是,此处的代码执行相同的操作(左键单击而不是上下文单击)。
ILocatable loc = (ILocatable)photoDiv;
IMouse mouse = ((IHasInputDevices)driver).Mouse;
mouse.ContextClick(loc.Coordinates);
mouse.MouseMove(loc.Coordinates, 15, 15);
看起来像一个错误。
Got problem with opening custom context menu using advanced user interactions API in Selenium 2 (http://code.google.com/p/selenium/wiki/AdvancedUserInteractions).
Here is C# code:
var driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.flickr.com/photos/davidcampbellphotography/4581594452/");
IWebElement photoDiv = driver.FindElement(By.Id("photo"));
Actions actions = new Actions(driver);
var context = actions.ContextClick(photoDiv).Build();
context.Perform();
Still this code doesn't open context menu but simply clicks on the image.
Still many other interactions work fine, like those at this blogpost.
I'm using Firefox 5 on Windows XP, Selenium version 2.2.
Thanks in advance for any suggestions how to make it work.
UPDATE:
However, the code from here does the same (left click instead of context click).
ILocatable loc = (ILocatable)photoDiv;
IMouse mouse = ((IHasInputDevices)driver).Mouse;
mouse.ContextClick(loc.Coordinates);
mouse.MouseMove(loc.Coordinates, 15, 15);
Looks like a bug.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过使用机器人点击,虽然它们不是最有效的方式,但只要浏览器窗口是顶部窗口,它就会点击您设置的坐标
也许这会对您有所帮助:-)
Have you tried using a robot click, Although they're not the most efficient way of doing so, but as long as the browser window is the top window it'll click the co-ordinates you set
Maybe this will help you :-)
这似乎就是那个错误。
它在用户组
This seems to be that bug.
It is stated in the user group here, though the bug is about double click.