如何在硒测试中右键单击
我在接缝中使用了 recursiveTreeNodesAdaptor 。我想通过 contextMenu 添加该树的子级,当用户单击树的右侧节点时打开上下文菜单,然后单击左侧然后打开模式面板。我想做这个。
当我尝试编写硒测试此流程时,我不会单击来装配并打开 contextMenu。我尝试 selenium.contextmenu(xpath) 但失败了。
那么,如何单击右侧
我尝试使用用户扩展来模拟右键单击。我的函数如下:
Selenium.prototype.doContextMenuClick = function(element){
var evt = document.createEvent('MouseEvents');
var RIGHT_CLICK_BUTTON_CODE = 2; // the same for FF and IE
evt.initMouseEvent('contextmenu', true, true,
document.defaultView, 1, 0, 0, 0, 0, false,
false, false, false, RIGHT_CLICK_BUTTON_CODE, null);
if (document.createEventObject){
// dispatch for IE
return document.fireEvent('onclick', evt);
}
else{
// dispatch for firefox + others
return !document.dispatchEvent(evt);
}};
我设法从 IDE 调用该函数。但是,现在,我收到错误“this.waitForCondition 不是函数”。怎么了?你有什么想法吗?
提前致谢。
I have using recursiveTreeNodesAdaptor in seam. And I want to add child this tree via contextMenu and when user click right node of tree open context menu and click left then open modal panel. I want to do this.
When I try to write selenium test this flow I dont click to rigt and open contextMenu. I try to selenium.contextmenu(xpath) but i'm fail.
So, How can I click to right
I tried to simulate right click with user extension. My function is below:
Selenium.prototype.doContextMenuClick = function(element){
var evt = document.createEvent('MouseEvents');
var RIGHT_CLICK_BUTTON_CODE = 2; // the same for FF and IE
evt.initMouseEvent('contextmenu', true, true,
document.defaultView, 1, 0, 0, 0, 0, false,
false, false, false, RIGHT_CLICK_BUTTON_CODE, null);
if (document.createEventObject){
// dispatch for IE
return document.fireEvent('onclick', evt);
}
else{
// dispatch for firefox + others
return !document.dispatchEvent(evt);
}};
I managed to call the function from IDE. But, now, I get the error "this.waitForCondition is not a function". What's wrong? Do you have any idea?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试在该元素上使用 fireEvent 。
您还应该看看这篇文章,它似乎差不多问题。
Try using fireEvent on that element.
You should also take a look at this post which seems to be about the same issue.
最新的 selenium 有一个名为 OpenQA.Selenium.Interactions Namespace 的命名空间。请查看此处。
请参阅我的另一篇文章此处
The latest selenium has a namespace called OpenQA.Selenium.Interactions Namespace. check it out here.
see my other post here