The input processing method of selenium+python for input field

  • 2020-12-09 00:57:07
  • OfStack

Recently, I was doing the automation test of the project (the company does not have this requirement). When the user management module was modifying the user information, the script was successfully run and the update operation was indeed done. However, after checking the login page, the information was not modified, and the editing function of the system module was confirmed to be available again.


if result_num>1:   
print "Begin to change user infomations"   
driver.find_element_by_xpath("//*[@id='tbodyUserInfo']/tr/td[8]/img[2]").click()   
driver.implicitly_wait(15)   
driver.find_element_by_id("uname").clear()   
driver.find_element_by_id("uname").send_keys("MoondyLi")   
driver.find_element_by_id("truename").clear()   
driver.find_element_by_id("truename").send_keys("chenchen")   
driver.find_element_by_id("updateUser").click()

After taking the screenshot, I did do the input operation. Later, I recorded the process once by using selenium IDE, which comes with Firefox, and found that there was one more step in the automation script recorded by the tool:

driver.find_element_by_id("uname").click()

First click on the input field for input text

With this step added, the script successfully modifies the data.


Related articles: