Moving mouse pointer to a specific location or element using C# and Selenium

0 votes

I am performing a click operation using Selenium and C#.I am able to perform click operation but I am not able to move mouse pointer(cursor) to a specific co-ordinate or over specific element.

Below is the code I’m using.

Actions action = new Actions(driver);

action.MoveByOffset(500, 500).ContextClick().Perform();

Jun 25, 2018 in Selenium by Martin
• 4,210 points
2,683 views

2 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Rather than trying to get an element just move by offset. Make sure you know what your prior focus is... If none then it should be the top left corner of the page. Then put your sleep in the middle and you should be able to see the mouse move, wait, and then click.

Actions action = new Actions(driver);
action.MoveByOffset(200,100).Perform();
Thread.Sleep(10000);
action.Click();

answered Jun 25, 2018 by Samarpit
• 5,130 points
0 votes

Hi, I will Share my ideas.

Here is a piece of code where we can move the mouse pointer to a location and clicking on the moved region

import org.openqa.selenium.WebElement;

import org.openqa.selenium.interactions.Actions;

Actions builder = new Actions(driver);  

WebElement Element = driver.findElement(By.xpath("//div[@id='signUpModal']")); 

builder.moveToElement(Element, 100, 100).click().build().perform();

Note: The Pointer will move with reference to region of element described "Element"(Top left of Element region is considered as 0,0).

Click here for more information

answered Mar 18 by Ellen Dares

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

How to mouse hover on a web element using Selenium WebDriver?

Hello Nitin, to automate mouse hovering over ...READ MORE

answered May 7 in Selenium by Anvi
• 7,160 points
22 views
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
138 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
529 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
131 views
0 votes
1 answer

How To move physical mouse pointer in selenium and c#

You can't show the mouse pointer moving and ...READ MORE

answered Jun 4, 2018 in Selenium by Samarpit
• 5,130 points
629 views
+1 vote
1 answer

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.