title: Selenium python: find_elements_by_tag_name and looping works but not find_element_by_xpath
body: <p>I'm trying to locate a 'div' element which has the title 'Type a message'.</p>
  <p>The following piece of code works:</p>
  <pre><code>div_nodes = driver.find_elements_by_tag_name('div')
  for element in div_nodes:
      if element.get_attribute('title') == 'Type a message':
          element.send_keys(Keys.ENTER)
  </code></pre>
  <p>But this does not work:</p>
  <pre><code>element = driver.find_element_by_xpath('//div[@title=&quot;Type a message&quot;]')
  element.send_keys(Keys.ENTER)
  </code></pre>
  <p>I get the error <code>selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {&quot;method&quot;:&quot;xpath&quot;,&quot;selector&quot;:&quot;//div[@title=&quot;Type a message&quot;]&quot;}</code></p>
  <p>Edit:
  Here is the relevant part of the code and webpage. I'm passing a phone number and a message to web.whatsapp.com. Below is the working code. If I replace the last 4 lines with find_element_by_xpath, it does not work:</p>
  <pre><code>from selenium import webdriver
  from selenium.webdriver.common.keys import Keys
  import urllib.parse
  
  options = webdriver.ChromeOptions()
  driver = webdriver.Chrome(executable_path=r'&lt;mypath&gt;/chromedriver.exe', options=options)
  qry = {}
  qry['phone'] = str(contact_number)
  qry['text'] = message
  url = &quot;https://web.whatsapp.com/send/?{}&quot;.format(urllib.parse.urlencode(qry))
  driver.get(url)
  div_nodes = driver.find_elements_by_tag_name('div')
  for element in div_nodes:
      if element.get_attribute('title') == 'Type a message':
          element.send_keys(Keys.ENTER)
  </code></pre>