total beginner here. I am automating a form used for ''non-conformity'' ticket, and I am filling all the text field sucessfully except one. The thing is, I do not receive any error message. The code go all the way to the end but leave one text field empty. That text box is the body of the ticket and is used to decribe the issue, so I can't work my way around not using it.
Here is the code I wrote initially:
print(desc_to_write) #Use while debuggin this to confirm the variable contain the string.
desc = web.find_element_by_xpath('/html/body')
desc.send_keys(desc_to_write)
#No error but still nothing in the browser text field.
The xpath is what I get with Chrome's ''Copy Xpath'' tool.
I have also tried the following methods with no success (assiociated comment are the error received).
#1:
desc = web.find_element_by_class_name('editor_body')
desc.send_keys(desc_to_write)
#selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".editor_body"}
#2 :
desc = web.find_element_by_css_selector('body.editor_body')
desc.send_keys(desc_to_write)
#NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"body.editor_body"}
#3 :
desc = web.find_element_by_xpath('/html/body')
desc.click()
time.sleep(5)
desc.send_keys(desc_to_write)
#No error but still nothing in the browser text field.
#4 : I have also tried with a full Xpath with no success. I had to guess the full by myself as the ''Copy full Xpath'' tool would return the same path as above. I got most of that path using the Xpath of the ''iframe'' and adding the ''/html/body''. Note that I know nothing about HTML, so I might have done a mistake somewhere. It was an out-of-desparation attempt.
desc = web.find_element_by_xpath('//*[@id="NewRequestTab"]/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr[1]/td/table/tbody/tr[1]/td/table/tbody/tr[14]/td[2]/div/iframe/html/body')
desc.send_keys(desc_to_write)
The resulting error is :
#selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="NewRequestTab"]/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr[1]/td/table/tbody/tr[1]/td/table/tbody/tr[14]/td[2]/div/iframe/html/body"} (Session info: chrome=88.0.4324.104)
I am also attaching a screen shot of the code as seen in the Chrome's developper tool. I could copy the actual code but I honestly know how HTML work and I do not know what would be relevant. I can provide more if needed. The highlighted part is the result of the inspector tool in Chrome's developper tool.
Thanks for the help!
HTML CODE
question from:
https://stackoverflow.com/questions/65878108/selenium-send-keys-leaves-field-empty-with-no-error 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…