org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: (x, y) is out of bounds while MouseHover with GeckoDriver Firefox Selenium

org openqa selenium interactions movetargetoutofboundsexception move target out of bounds
org openqa selenium interactions movetargetoutofboundsexception cannot click on element

I am learning how to automate tests with Selenium WebDriver, however I got stuck and cannot make dropdown menu to work in Firefox. The same code runs perfectly fine in Chrome.

The site I am practicing on is: http://www.executeautomation.com/demosite/index.html and I want to click the following item from menu: Automation Tools > Selenium > Selenium WebDriver.

The error message suggest that the web element may not be loaded on the screen yet, so I have implemented some method to wait with every execution until the element shows up:

public static void ImplicitWait(WebDriver driver){
    driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
}

but it did not helped.

Then I read that it is better to "pipe" those moveToElement() methods instead of performing them one by one. So I changed this:

action.moveToElement(menu).perform();
action.moveToElement(selenium).perform();
action.moveToElement(seleniumWebDriver).click().build().perform();

to one line. At this point it started to work on Chrome, but I am still struggling to make it work on Firefox.

The current code looks like this:

System.setProperty("webdriver.gecko.driver", "C:\\Drivers\\geckodriver-v0.24.0-win64\\geckodriver.exe");
System.setProperty("webdriver.firefox.bin", "C:\\Program Files\\Mozilla Firefox\\firefox.exe");
WebDriver driver = new FirefoxDriver();

ImplicitWait(driver);

driver.navigate().to("http://executeautomation.com/demosite/index.html");

WebElement menu = driver.findElement(By.id("Automation Tools"));
WebElement selenium = driver.findElement(By.id("Selenium"));
WebElement seleniumWebDriver = driver.findElement(By.id("Selenium WebDriver"));

Actions action = new Actions(driver);
action.moveToElement(menu).moveToElement(selenium).moveToElement(seleniumWebDriver).click().build().perform();

As I mentioned above the same works fine when I switch to Chrome, but with Firefox I get the error message:

Exception in thread "main" org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: (-9862, 206) is out of bounds of viewport width (1283) and height (699)

I am using: * Firefox v66.0.2 * Java v1.8.0_201 * Selenium Java v3.141.59 * GeckoDriver v0.24.0

Please help.

MoveTargetOutOfBoundsException: Error Using Python, org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: (x, y) is out of bounds while MouseHover with GeckoDriver Firefox Selenium (5 answers). Closed 8 months ago. I am trying to crawl a website that has a� org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: (x, y) is out of bounds while MouseHover with GeckoDriver Firefox Selenium. Java

Use WebDriverWait and try the following code.

driver.get("http://executeautomation.com/demosite/index.html");
WebDriverWait wait = new WebDriverWait(driver, 20);
WebElement menu= wait.until(ExpectedConditions.elementToBeClickable(By.id("Automation Tools")));

Actions action = new Actions(driver);
action.moveToElement(menu).build().perform();
WebElement selenium =wait.until(ExpectedConditions.elementToBeClickable(By.id("Selenium"))); 
action.moveToElement(selenium).build().perform();
WebElement seleniumWebDriver =wait.until(ExpectedConditions.elementToBeClickable(By.id("Selenium WebDriver")));
action.moveToElement(seleniumWebDriver).click().build().perform();

org.openqa.selenium.interactions , org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: (x, y) is out of bounds while MouseHover with GeckoDriver Firefox� Selenium - Cannot bring parent window back into focus in Firefox 4 org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: (x, y) is out of bounds while MouseHover with GeckoDriver Firefox Selenium

Try using it -

action.moveToElement(menu).build().perform();
Thread.sleep(500);
moveToElement(selenium).build().perform();
Thread.sleep(500);
moveToElement(seleniumWebDriver).click().build().perform();

当使用GeckoDriver Firefox Selenium进行MouseHover时,(x,y , org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: (x, y) is out of bounds while MouseHover with GeckoDriver Firefox Selenium. org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: (x, y) is out of bounds while MouseHover with GeckoDriver Firefox Selenium (5 answers) Closed 7 months ago . Trying to move the mouse using coordinates, first I get the coordinates

I've observed the same issue with geckodriver and Actions class. Although you can go with following code

System.setProperty("webdriver.gecko.driver", "C:\\Drivers\\geckodriver-v0.24.0-win64\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("http://executeautomation.com/demosite/index.html");
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
WebElement mainmenu = driver.findElement(By.xpath("//li[@class='active has-sub']"));
WebElement submenu = driver.findElement(By.xpath("//li[@class='has-sub'] [contains(.,'Selenium')]"));
WebElement intendedLink = driver.findElement(By.xpath("//li[@class='has-sub'] [contains(.,'Selenium')]//li[contains(.,'Selenium WebDriver')]"));

Actions action =new Actions(driver);
action.moveToElement(mainmenu).clickAndHold().build().perform();
Thread.sleep(1000);
action.moveToElement(submenu).clickAndHold().build().perform();
Thread.sleep(1000);
intendedLink.click();

Code is working fine at my end. let me know if any issue.

Note: Keep the mouse pointer out of web page screen else it override the current focus.

java — org.openqa.Selenium.interactions , MoveTargetOutOfBoundsException: (x, y) est hors limites tandis que MouseHover avec GeckoDriver Firefox Selenium MoveTargetOutOfBoundsException: (-9862, 206) is out of bounds of viewport width (1283) and height (699). J'utilise: * Firefox v66.0.2 * Java v1.8.0_201 * Selenium Java v3.141.59 * GeckoDriver v0.24.0. @codingphil could you please reopen this issue?. Fix is not working in 59.0b14 (64-bit) org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: (1759.7582702636719, 1074.816650390625) is out of bounds of viewport width (1920) and height (966)

Please try the below code(if you are inside frame , you need to come out and use below code):

WebDriver driver=new ChromeDriver();
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("window.scrollBy(0,400)");

with GeckoDriver Firefox and Selenium Java, MoveTargetOutOfBoundsException: (x, y) est� fuera de l�mites mientras MouseHover con GeckoDriver Firefox Selenium MoveTargetOutOfBoundsException: (-9862, 206) is out of bounds of viewport width (1283) and height (699) Content dated on or after 2018-05-02 (UTC) is licensed under CC BY-SA 4.0. | Privacy. Firefox worked with the "old" driver and with geckodriver it does not work anymore. There is no "code" to scroll an element which is out of the viewport into the viewport with geckodriver. Because of this, imho this is a bug for me. How to solve the problem of scrolling an element which is out of the viewport into the viewport with geckodriver?

actions.moveToElement in Selenium does not scroll � Issue #776 , org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: (x, y) is out of bounds while MouseHover with GeckoDriver Firefox Selenium. Exception in thread "main" org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: (408, 611) is out of bounds of viewport width (1280) and height (607

java: org.openqa.selenium.interactions , andreastt added the selenium label on Jun 8, 2017 os.version: '10.0', java. version: '1.8.0_144' Driver info: org.openqa.selenium.firefox. System Version: 0.19.1 Platform: Windows 10 Firefox: 59 (Nightly of 08/01/2018) Selenium: 3.81 1500, 150 become 2008,408 because this is computed from the center of the img element.

Firefox - org.openqa.selenium.interactions , MoveTargetOutOfBoundsException: (x, y) выходит за границы, когда MouseHover с GeckoDriver Firefox Selenium MoveTargetOutOfBoundsException: (-9862, 206) is out of bounds of viewport width (1283) and height� Hi. I’m getting exactly this problem when running my tests using ChromeDriver and when using GeckoDriver: “Element is not clickable at point (X, Y). Other element would receive the click…” (Each browser says that the element is hidden by a different element.)

Comments
  • First thing to check is the zoom level of your browser, it can throw off hovering functions. It should always be 100%. If your zoom level is fine you may be suffering from this: github.com/mozilla/geckodriver/issues/1507
  • @Ardesco the zoom level is fine. Also, I do not think I am affected by the linked issue. Some of the suggested answers works, but only partially. I am still looking for the perfect solution.
  • Same situation as with @kajal-kundu 's code. It works with Firefox given the mouse pointer is out of the web browser, but it does not work in Chrome anymore. It opens menu "Automations Tools", but goes to submenu "BDD" instead.
  • What do you mean by @kajal-kundu 's code ? What exacatly do you mean by mouse pointer is out of the web browser ?? You specifically mentioned same works fine when I switch to Chrome, but with Firefox I get the error. This answer is specifically for Firefox . Can you just copy-paste the code and execute and update me the status please ???
  • Kajal Kundu is the person that also answered to my question. If mouse cursor is over the web browser window the provided solution will not work. I have executed your code, it works in Firefox (given the cursor is not over web browser), but it does not work with Chrome anymore, hence I cannot accept the answer. I don't want to create multiple identical methods but for different web browsers if it is not necessary.
  • I don't think Kajal Kundu is associated with this answer anyway. I have no idea what exactly you mean by mouse cursor is over the web browser window as most of we developers will trigger the execution from an IDE e.g. Eclipse. To reiterate, you specifically mentioned same works fine when I switch to Chrome, but with Firefox I get the error. Though this answer is generic but works perfecto specifically with Firefox. Am I missing something?
  • Strange thing, it started to work properly with your code on both web browsers after the reboot. Thank you :)
  • It works with Firefox given the mouse pointer is out of the web browser, but it does not work in Chrome anymore. It opens menu "Automations Tools" and goes to submenu "BDD" instead. I have tried to search for elements using By.xpath as well but with no luck.
  • My output comes from Chrome only and you are saying it is not working with Chrome.Sorry I can’t help you.
  • Tried it, but the same issue still persists. Also, your code is missing "action." before the method moveToElement.
  • It works with Firefox given the mouse pointer is out of the web browser but it does not work in Chrome anymore. It opens menu and submenu but do not click the "Selenium WebDriver" web element. Also, I do not understand why you used clickAndHold() method instead of click(). What is the difference? I imagine that it will "press and hold" the LMB, move the coursor and release LMB. If I try to do that manually in the browser the dropdown menu would not appear, hence I am confused.