Python - selenium send_keys () does not work in this form field

3

I made the correct identification with xPath, the .clear () software works perfectly, however the send_keys does not work at all. Here is the form's HTML code:

<input id="yui-gen19" name="e_dt_ini_0" size="12" value="01/06/2015" class="dw-params43C55" 
tabindex="1" style="position: absolute; left: 3.49in; top: 0in; width: 0.967in; height: 0.197in;" 
onfocus="{dw_params.itemGainFocus(0,10,this,dw_params.gobs.e_dt_ini); dw_params.selectControlContent(this);}" 
onclick="{var ret;  ret= dw_params.itemClicked(0,10,'e_dt_ini',0,-1); return ret;}" 
onchange="{this.bChanged = true;}" onkeypress="return DW_EditKeyPressed(event, this, -1);" 
onblur="{dw_params.itemLoseFocus (this);}" type="text">

Everything else works perfectly. This form field is unbearable even for user direct filling.

The code in Python:

 # Preenche o Formulário
    hoje = datetime.datetime.strftime(datetime.datetime.now(), '%d/%m/%Y')
    dataInicioXpath = "//*[@id='dw_params_detail_0']/input[4]"
    dataFimXpath = "//*[@id='dw_params_detail_0']/input[3]"
    medicoXpath ="//*[@id='dw_params_detail_4']/input[3]"
    relButtonXpath = "//*[@id='bt_emitir']"


    dataInicioElement = WebDriverWait(driver, 15).until(lambda driver: driver.find_element_by_name("e_dt_ini_0")) # find_element_by_xpath(dataInicioXpath))
    dataFimElement = WebDriverWait(driver, 15).until(lambda driver: driver.find_element_by_xpath(dataFimXpath))
    medicoElement = WebDriverWait(driver, 15).until(lambda driver: driver.find_element_by_xpath(medicoXpath))
    relButtonElement = WebDriverWait(driver, 15).until(lambda driver: driver.find_element_by_xpath(relButtonXpath))


    dataInicioElement.click()
    dataInicioElement.clear()
    dataInicioElement.send_keys(hoje)
    dataFimElement.click()
    dataFimElement.clear()
    dataFimElement.send_keys(hoje)
    medicoElement.clear()
    medicoElement.send_keys("11111")
    relButtonElement.click()
    
asked by anonymous 14.07.2016 / 22:36

2 answers

1

Have you tried to pass this value via javascript?

webdriver.execute_script("document.getElementById('yui-gen19').value = '"+hoje+"'")
    
15.07.2016 / 14:10
0

Why do not you select directly by id ?

campo = driver.find_element_by_css_selector('#yui-gen19')
    
14.07.2016 / 22:44