Javascript 编程点击JS通知
我正在尝试测试我的Web应用程序,其中显示js通知:Javascript 编程点击JS通知,javascript,selenium,testing,Javascript,Selenium,Testing,我正在尝试测试我的Web应用程序,其中显示js通知: 新通知(“标题”)。然后我需要测试当我点击它时是否发生了某些行为。如何在javascript中模拟用户单击通知?存储构建后获得的通知对象。然后您可以执行任何操作 var notification = new Notification('test', { icon: 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png', body: 'this is
新通知(“标题”)
。然后我需要测试当我点击它时是否发生了某些行为。如何在javascript中模拟用户单击通知?存储构建后获得的通知对象。然后您可以执行任何操作
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
可能重复的