gaurav.singharoy
gaurav.singharoy

Reputation: 3921

Selenium::WebDriver::Error::MoveTargetOutOfBoundsError

I am getting the following error when trying to interact with some items:

Element cannot be scrolled into view:javascript:void(0); (Selenium::WebDriver::Error::MoveTargetOutOfBoundsError)

This comes when interacting with a modal (Bootstrap) just after an AJAX call even though the element is in the browser and is visible.

One workaround I found was I just manually went to the page again (this did not mess up the test scenarios).

Is there any better method for such errors?

Upvotes: 1

Views: 1255

Answers (1)

VolkerK
VolkerK

Reputation: 1510

Testing ajax is tricky. That's because it is asynchronous ;)
So you have to wait for certain objects to occur on your page.
And then depending on your framework some transitions or animations are done, you have to wait for them as well.

For what exactly you have to wait, depends on your application and the JS Framework you are using. It could be a css class an id or something else.
For example with jQuery mobile you have to wait for the css class ui-mobile-viewport-transitioning to be removed, then your transition is finished and you can continue testing.

Here is a Java code example for waiting:

webdriverWaiter.waitUntil(ExpectedConditions.invisibilityOfElementLocated(By.cssClass("ui-mobile-viewport-transitioning")));

Hope that helps

Upvotes: 2

Related Questions