Is there a way to obtain tooltip content with selenium when the tooltip is being dynamically loaded through JavaScript?

Currently, I am conducting tests on a web application that requires me to validate the information displayed in a tooltip when my mouse hovers over a specific area of the graphics.

The following is the snippet of HTML code responsible for generating this tooltip:

<div id="area-serverSlot-6a" class="annotation" style="width: 21px; height: 38px; left: 186px; top: 117px; position: absolute; z-index: 20; cursor: pointer;" name="annotation" present="1" tooltip="" href="javascript:select_module('server', '6a');" onareaover="javascript:DisplayTip('serverSlot-6a', TITLE,'Server Slot 6a')" onareaout="javascript:UnTip()"></div>

I am facing difficulty accessing the content of the tooltip as it moves along with the mouse cursor. Any suggestions on how I can extract the tooltip contents?

Below is the code snippet for DisplayTip function:

function DisplayTip()
{
var titleType = arguments[2];
var slotNumPos = titleType.lastIndexOf(' ');
var slotNum = " UNKNOWN";
var title = "UNKNOWN";
if (titleType.indexOf('Server') >= 0) title = vServerSlot;
else if (titleType.indexOf('IOM') >= 0) title = vIOMSlot;
else if (titleType.indexOf('PSU') >= 0) title = vPSUSlot;
else if (titleType.indexOf('CMC') >= 0) title = vCMCSlot;
else  if (titleType.indexOf('KVM') >= 0) title = vKVMSlot;
else if (titleType.indexOf('Fan') >= 0) title = vFanSlot;
else if (titleType.indexOf('LCD') >= 0) title = vLcdSlot;
if (slotNumPos >= 0)
{
slotNum = titleType.substring(slotNumPos);
title += slotNum;
}
TagToTip(arguments[0], TITLE, title, JUMPHORZ, true,
JUMPVERT, true, ABOVE, true);
} 

Answer №1

Hey Nick,

Here is a sample code snippet featuring the use of WebDriver with InternetExplorerDriver to interact with Linkedin:

WebDriver driver = new InternetExplorerDriver();
    driver.get("http://www.linkedin.com/");
    WebElement tooltipElement = driver.findElement(By.xpath("html/body/div[1]/div[1]/div/h2/a"));
    System.out.println("Tooltip Text : " + tooltipElement.getAttribute("title"));

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

Program that extracts information from interactive controls

One of my challenges involves working with pages that have dynamic controls, where I never know the types or quantities of controls present. My goal is to create a script that can extract text from a text area when it's clicked. Although I initially b ...

My ejs page is not showing up because a variable has not been defined

I am facing an issue with an undefined variable causing my EJS page to not display properly when an if statement is included. Removing the if statement allows the page to render, but the presence of the undefined variable and if statement triggers an error ...

Exploring the potential of utilizing functions in express.js to take advantage of the "locals"

Having experience with Rails/Sinatra, I am accustomed to using helper functions in my view files. However, incorporating this functionality into express.js has proven to be quite challenging. You can include locals automatically like this... app.set("nam ...

Displaying and hiding content with a single button

I'm working on a slide-in content feature that appears from the left when clicking on the bars icon. Initially, I set it up with separate buttons for opening and closing the content by moving the page left and right. Now, I'm attempting to achiev ...

Tips for utilizing selenium.waitForCondition(script, timeout) in Webdriver 2/3

We have recently transitioned from using Selenium-RC to WebDriver in our framework. I've been trying to find the alternative code for the snippet below, but without success. Since this code is utilized multiple times within the framework, it's a ...

Managing the uploading of files when a new property is included directly from the JavaScript File Object

When processing files using the POST method, I am able to access the default information such as name, type, size, tmp_name, and error through PHP. However, the file being sent contains additional data that I need PHP to extract. https://i.sstatic.net/bGj ...

How to change the state using an object as an argument in the useState hook within a function

This code uses a function component: export default function Account() { We define a constant with inputs as objects: const [state, setState] = useState({ profile: true, orders: false, returns: false, coupon: false, referrals: false, rewards: ...

What is the most efficient method for executing multiple variable=function() and determining when all tasks have been finished?

I am facing the issue of having multiple variables that need to be calculated before being saved as a JSON file. These calculations are done using a function, but when run asynchronously, they end up undefined. After reading about promises, it seems like t ...

Modify the input value within a table data cell when the checkbox on the same row is checked

Here is the code snippet: <table class="table" id="ptable" > <thead> <tr> <th>CheckBoxes</th> <th>SL</th> <th>Product</th> ...

Unable to assign a value to input in Knockout.js app using Selenium webdriver

Utilizing Selenium driver and Capybara to interact with an external site that is coded on Knockout JS. The objective is to input a value. Sounds simple, right? Here is the HTML for this particular input: <input data-bind="value: $root.data.location.us ...

Configuring the user-agent in Selenium RC

Utilizing Custom Headers in Selenium RC allowed me to include the User-agent and phone number in my HTTP requests. To achieve this, I am utilizing Selenium Server as a proxy in Firefox (refer to how-to use addCustomRequestHeader properly) This is the code ...

Arranging the data in the table by alternating rows using Datatables

I need to organize my data in a way that includes an additional row for descriptive information, but this particular row should not be sorted. It is crucial for understanding the rest of the data, so hiding or showing it is not an option. Is it possible t ...

The Material-ui Drawer does not function properly when used with an external CSS file

For my project, I'm working on a Sidebar design that is inspired by the Mini Variant drawer demo available at this link. However, the project requirements mandate that all CSS styling should be done in a separate CSS file rather than directly within t ...

Tips for setting a checkbox as checked based on a value using JQuery

My task is to set the checked status of my checkbox based on a data value. So far, I have been using the following method. $(document).ready(function(){ $('#add').click(function(){ $('#insert').val("Insert"); ...

Submitting POST data to PHP using AJAX

Having always sent AJAX requests with jQuery, I am now faced with the challenge of sending them using 'vanilla' JS. Despite my best efforts, I have managed to get everything working except for passing the data along with the request. The two vari ...

Show a compact graphic in the upper-right-hand corner

Hey, I have this interesting idea but CSS isn't my strong suit. Any thoughts on how to achieve it? I'm looking to create a new class that, when applied to an item (like a div), displays a small clickable pre-defined image in the Top-Right corne ...

Having trouble activating the submit function using an external JavaScript file

Having trouble getting the form to submit properly. I have placed the form inside a <div id="access"></div> by setting its innerHTML using an included js file in the header of the page. Here's how it looks: <div id="access"> < ...

What is the best way to display the output of a given input along with all its possible permutations?

Can anyone help me with showing all permutations of a value entered into an input field, with a maximum length of 5 characters? I tried creating a Codepen example for this, but it's not working as expected. Check out my Codepen here This is the scr ...

"Error encountered when attempting to upload directory due to file size

Utilizing the webkit directory to upload a folder on the server has been successful, however, an issue arises when there are more than 20 files in the folder. In this scenario, only the first 20 files get uploaded. The PHP code used for uploading the fold ...

repeated execution of a javascript function

I have created a tag picker that generates checkbox inputs based on the "group" selected. After selecting the desired tags and pressing the done button, it should return a string to set the value of a text input. Below are some related code snippets. The ...