title: How to send text to the search field through Selenium and Python
body: <p>I am trying to pass arguments to a search text in a HTML code using Selenium in Python:  </p>
  
  <p>I am working on the following HTML code:</p>
  
  <pre><code>&lt;/form&gt;&lt;form class="search-box-inner"&gt;
      &lt;div class="input-container"&gt;
          &lt;input type="text" class="typeahead search-box-input left" autocomplete="off" placeholder="Search ratings, research, analysts, and more..." maxlength="900"&gt;&lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The code does not have id or name. It has elements by class only.  </p>
  
  <p>I tried the following  </p>
  
  <pre><code>self.driver.find_elements_by_class_name('search-box-inner').send_keys("HSBC Bank plc")  
  </code></pre>
  
  <p>But I am getting the following error: </p>
  
  <blockquote>
  <pre><code>AttributeError: 'list' object has no attribute 'send_keys'
  </code></pre>
  </blockquote>
  
  <p>Then I tried to fetch first element of the list and send keys by using the following code:  </p>
  
  <pre><code>self.driver.find_elements_by_class_name('search-box-inner')[0].send_keys("HSBC Bank plc")
  </code></pre>
  
  <p>I get the following error:  </p>
  
  <blockquote>
  <pre><code>"selenium.common.exceptions.WebDriverException: Message: unknown error: cannot focus element"
  </code></pre>
  </blockquote>
  
  <p>I have tried both the above methods for "typeahead search-box-input left" class as well. it throws the same error. following is the code I used for this:</p>
  
  <pre><code>self.driver.find_elements_by_xpath("//*[@class='typeahead search-box-input left']").send_keys("HSBC Bank plc")
  </code></pre>
  
  <p>I again got the following error: </p>
  
  <blockquote>
  <pre><code>AttributeError: 'list' object has no attribute 'send_keys'
  </code></pre>
  </blockquote>
  
  <p>Then I tried to fetch the first element of the list with the following code:  </p>
  
  <pre><code>self.driver.find_elements_by_xpath("//*[@class='typeahead search-box-input left']").[0].send_keys("HSBC Bank plc")  
  </code></pre>
  
  <p>I again got the following error: </p>
  
  <blockquote>
  <pre><code>selenium.common.exceptions.ElementNotVisibleException: Message:
  element not interactable
  </code></pre>
  </blockquote>
  
  <p>I also tried the following way:  </p>
  
  <pre><code>element = wait.until(Ec.visibility_of_element_located((By.XPATH, "//*[@placeholder='Search ratings, research, analysts, and more...']")))
  </code></pre>
  
  <p>But could not sent the argument/keys to the search bar.<br>
  Any suggestions will be really helpful. </p>