"ExceptionThrownByMoveTargetOutOfBounds in Selenium WebDriver for IE9 and Firefox

Having trouble with the FireFox/IE9 driver in Selenium? When using the Actions class and its moveToElement method, I keep encountering a MoveTargetOutOfBoundsException error. Despite trying different solutions like Coordinates, Point, and javascriptexecutor, nothing seems to work. Oddly enough, the moveToElement method works perfectly fine with my Chrome driver. Why is it that Firefox33/IE9 are causing issues when they are native to Selenium?

Take a look at this code snippet:

WebElement requiredCheckbox = new WebDriverWait(driver,15).until(ExpectedConditions.presenceOfElementLocated(By.name("tc_n_cs_subscribe_1")));

    // Point points = requiredCheckbox.getLocation();
    // System.out.println(points.getX());
    // System.out.println(points.getY());
    // actions.moveByOffset(points.getX(), points.getY()).perform();

    // ((JavascriptExecutor)
    // driver).executeScript("window.scrollBy(0, "+points.getY()+");");

    // ((JavascriptExecutor) driver).executeScript(
    // "arguments[0].scrollIntoView();", requiredCheckbox);

    // Coordinates coordinate =
    // ((Locatable)requiredCheckbox).getCoordinates();
    // coordinate.onPage();
    // coordinate.inViewPort();

    actions.moveToElement(requiredCheckbox).build().perform();

    requiredCheckbox.click();

Answer №1

What is your objective? If you wish to move the screen to the 'requiredCheckbox', use this code:

((Locatable) requiredCheckbox).getCoordinates().inViewPort();

Answer №2

Successfully resolved the issue by utilizing the JavascriptExecutor code.

((JavascriptExecutor) driver).executeScript(
        "arguments[0].scrollIntoView();", requiredCheckbox);

The solution was effective after incorporating the DesiredCapabilities setJavascriptEnabled method.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Trouble with NodeJS NPM

I'm encountering difficulty when trying to install npm packages. npm ERR! Windows_NT 6.3.9600 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules&bso ...

Avoiding page refresh while utilizing the ng5-slider component in Angular

I am currently working with an ng5-slider that has a customizable range from 0 to 1000. However, I have encountered an issue when adjusting the slider at the bottom of the page - it refreshes and automatically takes me back to the top of the page. I would ...

What is the best way to implement media queries in a column layout for a responsive webpage?

My goal is to display a picture below the navbar when the window size becomes small or in mobile mode, followed by my name and other details. However, I am having trouble understanding how to implement this using media queries. DESKTOP PREVIEW https://i. ...

Error in ReactJs production code: ReferenceError - the process is undefined

Having some trouble with my ReactJs production code not recognizing environment variables. The error message reads: Uncaught ReferenceError: process is not defined <anonymous> webpack://testProject/./src/agent.js?:9 js http://localhost:8080/s ...

Sending an Ajax request to a nearby address

I'm feeling a bit lost on how to achieve this task. I've been searching online, but it seems like my search terms may not have been quite right. My goal is to set up a RESTful api. $.ajax({ type: "POST", url: "https//my.url/", data: ...

Encountering issues with the hyperlink tag '<a>' in an HTML document

I've encountered an issue with the code on my HTML page: <body> <div align="center"> <a href="../index.html"> <img border="0" src="banner1.jpg" width="800" height="120" alt="Ecommerce Knowledge Base"> &l ...

Tips for displaying a message when clicking on the second level in fancytree.js

I'm looking to use fancytree.js to display an alert message only when clicking on nodes in the second level. For example: <ul> <li>1</li> <ul> <li>1.1</li> ...

What does React default to for the implementation of the ``shouldComponentUpdate`` lifecycle method in its components?

Having a personalized approach to the shouldComponentUpdate() method as part of the React component lifecycle is not obligatory. I am aware that it serves as a boolean function determining whether the render() function will be triggered by changes in comp ...

Ways to modify the background color of the entire body excluding a sidebar div

How do I implement an overlay and dim the screen after clicking on a menu button? <ul id="gn-menu" class="gn-menu-main"> <li class="gn-trigger"> <a class="gn-icon gn-icon-menu"><span>Menu</spa ...

When aligning divs at the center, they may not all be perfectly in a straight

My goal is to align 4 div boxes in a vertical line using the translate method typically used for centering objects on a webpage. Here is the code snippet I have utilized: link .body-component { position: relative; margin: 10px; color: #000; disp ...

What is the method to alter the color of the browse button?

I am currently utilizing a custom file input feature from Bootstrap: https://i.sstatic.net/ybCYl.png Is there a way to modify the color of the "Browse" button? My attempts so far: Added a color tag to custom-file-input Added a color tag to custom-file- ...

Automatically notifying users via email about console errors in JavaScript

My exploration on this question and useful links: How to send console messages and errors to alert? jQuery AJAX form using mail() PHP script sends email, but POST data from HTML form is undefined The coding example: function handleError(evt) { if (ev ...

Unable to scroll to the top of the page with JavaScript

I tried the code below but it didn't quite do the trick. Can someone assist me with refreshing the page to the top every time it loads? window.addEventListener('load', function(){ window.scrollTo(0,0) }) window.onload = (event) => { ...

When trying to navigate through the PayPal login page, the Selenium webdriver abruptly stops without providing any error message

I'm facing an issue while trying to automate the payment process on paypal.com. After successfully loading the login page () and entering the email, the web driver unexpectedly closes when I click the next button without any error message appearing. ...

ng-view or controller appears to be malfunctioning

I'm currently working on a small web application using AngularJS. I have an index.html file in the main directory and three other HTML pages within the html subdirectory. login.html list.html detail.html Initially, the index.html should load the ...

Code Snippet: Adjust Table Column Alignment using CSS

Apologies for the basic question, as I am new to CSS. Below is the UI that I am working with: https://i.stack.imgur.com/crAYE.png Here is the code that corresponds to the UI: <div class="row centered-form center-block"> <div cla ...

"ModuleNotFound" error occurred when attempting to utilize Netlify lambda functions with external dependencies

https://i.stack.imgur.com/vVmky.jpg I'm currently exploring the capabilities of Netlify, specifically its lambda function feature for running a node function with dependencies. Following a tutorial from CSS-Tricks, my functions/submission-created.js ...

Acquire HTML information using the Robot framework and xpath techniques

My first task is to visit the website www.google.de. I aim to extract the word Deutschland from this section of the HTML code: <div class="logo-subtext">Deutschland</div> Since the id in this div class is not available, I must utilize xpath. ...

What is the best way to ensure that the size and maximum length of a text input box are properly aligned?

Is there a way to ensure that the size and maxlength attributes of a text input box align correctly? It can be frustrating when these attributes don't match up due to font differences. Example Input: <input type="text" size="4" maxlength="4" /> ...

Two elements failing to display side by side

Can someone help me figure out how to align the quantity and Add-to-cart button on the same line? The quantity is displaying as a block element even though I set it as inline... any suggestions would be appreciated! Visit this link for reference. I' ...