Tips on how to retrieve the tooltip of an image that is only displayed when hovering over it using Selenium

Currently, I am in the process of learning Selenium and aiming to retrieve the tooltip displayed on an image in the Selenium console. The tooltip is set to only appear when hovering over the image. Despite my attempts to obtain the xpath and use actions, I have encountered difficulties.

The website where this issue arises is https://mayexam.cpsatexam.org/certifications/. Specifically, I am interested in extracting the tooltips of the three circular logo images.

String xpathTooltip1 ="//*[@id="tippy-1"]/div/div[2]";

        String img2 = "//*[@id=\"eael-section-tooltip-bf4f6d6\"]/div/div/img";
        
        WebElement toolTIP = driver.findElement(By.xpath(img2));
        action.clickAndHold(toolTIP).moveByOffset(50, 0);
        String actTooltip = driver.findElement(By.xpath(xpathTooltip1)).getText();
        System.out.println("The tooltip  is " + actTooltip);
        

Answer №1

Tooltips are commonly found within the title attribute, but in this scenario, the tooltip is located within a 'div' tag with the class 'tippy-content'.

This piece of code is correctly set up to make the tooltip work:

String img2 = "//*[@id=\"eael-section-tooltip-bf4f6d6\"]/div/div/img";
String xpathTooltip1 = "//div[@class='tippy-content']";

WebElement image= driver.findElement(By.xpath(img2));
Actions action = new Actions(driver);
action.moveToElement(image).perform();
String actTooltip = driver.findElement(By.xpath(xpathTooltip1)).getText();
System.out.println("The tooltip is: " + actTooltip);

https://i.sstatic.net/KB3oQ.png

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

What is a creative way to store and organize ids along with their sub ids in an object without relying on arrays?

Currently, I am faced with the challenge of sending data to the server that contains multiple ids with sub ids. I have been utilizing arrays to handle this, but the repetitive use of find() and findIndex() functions in the DOM (specifically with Vue) is st ...

Updating the data and processing results settings for Select2 in an Angular 2 application

In my Angular2 app, I am utilizing Select2 and facing a challenge with accessing class properties in the data and processResults contexts. Unfortunately, these contexts do not belong to the class: export class DefaultFormInputSelectComponent { @Input ...

The CSS classes for the dropzonejs are not being properly updated for editing purposes

I'm currently facing an issue where I am attempting to include an editable area inside a dropzone, but for some reason, the editable area is not visible within the dropzone and the CSS classes are not being applied. <a href="#" editable-text="us ...

React - Stopping the Submit Action

Recently, I have been delving into React development. In my exploration, I have incorporated the Reactstrap framework into my project. However, I have encountered an issue where the HTML form submits when a button is clicked. Is there a way to prevent this ...

Encrypting data using JavaScript and then decrypting it with Ruby

Looking to securely encrypt a string in a client-side JavaScript application and decrypt it on a Ruby on Rails Server. Interested in utilizing AES for encryption. What would be the most effective combination of scripts, libraries, or methods to achieve t ...

What is the purpose of utilizing 'extends' instead of casting generics?

What is the reason for needing to cast to List<T> when using T extends A? class A{} public <T extends A> List<T> someMethod() { List<A> list = new ArrayList<>(); List<T> result1 = list; // !! Does not compile, ...

Exploring the integration of Firebase with Google Cloud using Java

Currently, I am facing a challenge where my database is stored in Firebase and my backend logic is in Google Cloud. The code is written in Java. I have encountered an issue where I am unable to authenticate to Firebase due to the requirement of the auth ...

Establishing context boundaries in Angular

Having my variables bound to this in the controller and using controllerAs: 'game' in the route designation allows me to include them in the HTML using {{game.var}}. At times, I find myself binding objects that I want to display, which leads to r ...

Selenium's send_keys method will not interact with an element more than once

My challenge involves sending keys to Wordle based on HTML elements. I've noticed that if there are duplicate letters in a word, the key won't press twice. For example, with the word 'Trent', it only types 'Tren'. However, wi ...

I was baffled by the error message stating "javac: file not found: HelloWorld.java."

javac HelloWorld.java I keep encountering the same error message every time I try to run this command in cmd: javac: file not found: HelloWorld.java Strangely, when I provide the full file path like this: javac D:\User\Documents\Projec ...

Select the Best jQuery Package

Having a variety of packages available for selection. <div class="image-grid-item" data-search="select"> <input name="pack1" type="checkbox" style="display: none;"> </div> <div class="image-grid-item" data-search="select"> <inp ...

What is the best way to dynamically shift the position of an image on a page while keeping it in place in real-time?

A group of friends and I are currently collaborating on an experimental project for a presentation. Our goal is to have multiple elements (such as images, text, gifs) displayed on a page that can be dragged around in real-time using a draggable script whi ...

Ways to apply the .not selector efficiently in jQuery

I have a situation with two separate divs, one named task1 and the other named task2. Each of these tasks contains panels with various names. Within task2, there is a duplicate name (Greg), who also belongs to the duplicate class. I'm trying to figure ...

Obtaining asynchronous data with nodejs is possible through several methods

I am currently trying to retrieve data from a MySQL table using Node.js. I have a SQL routine in another Node.js file that I am calling, but I am struggling to get the callback function to return the data. I suspect that the issue may be related to calling ...

In Java using Hibernate and JPA, you can create an entity that joins two distinct tables using the same column as a reference, even if the

I am facing an issue that I want to resolve using annotations only, without having to use two separate queries to retrieve the data. The problem involves joining two different tables based on the same column id. One table is Travels, which at times may hav ...

Get your hands on Excel by utilizing the power of Ajax and Flask

I'm attempting to download an excel file from Flask using an Ajax call. The response code shows as 200, but the excel file is not downloading. The error messages I am receiving are as follows: Ajax Request : $("#genExcel").on("click", function() { ...

Is Selenium failing to enter text based on element names?

Having trouble getting my C# visual studio tests with selenium to input keys/strings into the username and password fields on Google Chrome. How can I resolve this issue and ensure that the correct user information is entered and the submit form button i ...

Using Selenium to continuously scroll to the bottom of the webpage

Selenium: I am new to WebDriverJS. I have experimented with this method in Java. Long repeat = 0l, scrollHeight = 0l, returnHeight = 0l; while(true){ if (repeat == 0) { returnHeight = (Long) jse.executeScript("var scroll =document.documentEle ...

Capturing failed test results through Junit 5 Selenium parallel test runs

For each test failure or multiple failures, a screenshot needs to be taken. Rather than wrapping each individual test with a try-catch block, is there a way to apply this functionality to all tests without explicitly wrapping them? Would setting this up in ...

What are the steps for implementing custom edit components in material-react-table?

I am currently using the official material-react-table documentation to implement a CRUD table. You can find more information at this link: . However, I encountered an issue while trying to utilize my own custom modal components for the "create new" featur ...