我正在尝试测试我的webapp,其中显示了js通知:
$("#bx-pager").bxSlider({
slideWidth: 275,
minSlides: 3,
maxSlides: 3,
slideMargin: 0,
controls: true,
pager: false,
infiniteLoop: false,
prevText: "",
nextText: ""
});
。然后我需要测试当我点击它时是否发生了某些行为。如何在javascript中模拟用户点击通知?
答案 0 :(得分:0)
存储构建后获得的通知对象。然后您可以执行任何操作
var notification = new Notification('test', {
icon: 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png',
body: 'this is body of the notification'
});
notification.onclick = function() { alert('got clicked'); } //handler
var event = new Event('click'); //event creation
notification.dispatchEvent(event); //triggering