我对使用量角器的e2e测试完全陌生。 我的问题是,当我运行我的测试用例时如何显示/显示光标移动。我在谷歌搜索过,我没有得到任何结果。帮助我。
答案 0 :(得分:2)
我通过注入一个跟踪鼠标事件的addMockModule
模块并在事件坐标处创建临时固定点来完成它:
onPrepare: function() {
// track mouse movements
var trackMouse = function() {
angular.module('trackMouse', []).run(function($document) {
function addDot(ev) {
var color = 'black',
size = 6;
switch (ev.type) {
case 'click':
color = 'red';
break;
case 'dblclick':
color = 'blue';
break;
case 'mousemove':
color = 'green';
break;
}
var dotEl = $('<div></div>')
.css({
position: 'fixed',
height: size + 'px',
width: size + 'px',
'background-color': color,
top: ev.clientY,
left: ev.clientX,
'z-index': 9999,
// make sure this dot won't interfere with the mouse events of other elements
'pointer-events': 'none'
})
.appendTo('body');
setTimeout(function() {
dotEl.remove();
}, 1000)
}
$document.on({
click: addDot,
dblclick: addDot,
mousemove: addDot
});
});
};
browser.addMockModule('trackMouse', trackMouse);
},