Why does Selenium's MoveToElement trigger the onmousemove event even when the mouse is stationary?

While conducting some testing with Selenium, I came across an unusual behavior that appears to be causing the window.onmousemove event to fire repeatedly. This occurs even after the mouse movement has ended, which is not the expected behavior. I am seeking guidance on how to ensure that the onmousemove event only triggers when the mouse is actually being moved. Any assistance would be appreciated.

Below is the code snippet in question:

Public Class Form1
Imports OpenQA.Selenium
Imports OpenQA.Selenium.IE
Imports OpenQA.Selenium.Interactions

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim driver As New InternetExplorerDriver()
        driver.Navigate.GoToUrl("http://127.0.0.1:1337/showmouseposition.html")
        driver.Keyboard.PressKey(Keys.F12)
        Dim builder As New Actions(driver)
        Dim ele As IWebElement = driver.FindElement(By.Id("myButton"))
        builder.MoveToElement(ele)
        builder.Perform()
    End Sub

End Class

showmousepositions.html

<html>
<head>
</head>
<body>
    <input type="text" id="x">
    <input type="text" id="y">
    <button type="button" id="myButton" onclick="alert('clicked btn')">Click Me!</button>

    <script>
        window.doLogging = true;
        document.onmousemove = function(e) {
            var dot, eventDoc, doc, body, pageX, pageY;

            event = event || window.event; // IE-ism

            if (event.pageX == null && event.clientX != null) {
                eventDoc = (event.target && event.target.ownerDocument) || document;
                doc = eventDoc.documentElement;
                body = eventDoc.body;

                event.pageX = event.clientX +
                  (doc && doc.scrollLeft || body && body.scrollLeft || 0) -
                  (doc && doc.clientLeft || body && body.clientLeft || 0);
                event.pageY = event.clientY +
                  (doc && doc.scrollTop  || body && body.scrollTop  || 0) -
                  (doc && doc.clientTop  || body && body.clientTop  || 0 );
            }

            if (doLogging) {
                window.x.value = event.pageX;
                window.y.value = event.pageY;
                console.log(event.pageX + "," + event.pageY);
            }
        }
    </script>
</body>
</html>

Answer №1

Have you attempted using build.perform() method?


Public Class Form1
 Imports OpenQA.Selenium
 Imports OpenQA.Selenium.IE
 Imports OpenQA.Selenium.Interactions

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles 
    Button1.Click
    Dim driver As New InternetExplorerDriver()
    driver.Navigate.GoToUrl("http://127.0.0.1:1337/showmouseposition.html")
    driver.Keyboard.PressKey(Keys.F12)
    Dim builder As New Actions(driver)
    Dim ele As IWebElement = driver.FindElement(By.Id("myButton"))

    builder.MoveToElement(ele).Build.Perform()

End Sub

End Class

Answer №2

Although I have found a workaround for the onmousemove issue with FireFox driver, I still struggle to find a solution for IE Driver. Despite the memory leak problem caused by onmousemove in IE, I am willing to use it if someone can provide me with a reliable fix. Any help would be greatly appreciated. I am currently using the latest version of IEServerDriver.exe from Selenium's website and have IE 11 installed on Windows 10.

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

Employing ng-repeat within a ui-scope

I'm having trouble getting my ui-view to update dynamically using ng-repeat. I'm not sure if what I want to do is even possible because when I add static objects to intro.html, they display properly. Thank you for any assistance, JS }).st ...

Transfer data in JSON format to the server using Ajax

Currently, I have an HTML form where I am in the process of creating a JSON object using JavaScript. Here is how it looks: var JSobObject= '{"name":"'+personObject.GetPersonName()+ '","about":"'+personObject.GetAbout()+ &ap ...

Tips for obtaining and storing multiple inputs within the same readline.question prompt in separate variables

Seeking to gather multiple user inputs in a single readline question and assign them to different variables? You're not alone! Ran into this challenge myself while trying to figure out the solution. Code import * as readline from 'node:readline&a ...

Is it possible to display an HTML file along with accompanying JS files using Express in Node.js?

I am working with an index.html file and I need to send it using the following Node.js code: app.get('/', (req, res) => { res.sendFile(`${__dirname}/index.html`) }); Within the same directory, I also have some JavaScript files that I want ...

Is it possible to conduct a feature test to verify the limitations of HTML5 audio on

Is there a way to detect if volume control of HTML5 audio elements is possible on iOS devices? I want to remove UI elements related to the volume if it's not alterable. After referring to: http://developer.apple.com/library/safari/#documentation/Aud ...

Is it possible to conceal the mapbox access token during the map initialization process?

I have successfully integrated the mapbox API to create an interactive map on my website. To ensure the security of my access token, I have set up a proxy to handle the API requests externally. However, I am facing a challenge when it comes to hiding the a ...

Retrieve the ID of the button that was chosen

Hello, I have a card with 3 selectable buttons as described below. <ul class="nav nav-tabs border-0" role="tablist" id="FlightType" onclick="SelectedFlightType()"> <li cla ...

What seems to be the issue with the useState hook in my React application - is it not functioning as

Currently, I am engrossed in a project where I am crafting a Select component using a newfound design pattern. The execution looks flawless, but there seems to be an issue as the useState function doesn't seem to be functioning properly. As a newcomer ...

Converting a multidimensional array from PHP to JavaScript in Symfony 4

Greetings! I have an array in Symfony within my controller that looks like this: $array = [ "label" => [ "january", "february" ], "data" => [ 0, 1 ] ]; I am loo ...

The ng-cloak feature in Angular JS seems to be malfunctioning as it is displaying the expression symbol when the

As someone who is new to AngularJS, I am faced with a challenge of dealing with html code that displays before it gets evaluated. It's quite frustrating to see the expressions appear first and then the actual values. I tried using ng-cloak in the body ...

Creating a dynamic search bar using Ajax with support for multiple keywords

I recently attempted to create an ajax search bar for my website. It functions perfectly with a single keyword, however, I'm facing some difficulty when trying to make it work with two keywords. I thought about parsing the data in the input field, but ...

Building an object in React using JavaScript: A step-by-step guide to including all necessary fields

I am working on a Sign-up page where I console log the input values from each field when the 'Sign Up' button is clicked. However, I want to combine these individual values into one object in the console. If anyone can provide assistance with thi ...

Transferring form data through AJAX for uploading files

My current task involves uploading an image using form data with ajax. I have successfully tested the code below and it is saving the image on my local machine. <form ref='uploadForm' id='uploadForm' action='/tab10/uploadImage& ...

Is there a way to update the value of a property using jQuery?

Is there a way to retrieve the "top" property value along with its inline CSS adjustment? <article class="stack" style="position: absolute; left: 741px; top: 1000px;"> </article> I'm looking to subtract 200px from the top value, in this ...

The style property is returned as null by the React Hook useRef

I am currently working on a modal that requires me to access the id property of an HTML element in order to modify its display property. I attempted to achieve this using the useRef Hook, but encountered the following errors. TypeError: Cannot read propert ...

The y-axis max property in Highcharts does not effectively hide plot bands and labels

I have set up two separate jsfiddles to demonstrate my issue. The first jsfiddle represents the desired behavior, while the second one displays the problem I am encountering. In the first jsfiddle (https://jsfiddle.net/n5ua6krj/1/), the y-axis[0] does not ...

Guide on updating a specific item in a JSON array using npm request

I am currently working on setting a value in a JSON array utilizing a PUT request with the request module, specifically targeting one of multiple main objects within the array. The structure is as follows: [ 0: { status: 'pending' ...

A JQuery function linked to the click event of the body element triggers another click event right away

$().ready(function(){ $("#move-to").click(function(){ $("body").bind("click",function(){ alert("foo"); }); }); }); Why do I receive an alert message of "foo" immediately after clicking on "move-to"? When I bind the " ...

Using Firebase with Angular 4 to fetch data from the database and show it in the browser

Currently diving into Angular 4 and utilizing Firebase database, but feeling a bit lost on how to showcase objects on my application's browser. I'm looking to extract user data and present it beautifully for the end-user. import { Component, OnI ...

Removing exclamation points from the routing of a state URL is a key aspect of mastering full stack development

Is there a way to remove exclamation marks from the url in state routing using mean.io? Currently, my url looks like http://localhost:3000/#!/auth/register I just want to get rid of the "!" marks after the "#" symbol. Is it possible? Here is the content ...