title: Using selenium webdriver python to retrieve SVG text element
body: <p>I am trying to use selenium webdriver (Firefox) to get information about college courses from a website where we can see course reviews .... I can get the webdriver to successfully log into the website and reach the course info page, but once I am there I can't access the text element for the overall course rating. </p>
  
  <p>Here is what the page looks like:</p>
  
  <p>Course Ratings Chart:</p>
  
  <p><img src="https://i.stack.imgur.com/2hoBQ.png" alt="Course Ratings Chart"> </p>
  
  <p>And this is what the text element HTML code looks like: </p>
  
  <pre><code>&lt;text style="text-anchor: middle; font: 12px Arial,Helvetica,sans-serif; 
  opacity: 1;" x="438.00500259399416" y="131.25" text-anchor="middle" 
  font="10px &amp;quot;Arial&amp;quot;" stroke="none" fill="#3c4c30" font-size="12px" 
  font-family="Arial,Helvetica,sans-serif" font-style="normal" font-
  weight="normal" transform="matrix(1,0,0,1,0,0)" opacity="1"&gt;&lt;tspan 
  dy="4"&gt;3.00&lt;/tspan&gt;&lt;/text&gt;
  </code></pre>
  
  <p>And the svg code: </p>
  
  <pre><code>&lt;svg height="200" version="1.1" width="600" 
  xmlns="http://www.w3.org/2000/svg" style="overflow: hidden; position: 
  relative; left: -0.5px; top: -0.866669px;"&gt;&lt;rect x="0" y="0" width="600" 
  height="200" r="0" rx="0" ry="0" fill="#ffffff" stroke="#ffffff" 
  style="stroke-linejoin: round; stroke-linecap: square; stroke-opacity: 1; 
  fill-opacity: 1;" stroke-linejoin="round" stroke-linecap="square" stroke-
  width="1" stroke-opacity="1" fill-opacity="1"&gt;&lt;/rect&gt;
  .......&lt;/svg&gt;
  </code></pre>
  
  <p>First I tried identifying the element by it's CSS selector (#chart > svg:nth-child(1) > text:nth-child(107)) but I got a nosuchelement exception. </p>
  
  <p>I think the next option is to find the element by XPath but I'm not sure how to identify the "3.00"  element because it doesn't have a specific ID or class name. </p>
  
  <p>Parent element1:
   (bar and text for Papers/Problem Sets)
  -Papers/Psets label:</p>
  
  <pre><code>&lt;text style="text-anchor: middle; font: 12px Arial,Helvetica,sans-serif;" 
  x="0" y="0" text-anchor="middle" font="10px &amp;quot;Arial&amp;quot;" stroke="none" 
  fill="#3c4c30" font-size="12px" font-family="Arial,Helvetica,sans-serif" 
  font-style="normal" font-weight="normal" 
  transform="matrix(1,0,0,1,128,102.0833)"&gt;&lt;tspan dy="4"&gt;Papers, Reports, 
  Problem Sets, Examinations&lt;/tspan&gt;&lt;/text&gt;
  </code></pre>
  
  <p>Paper/Psets bar: </p>
  
  <pre><code>&lt;rect x="262.03334045410156" y="96.00694444444444" width="216.0105950756073" 
  height="12.152777777777777" r="0" rx="0" ry="0" fill="#ffffff" 
  stroke="#ffffff" style="stroke-linejoin: round; stroke-linecap: square; 
  stroke-opacity: 0; opacity: 1; fill-opacity: 0;" stroke-linejoin="round" 
  stroke-linecap="square" stroke-width="0" stroke-opacity="0" opacity="1" 
  fill-opacity="0"&gt;&lt;/rect&gt;
  </code></pre>
  
  <p>Number rating for papers/ psets: </p>
  
  <pre><code>&lt;text style="text-anchor: middle; font: 12px Arial,Helvetica,sans-serif; 
  opacity: 1;" x="458.2356021327972" y="102.08333333333333" text-
  anchor="middle" font="10px &amp;quot;Arial&amp;quot;" stroke="none" fill="#3c4c30" 
  font-size="12px" font-family="Arial,Helvetica,sans-serif" font-
  style="normal" font-weight="normal" transform="matrix(1,0,0,1,0,0)" 
  opacity="1"&gt;&lt;tspan dy="3.999997456868485"&gt;3.31&lt;/tspan&gt;&lt;/text&gt;
  </code></pre>
  
  <p>Parent element 2 (Feedback for other students bar)</p>
  
  <p>Feedback text label: </p>
  
  <pre><code>&lt;text style="text-anchor: middle; font: 12px Arial,Helvetica,sans-serif;" 
  x="0" y="0" text-anchor="middle" font="10px &amp;quot;Arial&amp;quot;" stroke="none" 
  fill="#3c4c30" font-size="12px" font-family="Arial,Helvetica,sans-serif" 
  font-style="normal" font-weight="normal" 
  transform="matrix(1,0,0,1,175.3333,160.4167)"&gt;&lt;tspan dy="4"&gt;Feedback for 
  other students&lt;/tspan&gt;&lt;/text&gt;
  </code></pre>
  
  <p>Bar for feedback: </p>
  
  <pre><code>&lt;rect x="262.03334045410156" y="154.34027777777777" 
  width="232.3255947036743" height="12.152777777777777" r="0" rx="0" ry="0" 
  fill="#ffffff" stroke="#ffffff" style="stroke-linejoin: round; stroke-
  linecap: square; stroke-opacity: 0; opacity: 1; fill-opacity: 0;" stroke-
  linejoin="round" stroke-linecap="square" stroke-width="0" stroke-opacity="0" 
  opacity="1" fill-opacity="0"&gt;&lt;/rect&gt;
  </code></pre>
  
  <p>Feedback rating text: </p>
  
  <pre><code>&lt;text style="text-anchor: middle; font: 12px Arial,Helvetica,sans-serif; 
  opacity: 1;" x="474.55060176086425" y="160.41666666666666" text-
  anchor="middle" font="10px &amp;quot;Arial&amp;quot;" stroke="none" fill="#3c4c30" 
  font-size="12px" font-family="Arial,Helvetica,sans-serif" font-
  style="normal" font-weight="normal" transform="matrix(1,0,0,1,0,0)" 
  opacity="1"&gt;&lt;tspan dy="3.9999949137369697"&gt;3.56&lt;/tspan&gt;&lt;/text&gt;
  </code></pre>
  
  <p>Here is the entire HTML code for the body of the website from page_source: </p>
  
  <p>(<a href="https://pastebin.com/zpd4iF05" rel="nofollow noreferrer">https://pastebin.com/zpd4iF05</a>)</p>
  
  <p>And for the python code I attempted to use to find the element: </p>
  
  <p>(<a href="https://pastebin.com/aW40P86u" rel="nofollow noreferrer">https://pastebin.com/aW40P86u</a>)</p>