Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

I want to click at x, y coordinates like 52, 216-52, 295. How can this be done using selenium. I am using Mac OSX 10.8.5 with Selenium 2.40.0 and Firefox version 29.0

share|improve this question

2 Answers 2

You can move the mouse and click with Actions, given you have a element to offset from. You cannot click outside the browser content window or control Operating System elements.

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

The code (Java) would look like this:

Actions builder = new Actions(driver);

builder.
   .moveToElement(knownElement 10, 25 );
   .click()
   .build().perform();
share|improve this answer
    
Can you use the window itself as a known element so that you can click on an absolute x,y position? If so, how do you reference the window? –  Doug Sep 13 at 23:21
    
@Doug I am not sure, but you could try the body element which should start in the upper left corner. If not please ask a new question, because its something new and different. –  Niels van Reijmersdal Sep 14 at 8:52

I needed to do this in javascript with protractor:

  browser.actions()
  .mouseMove(
    element(by.css('.material-dialog-container'))
    , -20, -20  // pixel offset from top left
  )
  .click()
  .perform();
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.