0

I am trying to extract data from an SVG chart using selenium. The XPATH seems correct as with an xpath helper wizard I retrieve the value, but running a Python script it returns an empty value...

Here is a part of the code

<svg width="710" height="184">
    <g>
        <g class="sub _0">
            <g>
                <circle cla ss="dot xh-highlight" r="0" fill="#3887DD" cx="0" cy="117.55757575757576" style="fill-opacity: 1e-06; stroke-opacity: 1e-06;">
                    <title class="">Tue Feb 09 2016 01:00:00 GMT+0100 (CET): 120</title>
                </circle>
                <circle class="dot" r="0" fill="#3887DD" cx="0.8892086330935252" cy="117.34121212121212" style="fill-opacity: 1e-06; stroke-opacity: 1e-0;">
                    <title class="">Wed Feb 10 2016 01:00:00 GMT+0100 (CET): 138</title>
                </circle>
            </g>
        </g>
    </g>
</svg>

and the Selenium code

LaunchDate = driver.find_elements_by_xpath("//*[name()='svg']/*[name()='g']/*[contains(@class ,'_0')]//*[name()='circle'][1]").text

Does anyone Know what goes wrong ?

Thanks

Eric
  • 95
  • 7
  • 1
    `svg` elements are from **svg** `namespace`. Possible duplicate of [Selenium WebDriver \[Java\]: How to Click on elements within an SVG using XPath](https://stackoverflow.com/questions/41829000/selenium-webdriver-java-how-to-click-on-elements-within-an-svg-using-xpath) – undetected Selenium Jan 04 '18 at 15:16

1 Answers1

0

Your html has an error, an extra space in the word class of the first circle.

i this this should work to get the first circle:

//svg//g[contains(@class,"_0")]//circle[contains(@class,"highlight")]

i hope it helps :)