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?