Click at [X, Y] coordinates

  • 2 Replies
  • 1057 Views
Click at [X, Y] coordinates
« on: April 03, 2016, 18:31:05 pm »
How can I click at certain coordinates on my webpage with selenium ?

e.g. (x, y) = (52, 270)

*

Oren

  • **
  • 59
Re: Click at [X, Y] coordinates
« Reply #1 on: April 04, 2016, 15:19:49 pm »
You can initiate mouse movement with the Actions class, but you need another element to set offset from. It is not possible to click outside of the browser content window or control OS elements.

Code
moveToElement(WebElement toElement, int xOffset, int yOffset)
Moves the mouse to an offset from the top-left corner of the element.

For example:

Code
Actions builder = new Actions(driver);   
builder.moveToElement(myElement, 50, 275).click().build().perform();

Re: Click at [X, Y] coordinates
« Reply #2 on: April 07, 2016, 17:32:47 pm »
Thanks, that did the trick ;)

 

Sitemap 1 2 3 4 5 6 7 8