Skip to content
Advertisement

Get Text from SVG using Python Selenium

My first time trying to extract data from an SVG element, following is the SVG element and the code I have tried to put up by reading stuff on the internet, I have absolutely no clue how wrong I am and why so.

JavaScript

I am trying to get the Categories and corresponding Percentages from the last 2 blocks of the SVG, I’ve replaced all the values with the string ‘rrr’ just to make it more readable here.

I’m trying,

JavaScript

Like I said, I don’t know what I’m doing here, what I’ve so far understood is svg elements need to be represented as a ‘custom ?’ XPATH which involves stacking all elements into an XPATH which is relative to each other, however I have no clue on how to extract the expected output like below.

JavaScript

Any help is appreciated. Thanks.

Advertisement

Answer

You can try something like :

JavaScript

#OR

JavaScript
Advertisement