title: How to use find_element_by_xpath() for svg element using Selenium for Python
body: <p>I'm trying to make an Instagram bot to like a post if it's unliked, and to ignore it if it's already liked
  I've managed to grab the div element and click it, but for the like detection code I need the attribute for <code>&quot;aria-label&quot;</code> or <code>&quot;fill&quot;</code> for the bot to specify if the post is liked or not, but I haven't managed to grab the <code>svg</code> element to do so.</p>
  <p>Here's the like button structure</p>
  <p><img src="https://i.stack.imgur.com/WobP8.png" alt="1" /></p>
  <p>and here's my code:</p>
  <pre><code>like_button = self.driver.find_element_by_xpath(
  '//*[@id=&quot;react-root&quot;]/section/main/div/div/article/div[3]/section[1]/span[1]/button/div')
            
  like_icon=like_button.find_element_by_xpath(
  '//*[@id=&quot;react-root&quot;]/section/main/div/div/article/div[3]/section[1]/span[1]/button/div/span/svg')
  </code></pre>
  <p>Whenever i run it an error occurs:</p>
  <pre><code>selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {&quot;method&quot;:&quot;xpath&quot;,&quot;selector&quot;:&quot;//*[@id=&quot;react-root&quot;]/section/main/div/div/article/div[3]/section[1]/span[1]/button/div/span/svg&quot;}
  </code></pre>