Search code examples
pythonseleniumtextbox

Python Selenium: input textbox, send_keys not working


In my python code, I want to input a date in the Date textbox. However, the existing date cannot be cleared, and a date cannot be entered either. I am using Selenium. I think the element is found, but anyway the Send_keys() function does not work on this textbox. What is the problem?

Thanks.

url = 'https://iol1.iroquois.com/infopost/Pages/OperationallyAvailable.php?parentId=100'
browser.get(url)
date_element = browser.find_element_by_id('searchDateTextfield-inputEl')
date_element.click()
date_element..clear()
date_element.send_keys(slash_date)
date_element.submit()

Solution

  • Below is the full-functional code-

    import time
    from selenium.webdriver.common.keys import Keys
    from selenium import webdriver
    from selenium.webdriver.support.wait import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    from selenium.webdriver.common.by import By
    browser = webdriver.Firefox()
    
    url = 'https://iol1.iroquois.com/infopost/Pages/OperationallyAvailable.php?parentId=100'
    browser.get(url)
    WebDriverWait(browser,10000).until(EC.visibility_of_element_located((By.TAG_NAME,'body')))
    date_element = browser.find_element_by_id('searchDateTextfield-inputEl')
    date_element.click()
    date_element.send_keys(Keys.HOME)
    
    # For date 10 Oct 2015
    date_element.send_keys("10042015")
    date_element.send_keys(Keys.TAB)
    browser.find_element_by_xpath("//span[@id='retrieveButton-btnInnerEl']").click()
    time.sleep(100)
    browser.close()