目 录CONTENT

文章目录

使用pyautogui实现文件上传

phyger
2024-01-18 / 0 评论 / 2 点赞 / 2,244 阅读 / 428 字 / 正在检测是否收录...

使用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()
2

评论区