python+selenium 浏览器内上传文件
try: import autoit except: os.system('pip install -U pyautoit') import pyautogui #谷歌浏览器不存在时尝试捕获火狐浏览器窗口 title_name = ['打开','Open','文件上传','File Upload'] for j in title_name: try: handle = "[CLASS:#32770; TITLE:%s]" % j autoit.win_wait(handle, 30)#等待指定窗口可见 break except: continue else: task_io.set_fail_fields(1900, '上传图片失败,打开文件弹框不可见') task_log.log_info(self.imgge_path_list[i]) self.web.delay(4, 6) autoit.control_set_text(handle, "Edit1", self.imgge_path_list[i])#输入指定文件路径打开 self.web.delay(2, 3) autoit.control_click(handle, "Button1")#点击上传 self.web.delay(8, 10)#等待时间