Please example of mouse clicks "dispatchMouseEvent".
PS: Many thanks for all the answers, and create an extensive wiki.
You just need to specify the right values, for example to simulate a click event you'll need to dispatch two separate events:
function click(client, x, y) {
const options = {
x: x,
y: y,
button: 'left',
clickCount: 1
};
options.type = 'mousePressed';
client.Input.dispatchMouseEvent(options);
options.type = 'mouseReleased';
client.Input.dispatchMouseEvent(options);
}
PS you're welcome!
do not click on andoid
Just tried and works, here's the test page:
<body>
<script>
const body = document.querySelector('body');
body.addEventListener('click', (e) => {
alert(`${e.clientX}, ${e.clientY}`);
});
</script>
</body>
FYI here's the wiki example using promises.
i click on mobail screen no show alert
I really don't know, it works with Chrome 54 on my Nexus 5. In any case I doubt it's a problem with this module. Try to debug the client-side JavaScript code.
i work in changed on addEventListener('touchend'
chrom 54 andoid 6
I have worked in this way:
function click(cri, x, y) {
const options = {
touchPoints: [{x:x,y:y, state:'touchPressed'}]
};
options.type = 'touchStart';
cri.Input.dispatchTouchEvent(options);
options.touchPoints[0].state = 'touchReleased';
options.type = 'touchEnd';
cri.Input.dispatchTouchEvent(options);
}
help position mouse in chage page (big grey border)
chrome.Page.setDeviceMetricsOverride({
width: 320,
height: 240,
deviceScaleFactor: 3,
mobile: true,
emulateViewport: true,
fitWindow: true
});
Page moves to the center of the screen, and coordinate the eyes remain the same. how to move the grid coordinates or to define the beginning of the axis on the page?
You should try to ask this in the [Google Group]; it's a bit off-topic here and I've never experimented too much with Page.setDeviceMetricsOverride.
Most helpful comment
You just need to specify the right values, for example to simulate a click event you'll need to dispatch two separate events:
PS you're welcome!