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