4

I need to move my physical mouse pointer. I am using selenium and c#.

Actions action = new Actions(driver);
action.MoveByOffset(500, 500).ContextClick().Build().Perform();
//action.MoveToElement(element).ContextClick().Build().Perform();

Both MoveByOffset and MoveToElement are performing the right-click but the mouse pointer is not moving.

6
  • Why do you want to move your mouse pointer physically? Update the question with your exact usecase and relevant HTML please. Commented Mar 27, 2018 at 7:41
  • I need to show the mouse pointer moving and performing the task Commented Mar 27, 2018 at 7:43
  • But then how would you validate mouse pointer moving or not? Commented Mar 27, 2018 at 7:44
  • I don't need to validate mouse movements. My tests are already doing it. I just need to show the mouse movements visually. Commented Mar 27, 2018 at 7:48
  • I think it's a lot of work, you can have a look here: stackoverflow.com/questions/46231617/… Commented Mar 27, 2018 at 8:05

1 Answer 1

3

Answering From Java Perspective

No you can't show the mouse pointer moving and performing the task using the Actions Class.

The Java Docs of Actions Class clearly mentions that while Automation through Selenium you should use Actions class only for emulating complex user gestures and but not for using the Keyboard or Mouse directly.

To interact with the the Keyboard or Mouse directly i.e. to generate native system input events for the purposes of Test Automation where control of the mouse and keyboard is needed you should use the Robot Class instead.

You can find a detailed discussion in Why do we need Robot class when we have Actions class in selenium

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.