【发布时间】:2011-09-20 14:51:54
【问题描述】:
我在接缝中使用了 recursiveTreeNodesAdaptor。我想通过 contextMenu 添加子树,当用户单击树的右节点打开上下文菜单并单击左然后打开模式面板时。我想这样做。
当我尝试编写 selenium 测试此流程时,我不会点击绑定并打开 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 不是函数”。怎么了?你有什么主意吗?
提前致谢。
【问题讨论】:
标签: selenium richfaces contextmenu right-click