Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geckodriver is not returning expected element coordinates #331

Closed
ghost opened this issue Nov 10, 2016 · 4 comments
Closed

Geckodriver is not returning expected element coordinates #331

ghost opened this issue Nov 10, 2016 · 4 comments

Comments

@ghost
Copy link

ghost commented Nov 10, 2016

Dear Geckodriver team,

I'm using the following environment:

  • Windows 10
  • Firefox 49.0.2
  • Geckodriver 0.11.1
  • Selenium 3.0.1

When I lookup a WebElement, get it's coordinates and move the mouse to this position, it is not moved to the expected place.

I've attached a short example by opening the Google entry page and moving the mouse pointer to the upper left corner of the SearchField.

MoveMouse.java.txt

Additionally I also attached a screenshot of the current result, when executing this script. x-coordinate looks ok, but y-coordinate is way to small.

elementcoordinatesnotcorrect

Any idea, where this might result from?

Thanks and regards
mgavilan

@leonard84
Copy link

If you want to use java.awt.Robot you need to take into account that the coordinates reported by webdriver are relative to the rendered website not the OS. So you need to correct for the title and url-bar. My recommendation is to use https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/interactions/Actions.html instead

@ghost
Copy link
Author

ghost commented Nov 12, 2016

@leonard84: Thanks a lot for this hint. I immediatelly tried the alternative way using Selenium Actions, this is my short example:

MoveMouse_WithActions.txt

As you can see, I'm using moveToElement() to get the mouse moved over the SearchField and sendKeys() to enter some search term.
None of both is resulting in the expected behaviour, as nothing else happens after opening the web page.

Is this maybe still a lack of functionality with the new geckodriver to support Selenium Actions?

Thanks and regards
mgavilan

@leonard84
Copy link

@mgavilan yes I also stumbled on this issue today, Actions are not support atm see #233

@andreastt
Copy link
Contributor

You say that geckodriver is not returning the expected coordinates, yet you omit what the return value of driver.findElement(By.id("sbtc")).getLocation() is.

@leonard84 is correct that WebDriver is meant to return an element’s location relative to the viewport and not the screen and that the actions API is not implemented in geckodriver yet.

I’m going to go ahead and close this issue as getting coordinates with geckodriver works to the extent of my knowledge. Please let me know if you think this is a mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants