selenium webdriver – How to move mouse pointer outside of the actual web page

It appears the test case in this situation is to “show a pop-up modal to the user if the app sees the mouse leaving the document window”.

Selenium is only able to use the mouse while inside the document window (DOM) of the browser. It is not able to move the mouse outside the document window to interact with the browser address bar, back/forward/refresh buttons, etc. That’s why there are built-in commands to do those tasks for you.

From the Selenium docs:

Mouse represents a mouse event. Mouse actions are performed by using low-level interface which allows us to provide virtualized device input action to the web browser.

In other words, it looks like a mouse cursor, but it’s a virtual mouse cursor. What you’re wanting to do is outside the scope of Selenium.

Keep in mind that this test case likely falls under the principle of “you can’t automate everything, nor should you automate everything.”

Read more here: Source link