这里会用到的有
clear()清除
send_keys()输入
如下:
from selenium import webdriver import time driver=webdriver.Chrome() driver.implicitly_wait(8) driver.maximize_window() driver.get("https://www.csdn.net/") driver.find_element_by_xpath("//li[@class='userinfo']/a").click()#点击登录按钮 time.sleep(1) driver.find_element_by_xpath("//div[@class='main-select']/ul[1]/li[1]/a").click() time.sleep(1) driver.find_element_by_xpath("//input[@name='all']").clear() #清除文字 driver.find_element_by_xpath("//input[@name='all']").send_keys("name") #输入账号 driver.find_element_by_xpath("//input[@type='password']").send_keys("password") driver.quit()