我需要捕获按钮上的点击事件并仅更改事件Actions a=new Actions(driver);
a.moveToElement(driver.findElement(By.cssSelector("#twotabsearchtextbox"))).keyDown(Keys.SHIFT).sendKeys("hello").build().perform();
并再次调度
与jquery类似,但我想在angular
type
我能够做button.on("click", function(event) {
var newEvent = $.extend({}, event, { type: "dxcontextmenu" });
event.stopPropagation();
$(this).trigger(newEvent);
});
,但是dispatchEvent
或Event
构造函数没有MouseEvent
或screenX
或...的参数。
我尝试使用传播运算符或clientX
,但只会复制Object.Assign
和isTrusted
属性。
我的代码是
type
这是stackblitz的链接
答案 0 :(得分:1)
在其他人遇到相同问题的情况下,我找到了解决方法
openContextMenu(event: MouseEvent)
{
if (event.target)
{
const newEvent = new MouseEvent('dxcontextmenu', { bubbles: true });
newEvent.initMouseEvent(
'dxcontextmenu',
true,
false,
event.view,
event.detail,
event.screenX,
event.screenY,
event.clientX,
event.clientY,
event.ctrlKey,
event.altKey,
event.shiftKey,
event.metaKey,
event.button,
event.relatedTarget
);
event.stopPropagation();
event.target.dispatchEvent(newEvent);
}
}