Friday 18 November 2011

Working with Mouse Click in selenium webdriver using CSharp

In the below script , i am trying to click on image having name=jack.

Before to do this, we hav to include OpenQA.Selenium.Interactions  namespace  

IWebElement element = driver.FindElement(By.XPath("//img[@name='jack']"));
new Actions(driver).MoveToElement(element).Perform(); //Here i am moving driver to that element.
ILocatable loc = (ILocatable)element;       // Here i am getting co-ordinates of that element.
 IMouse mouse = ((IHasInputDevices)driver).Mouse; // Here i am converting driver as a mouse device.
 mouse.Click(loc.Coordinates);    //Here driver click on that coordinates.

3 comments:

  1. It works perfectly for me in chrome and firefox just not working in ie

    ReplyDelete
  2. Hi Anjaneyulu,

    I am not able to convert it into JAVA. Please attached same code in JAVA also.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete