5

I am writing tests for a web application and all went well until I had to choose an option from a menu and that option displays a drop down list when hovered or clicked. When I click an option from the drop down list, I get the following error:

MoveTargetOutOfBoundsException: Element cannot be scrolled into view

Does anyone know what this error is about and what I should look for in my code?

Selenium version 2.25.0, java version 1.6.0_31

I've been checking some selenium and google groups regarding this issue in older versions https://groups.google.com/forum/?fromgroups=#!topic/selenium-users/EuZ7a6_lB9Q http://code.google.com/p/selenium/issues/detail?id=3075 http://code.google.com/p/selenium/issues/detail?id=4102

a more recent discussion

Is it a known issue for Selenium 2.25.0 or is there a way to fix it? I recently upgraded to Firefox 15.0 :|

Note: I found a temporary solution until someone magically fixes this...since I can't find where the problem is... I run the code before that point where it crashes, I put it to sleep for 10 seconds, I manually click the menu and the option from the drop down list, the window I want is displayed and the code continues with actions from that point. It works for now...I hope this will be fixed since I can't believe that I can run a script in Selenium IDE but I can't run my java code in WebDriver ...this is crazy :|

Michiru
  • 179
  • 2
  • 6
  • 12
  • 1
    This question definitely lacks a [example]; however a possible reason is that the drop down is too large to fit in a screen; in that case it's possible to scroll it into the correct place (with JavaScript) manually. Possibly related: [java - Selenium MoveTargetOutOfBoundsException even after scrolling to element - Stack Overflow](https://stackoverflow.com/questions/56719535/selenium-movetargetoutofboundsexception-even-after-scrolling-to-element) – user202729 Dec 09 '21 at 09:08

2 Answers2

4

I guess you are trying to click an element from a dropdown. You should keep in mind, that Selenium helps you replicate exact human behavior. So if the code fails because the element is not visible, it is probably because the element is not visible.

To make it work, you might want to put a click command on the menu before the failing bit of code. (to replicate the sleep 10 seconds manually click the menu button method you are using)

Once again, if you can show us your code and also the HTML snippet of the Menu section, we can provide an exact solution.

Amey
  • 8,470
  • 9
  • 44
  • 63
0

Maybe you're opening new popup window while opening select box. This may help you:

WebDriver.FindElement(By.Id("someInputBox")).SendKeys("hello");
(IJavaScriptExecutor)WebDriver).ExecuteScript("document.getElementById('windowOpener_Button').click();");
WebDriver.SwitchTo().Window("newDisplayedWindowPopupName"); // continue to test
PavelP
  • 119
  • 4