title: How to get an XPath from selenium webelement or from lxml?
body: <p>I am using selenium and I need to find the XPaths of some selenium web elements.</p>
  
  <p>For example:</p>
  
  <pre><code>import selenium.webdriver
  driver = selenium.webdriver.Firefox()
  
  element  = driver.find_element_by_xpath(&lt;some_xpath&gt;)
  elements = element.find_elements_by_xpath(&lt;some_relative_xpath&gt;)
  
  for e in elements:
      print e.get_xpath()
  </code></pre>
  
  <p>I know I can't get the XPath from the element itself, but is there a nice way to get it anyway? </p>
  
  <p>I tried using lxml to parse the HTML, but it doesn't recognize the XPath, <code>&lt;some_xpath&gt;</code>, I passed, even though <code>driver.find_element_by_xpath(&lt;some_xpath&gt;)</code> <strong>did</strong> manage to find that element.</p>