Obtaining data from Amcharts bar bubble using Selenium's JSExecutor

My goal is to extract the value from an Amcharts bar graph using JSExecutor with Selenium. The bar graph functions similarly to when you hover over it, a bubble displays the value.

https://i.sstatic.net/CSg70.jpg

This is the structure of my HTML DOM:

   <div class="amcharts-chart-div" style="overflow: hidden; position: relative; width: 1315px; height: 500px; padding: 0px;">
      <svg version="1.1" style="position: absolute; width: 1315px; height: 500px; left: -0.421875px; top: 0.3125px;">
         <desc>JavaScript chart by amCharts 3.12.3</desc>
        <g><path cs="100,100" d="M0.5,0.5 L1314.5,0.5 L1314.5,499.5 L0.5,499.5 Z" fill="#FFFFFF" stroke="#000000" fill-opacity="0" stroke-width="1" stroke-opacity="0"></path>
  <path cs="100,100" d="M0.5,0.5 L1218.5,0.5 L1218.5,443.5 L0.5,443.5 L0.5,0.5 Z" fill="#FFFFFF" stroke="#000000" fill-opacity="0" stroke-width="1" stroke-opacity="0" transform="translate(76,20)"></path></g>
        <g><g transform="translate(76,20)"><g><path cs="100,100" d="M122.5,0.5 L122.5,5.5" fill="none" stroke-width="0" stroke-opacity="1" stroke="#000000" transform="translate(0,443)"></path>

The xpath for the bar containing the desired value is:

//*[@id="barGraph"]/div/div/svg/g[6]/g/g[3]/path

I attempted to retrieve the value using this code:

String str = "document.querySelector(\"#barGraph > div > div > svg > g:nth-child(7) > g > g:nth-child(3) > path\")";
JavascriptExecutor js = (JavascriptExecutor) getDriver();
System.out.println(js.executeScript(str));

Unfortunately, I am only getting back null as the value. How can I make this work correctly?

Answer №1

Experiment with the following CSS and adjust the type number as needed.

#barGraph div > div > svg > g:nth-of-type(1) path

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

tabs that are vertical without the use of jQuery UI

I'm feeling a bit lost because I can't seem to find any examples or tutorials for vertical or side tabbed content. I want the tabs to be on the left side, but all my searches online have come up empty. Maybe I'm not using the right search te ...

Trouble with removing requests in Postman using express.js

I have discovered the issue, but I am unsure of why this particular line of code is causing the problem. if (!mongoose.Types.ObjectId.isValid(id)) { return res.status(404).json({ error: "no such comment" }); } Interestingly, when I removed t ...

JQuery HTML not functioning properly with dynamically inserted elements

Initially, I perform this action var columns = row.getElementsByTagName('td'); columns[2].innerHTML ='<Button class="btn btn-success" style="margin-right:4px;" onclick="savecategory(this.parentNode,this)"> ...

Identify a CSS style or attribute that is being dynamically assigned using JavaScript

While using the Jquery Cycle plugin for my slideshow, I'm looking to trigger an event when a specific slide is active. The Cycle plugin handles this by adjusting the opacity of images within a div in this manner: <div style="position: absolute; to ...

Tips for utilizing the json_encode function with an array

I am trying to extract specific data from an object created using the json_encode function in PHP. while($locations=$req->fetch()){ $t = $locations->titre; $la = $locations->latitude; $lo = $locations->longitude; $typ = $lo ...

"Receiving a 'connection refused' error while executing selenium tests with marionette

My selenium 2.53.1 tests are being run on the marionette web driver, but I keep encountering an error during the test execution. The geckodriver executable is installed at /opt/, so it's puzzling why this error persists. Error Message: Caused by: or ...

I'm currently facing an issue with an error labeled as: "TypeError: Cannot read property 'execute' of undefined" and it's proving difficult to resolve

I need help troubleshooting my Discord bot that is not functioning correctly with an advanced command handler. Error Message: at Client.<anonymous> (C:\Users\bryce\OneDrive\Desktop\bot\main.js:76:39) at Client.e ...

Sending a returned value to another function

I'm facing an issue with a method I have implemented, where I return a variable that needs to be compared but I'm struggling to retrieve it... This is the code snippet: public char setCurrency(String currencyToSet) { WebElement currencyVal ...

Steps for designing an animated css notification message that slides up

I'm looking to implement a dynamic CSS animation for a slide-up notification or confirmation message in my ReactJS project. The goal is for the message to smoothly slide up from the bottom of the page, linger briefly, and then gracefully slide back do ...

The script extracts only a small number of titles from a large pool of content on a webpage

I'm currently using Python and Selenium to extract titles from a webpage that has highly dynamic content. However, my script is only able to fetch the first few titles even though I have carefully defined the selectors in the code. Link to the webpag ...

What is the best way to showcase specific information from a JSON file with the help of

Our corporation is looking to showcase job listings that we promote on a prominent job platform. They provide us with JSON data so we can exhibit our company's job openings on our website. I aim to present essential information in a summary format, w ...

The peculiar behavior of Google Maps markers refreshing inconsistently upon bounds adjustment

I recently completed a project involving a restaurant app using Vue and Google Maps. While everything is functional, I have encountered a persistent bug with the markers. When navigating on the map and the bounds change, some markers seem to disappear. Ev ...

Finding the right element with identical class names (Selenium)

Dealing with two toggle buttons that have the exact same class names has been a challenge for me. The only way I could differentiate between them was by locating a list of these elements and then selecting the correct index, but this method is not foolproo ...

Conceal the pagination element within the Bootstrap aside on smaller screens

I am experiencing an issue with my web page layout. I have a DIV and an Aside element, inside the DIV there is a list with dynamic pagination. Everything seems to be functioning correctly, however on small devices, the Aside section is covering up the pa ...

Is it possible to manipulate videos embedded in an iframe using javascript?

It's common knowledge that JavaScript commands from Google can be used to control YouTube videos, while Vimeo provides its own JavaScript commands for their videos. Both videos are typically embedded within 'iframes' on websites. I'm ...

Utilize the browser/page scroll bar to navigate through the fixed-position div's content

I have several div elements with the CSS property position:fixed positioned all over the page. One of these divs contains longer content than the others. My goal is to enable scrolling within that specific box using the main browser/page scroll-bar, as op ...

What is preventing me from being able to reach the instance of Cropper JS?

I'm facing some issues with executing the loadImage() function as I am unable to access the variable cropper. My ultimate objective is to run cropper.getCroppedCanvas and save its output value into an input field so that I can transmit it via AJAX. T ...

Selenium is equipped to handle download dialogs

I am currently working on automating the download of files (.3ds) using Selenium. My browser of choice is FireFox (v94.0.1 64-bit), but I am open to trying a different browser if necessary. I am operating on MacOS. The problem arises when clicking a downl ...

Tips for showcasing the dynamic legend in a line graph

Within my project, the legend is being displayed dynamically. However, I am looking to showcase names such as "student-marks" and "studentannualscore" instead of numerical values like 0, 1, 2, etc. Currently, the values are appearing as numbers (e.g., 0 ...

Identifying changes in the route within an Angular service

I have developed a service that checks whether a user needs to be logged in to access a particular route. Currently, the code includes the $scope.$on('routeChangeStart) function within the profileInfoCtrl.js controller, but I want to move this functio ...