首页 > 技术文章 > selenium清空元素时,.clear不执行

xqnq2007 2017-12-01 14:55 原文

应该是由于鼠标焦点没有定位到相应元素

driver.find_element_by_xpath('//input[@type="password"]').click()
driver.find_element_by_xpath('//input[@type="password"]').clear()
driver.find_element_by_xpath('//input[@type="password"]').send_keys(newpass)

可以先执行 click定位到相应元素

推荐阅读