pythonseleniumweb-crawlersendkeys

Sendkeys selenium (python)


I am scraping a website using selenium with python. This website has a search engine that allows you to write. When I include the text, before hitting enter, I need to wait some time, otherwise it does the search. I wanted to know if there is a way to include a fluentwait instead of using time.sleep()

search_text = browser.find_element(By.CSS_SELECTOR, 'input#wuSearch')
search_text.click()
search_text.clear()
search_text.send_keys('text')
#time.sleep(2)
search_text.send_keys(Keys.ENTER)

Solution

  • There are different types of waits in selenium. You can find Selenium waits also, you can use Explicit waits or Implicit waits based on your code.