使用pyautogui实现交互式文件上传
from selenium import webdriver
import pyautogui
import time
driver = webdriver.Chrome()
driver.get('http://127.0.0.1:8989')
driver.implicitly_wait(10)
driver.find_element('xpath', '/html/body/button').click()
time.sleep(3)
# use pyautogui upload file
pyautogui.write('/Users/hfy/Downloads/chromedriver-mac-x64/chromedriver', interval=0.1)
time.sleep(3)
pyautogui.press('enter', 1)
pyautogui.press('enter', 1)
time.sleep(5)
driver.close()
评论区