IWebElement element = driver.FindElement(By.XPath("//img[@name='jack']"));
new Actions(driver).MoveToElement(element).Perform();
ILocatable loc = (ILocatable)element;
IMouse mouse = ((IHasInputDevices)driver).Mouse; // Converting driver as a Mouse
mouse.ContextClick(loc.Coordinates); //Right Click
IKeyboard key = ((IHasInputDevices)driver).Keyboard; // Converting driver as a Keyboard
key.SendKeys("w");
Hi Anjaneyulu,
ReplyDeleteIs it possible to send the code by using JAVA. I have tried a lot but no use.
my requirement is i need to right click on a selected item and i want to select any of the option in the right click context menu options.
Java Equivalent:
ReplyDeleteActions action= new Actions(this.driver);
action.moveToElement(element).perform();
Locatable loc = (Locatable)element;
Mouse mouse = ((HasInputDevices)this.driver).getMouse(); // Converting driver as a Mouse
mouse.contextClick(loc.getCoordinates()); //Right Click
Keyboard key = ((HasInputDevices)this.driver).getKeyboard(); // Converting driver as a Keyboard
key.sendKeys("w");
Anyone had any luck with this? I'm using Java and i would like it to right click on a flash game but the right click only wants to open in the top left of the browser. Any tips would be appreciated.
ReplyDelete