Home > Back-end >  selenium.common.exceptions.TimeoutException error using send_keys() from Selenium Python
selenium.common.exceptions.TimeoutException error using send_keys() from Selenium Python

Time:04-18

getting the error of timeout, tried to increase the time to 20, I see the page loading but still get the error and cannot see the email inserted to the field.

Code trials:

element = WebDriverWait(driver, 10).until(
    EC.presence_of_element_located((By.CLASS_NAME, 'input]'))
)
driver.find_element(By.XPATH, '//input[@class=input]').send_keys('[email protected]')

What is the problem?

CodePudding user response:

Try this

element = WebDriverWait(driver, 10).until(
    EC.presence_of_element_located((By.CLASS_NAME, 'input]'))

element.sendKeys('[email protected]')

or

element = WebDriverWait(driver, 10).until(
    EC.visibility_of_element_located((By.CLASS_NAME, 'input]'))

element.sendKeys('[email protected]')

CodePudding user response:

To send a character sequence to the element instead of presence_of_element_located() you need to induce WebDriverWait for the element_to_be_clickable() and you can use the following locator strategy:

  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//input[@]'))).send_keys("[email protected]")
    
  • Note: You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
  • Related