TestProject Forum
Powered by leading experts in the test automation community

Click at [X, Y] coordinates

How can I click at certain coordinates on my webpage with selenium ?

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

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.

moveToElement(WebElement toElement, int xOffset, int yOffset)

Moves the mouse to an offset from the top-left corner of the element.

For example:

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

Thanks, that did the trick :wink: