MouseEvent clientX Property
The clientX is a read-only property of the MouseEvent interface which provides the horizontal coordinate within the application's viewport at which the event occurred (instead of the coordinate within the page).
As an example to retrieve the clientX coordinate of the mouse pointer while the mouse pointer moves you can use:
let x = event.clientX;
MouseEvent clientY Property
The clientY is a read-only property of the MouseEvent interface which provides the vertical coordinate within the application's viewport at which the event occurred (instead of the coordinate within the page).
As an example to retrieve the clientY coordinate of the mouse pointer while the mouse pointer moves you can use:
let y = event.clientY;
This usecase
To print clickCoordinates whenever click event occurs you can use the following solution:
result = driver.execute_script("""
function clickHandler(e) {
console.log(e)
console.log(e.clientX)
console.log(e.clientY)
var clickCoordinates = e.clientX + ',' + e.clientY;
console.log(clickCoordinates)
return clickCoordinates
}
document.addEventListener('click', clickHandler);
""")
print(result)
References
Link to useful documentations: