3
I made the correct identification with xPath, the software . clear() works perfectly, however send_keys does not work at all. Follow the HTML code of the form:
<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 direct user 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()
Shows identification with xPath
– Math
Ah, it would be nice if you told us if he’s inside a
<iframe>
.– Leonel Sanches da Silva
Esse campo do formulário é insuportável até para o preenchimento direto pelo usuário.
I managed to fill in the hand– Math