title: Getting ID of Selenium WebElement in Python?
body: <p>If I have the following HTML <code>&lt;a id="id" class="class" href="href"&gt;Element Text&lt;/a&gt;</code> how would I get "id" to be returned? My current procedure is:</p>
  
  <pre><code>print("Attribute: " + element.get_attribute('id'))
  print("Property: " + element.get_property('id'))
  print("Class: " + element.get_attribute('class'))
  </code></pre>
  
  <p>But all of those return empty strings. I am, however, able to get the text by using <code>element.text</code></p>
  
  <p>EDIT: Here's a more in depth explanation</p>
  
  <p>I'm looking for an element but that element's ID varies. There is, however, an element linked to the element I want that I can find using it's xpath and comparing it's text to a specific text that I know beforehand. The ID of that element is something in the form of someID_XX. By taking the XX and appending it to another fixed string, I can then search for the element that I actually want. My issue is that once I get the second element (not the one I want directly, but the one that can lead me to the one I want) I can't seem to get it's ID attribute even though it seems to have one in the html. My question is, how do I get the id attribute?</p>