我尝试用硒选择输入,但是当我使用它时,它不起作用:
driver = self.driver password = driver.find_element_by_xpath("//input[@name='password']") password.clear() password.send_keys(password) password.send_keys(Keys.RETURN) # the sentence below doesn't work password.send_keys(Keys.COMMAND, 'a') password.send_keys(Keys.DELETE)
我正在使用Mac,所以Keys.CONTROL无法正常工作,有人可以帮助我选择输入或清除输入吗?
谢谢
Mac无法使用COMMAND您需要的Keys.BACKSPACE 试试:
COMMAND
Keys.BACKSPACE
driver = self.driver password = driver.find_element_by_xpath("//input[@name='password']") password.clear() password.send_keys(password) password.send_keys(Keys.RETURN) #password = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@name='password']"))) #or #time.sleep(1) for i in range(len(password)): password.send_keys(Keys.BACKSPACE)