web自动化,selenium 无法清空输入框默认值继续输入
解决方法:
缺陷: 双击不一定能选中所有内容
from selenium.webdriver.common.action_chains import ActionChains element = driver.find_element_by_xpath('xpath路径') ActionChains(driver).double_click(element).perform() element.send_keys('009')
完美解决
from selenium.webdriver.common.keys import Keys element = driver.find_element_by_xpath('xpath路径') element.send_keys(Keys.CONTROL, 'a') element.send_keys('009')