title: Why is my Selenium xpath expression returning an [object attribute] instead of an element?
body: <p>I'm making a scraper that will through my webpage and grab all of the links. A lot of the links are in closed list also known as a tree. Therefore, I found the xpath that holds all of the links. I ran the following xpath in google inspect and it ran perfectly fine giving me the following output.</p>
  
  <pre><code>var result=$x("//div[@id='index__tree']//a[contains(text(),doku.php)]/@href")
  
  result[0].value
  "/doku.php?ihome"
  result[4].value
  "/doku.php?start"
  </code></pre>
  
  <p>I than transferred the xpath into selenium code:</p>
  
  <pre><code>a = driver.find_elements_by_xpath("//div[@id='index__tree']//a[contains(text(),doku.php)]/@href")
  
  for aa in a:
          print(aa)
  
  </code></pre>
  
  <p>I then ran the code and received the following error:</p>
  
  <pre><code>opening browser
  Login Successful
  Traceback (most recent call last):
    File "wiki.py", line 49, in &lt;module&gt;
      a = driver.find_elements_by_xpath("//div[@id='index__tree']//a[contains(text(),doku.php)]/@href")
    File "/home/aevans/wikiProject/venv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 410, in find_elements_by_xpath
      return self.find_elements(by=By.XPATH, value=xpath)
    File "/home/aevans/wikiProject/venv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 1007, in find_elements
      'value': value})['value'] or []
    File "/home/aevans/wikiProject/venv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
      self.error_handler.check_response(response)
    File "/home/aevans/wikiProject/venv/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
      raise exception_class(message, screen, stacktrace)
  selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: The result of the xpath expression "//div[@id='index__tree']//a[contains(text(),doku.php)]/@href" is: [object Attr]. It should be an element.
    (Session info: headless chrome=73.0.3683.86)
    (Driver info: chromedriver=73.0.3683.86,platform=Linux 3.10.0-957.12.2.el7.x86_64 x86_64)
  </code></pre>