2

So I've got a bing map on my web page and the user can draw a area which they want to search with in by clicking on the points and closing the shape up.

I'm trying to automate this using webdriver however when I call click it clicks in the middle of the map.

It is basically the same issue as this question but the problem is with the c# driver rather than the java.

Here is my code:

RemoteWebDriver driver = ScenarioContext.Current.Get<RemoteWebDriver>();

driver.FindElementById("location").SendKeys("London");
driver.FindElementById("find").Click();
driver.FindElementById("boundry").Click();

IWebElement map = driver.FindElementById("Map");

Actions actions = new Actions(driver);

actions
  .MoveToElement(map, -100, -100)
  .Click()
  .Build()
  .Perform();

actions
  .MoveToElement(map, -100, 100)
  .Click()
  .Build()
  .Perform();

actions
  .MoveToElement(map, 100, -100)
  .Click()
  .Build()
  .Perform();

actions
  .MoveToElement(map, 100, 100)
  .Click()
  .Build()
  .Perform();

actions
  .MoveToElement(map, -100, -100)
  .Click()
  .Build()
  .Perform();

What happens is the mouse moves to the correct position and then the click event resets the mouse pointer to the middle of the element.

Community
  • 1
  • 1
Mark Broadhurst
  • 2,675
  • 23
  • 45

1 Answers1

0

Try to take a close look at Click method. If it isn't helpful - see MouseDown method. Methods description you can find here http://selenium.googlecode.com/svn/trunk/docs/api/dotnet/index.html You need OpenQA.Selenium Namespace->IMouse Interface->IMouse Methods Hope it helps you!

Vlad Titov
  • 686
  • 1
  • 6
  • 15
  • I don't want to sound negative but the first link doesnt work and the second link doesn't have a MouseDown method on ? Assuming you are talking about the IMouse interface they both take an ICoordinates which you cannot create an instance of directly and AFAIK you can only get an instance on a RemoteWebElement – Mark Broadhurst Sep 20 '12 at 09:02