I want to get the current mouse location after an action in Selenium (click, move, page reload etc). Is there any way to do it and return the values to Python?
Asked
Active
Viewed 179 times
0
-
https://stackoverflow.com/questions/2601097/how-to-get-the-mouse-position-without-events-without-moving-the-mouse – Joran Beasley May 19 '21 at 19:46
-
Does this answer your question? [Selenium: get coordinates or dimensions of element with Python](https://stackoverflow.com/questions/15510882/selenium-get-coordinates-or-dimensions-of-element-with-python) – vitaliis May 20 '21 at 01:02
-
@JoranBeasley - Although I can add JS to Selenium, I haven't found a way just yet to return the values on Event. When I tried, the variables returned undefined. – cristina_gatt May 20 '21 at 04:40
-
@vitaliis: I am not moving to an element, I am moving by offset without knowledge on which element I'm landing on. I know it's not the conventional way how Selenium is used but this is the way I have to use it for the sake of the problem being solved. – cristina_gatt May 20 '21 at 04:42
-
the answer is NO there is no way to get the currentMousePosition ... in theory you could make a `document.on('mousemove` listener and update some global javascript variable(but it will only do anything when the mouse actually moves which doesnt usually happen with a selenium script) ... but this sounds like an XY problem... why do you think you need to get the mouse position? – Joran Beasley May 20 '21 at 06:47