Can you suggest a different method for performing a mouse hover action on a selenium web element using Java 1.8, Gecko Driver 0.19, and Firefox 56?

I encountered an issue where using Actions resulted in an unsupportedCommandException.

I attempted the following:

Actions action = new Actions(driver);
action.moveToElement(element).build().perform();
driver.findElement(By.linkText("All Actions")).click();

The element is the web element that I tried to hover over.

I also tried the following:

((JavascriptExecutor) driver).executeScript("arguments[0].focus();",element);
((JavascriptExecutor) driver).executeScript("arguments[0].click();", element);

Unfortunately, none of these solutions worked for me.

I am utilizing seleniumbox and working with the latest version of selenium 3.9.1.

Answer №1

In order to perform a Mouse Hover action on an element, it is essential to ensure that the element is first visible. Using Selenium-Java Client v3.9.1, ChromeDriver v2.35, and Chrome v 63.0, the following code snippet has been successful for me:

WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("xpath_of_element")));
Actions action = new Actions(driver);
action.moveToElement(element).perform();

Update

Based on your inquiry :

  • You are working with GeckoDriver v0.19 and Firefox 56.x

According to the trace logs :

  • Your setup includes Selenium Client v3.4.0

https://i.stack.imgur.com/DcBgI.png

The Release Notes for Geckodriver v0.19.0 (2017-09-16) explicitly state :

It is recommended to use Firefox version 55.0 (and above) in conjunction with Selenium 3.5 (and above) when using geckodriver 0.19.0.

Thus, the error message you encountered was due to :

Caused by: org.openqa.selenium.UnsupportedCommandException: mouseMoveTo Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'

Answer №2

The Action is not functioning properly. One potential fix is to downgrade the versions of Firefox and GeckoDriver to a lower, more stable version.

Example for IEDriver:

selenium-standalone install --version=2.47.0 --drivers.ie.version=2.53.1

selenium-standalone start --version=2.47.0 --drivers.ie.version=2.53.1

Answer №3

See if modifying the code in this manner makes a difference:

Actions builder = new Actions(driver);
builder.moveToElement(element).moveToElement(driver.findElement(By.linkText("All Actions"))).click().build().perform();

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

The rows sent to HTML/Bootstrap from Java through JSON do not neatly wrap across rows evenly

I am having trouble getting images to wrap evenly on an HTML/Bootstrap page that are retrieved by Java and passed through JSON. Despite my expectations, there is a third row created with only one image and a fifth row with 3 extra images. Additionally, whe ...

Obtain the src attribute of iframes using Robot Framework Selenium and store it as a variable

On a webpage, I have an iframe element that displays an html document representing a generated form. My goal is to create an automated Selenium script to validate specific values within this document. Currently, I am manually copying the URL from the ifram ...

Finding a nested div within another div using text that is not tagged with XPath

I need help creating an XPath to select a div with the class "membername" using the parameter "Laura". <div class="label"> <div class="membername"></div> David </div> <div class="label"> < ...

Disappearing table borders in print view on Firefox

I have been working on creating a printable table that displays correctly in Chrome. However, when viewed in Firefox, the table borders are not showing up. <body> <table> <tbody> <tr> ...

What ways can we implement identification features in Flutter Web applications, such as adding an ID or name property?

While developing a Flutter Web application, I am exploring a Web-UI-Testing framework that is Selenium-based. Unfortunately, I am struggling to locate an HTML element that represents a specific flutter widget by its id or name attribute. The widget key doe ...

Incorporating a File Attachment within a JSON Structure

Can a file attachment be included in a JSON Object? I am working on an HTML Form with text field inputs and a file attachment, and I would like to send all this form data (including the file attachment) as a JSON Object to the server. Are there any specif ...

Error in thread : TagNameUnexpectedException

I encountered an issue while trying to find a dropdown using Select: An error occurred: Exception in thread "main" org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been "select" but was "input" Even when attempting to use ...

A guide on utilizing Xpath to reference a tag within a class

Trying to obtain the website link by using xpath and selenium with a reference to the class pv-contact-info__contact-type ci-websites. [Here is the html snippet being referenced][1] sel = Selector(text=driver.page_source) website = sel.xpath("//*[@class= ...

Pytest is not able to locate any elements on the webpage, yet the same elements can be easily found using the console

When using CSS or XPath in the console (F12), I am able to locate the element on the page. $$("span.menu-item[data-vars-category-name='Most Popular']") However, when trying to find the same elements with Selenium (pytest) using: driver.find_el ...

Verifying unloaded images

I am new to using Selenium and I need help. I am attempting to retrieve all the image sources on a page in order to identify any images that have not loaded. How can I check the image sources? Can I use "null" as a check? Below is my code, which contains m ...

What is the process for executing Selenium IDE scripts in Selenium RC?

As a newcomer to using the selenium testing tool, I am seeking guidance on running selenium IDE scripts within selenium RC. I would greatly appreciate examples and screenshots to help me better understand the process. ...

Are you able to develop a customized TestNG Listener to cater to your specific requirements?

I have developed a unique concept for a TestNG listener that meets my specific requirements. Essentially, I aim to design a custom listener that generates a report using a predefined HTML format. The crux of my idea revolves around declaring the listener ...

JavaScript - Receiving alert - AC_RunActiveContent.js needed for this page to function

When I attempt to open the HTML file in my application, a pop-up message appears stating that "This page requires AC_RunActiveContent.js." However, I have already imported and referenced the AC_RunActiveContent.js file in my package. Can someone assist m ...

What is the best way to send an HTML report through email with embedded images as an attachment?

Currently, I am in the process of generating a report using ExtentReports that will be distributed via email to team members who are outside of our domain. To capture screenshots of any test failures, I utilize a screenshot method which saves these images ...

Guide for executing Java code and displaying HTML form fields concurrently in JSP

I have created a JSP page with form fields and Java code in scriptlets. I have imported the Java code into the JSP page and created an object to call the functions of that Java class. When I run the JSP, the page remains blank until all the Java code has ...

How to locate a particular element containing specific text using xpath

I have a unique set of spans to work with: <span> <span>foobar</span> <span>textexampleone</span> </span> Currently, I am attempting to utilize xpath in order to locate the span containing "textexampleone" with ...

I am interested in utilizing Selenium to interact with a hyperlink within an HTML table

I am currently using the code snippet below to fetch data from the HTML structure provided: //findTables(driver); WebElement content = driver.findElement(By.id("tblTaskForms")); List<WebElement> elements = content.findElements(By.className("form-nam ...

Some elements are not visible when inspecting the source code

Hidden fields are essential in my jsp form. Interestingly, when I check the page source in a browser, only the first hidden field is displayed, not the second one. <input type="hidden" name="url" id="url" value="<%=url%>" /> <input type="hi ...

Implementing Validation for DropdownChoices and Checkboxes in Wicket Java

There is a checkbox and dropdown menu on an HTML page. Upon clicking submit, if both are selected, there should be an error message stating that at least one of them is mandatory and prompting the user to select at least one value. To address this issue, ...

Is it possible to conduct HTML-based Selenium tests without an internet connection?

As a newcomer to Selenium, I am currently using the Selenium IDE which has led me to create table structures like the one below: <table cellspacing="1" cellpadding="1" border="1" name="SELENIUM-TEST"> <thead> <tr class="title"> ...