web自动化之文件上传操作

#!/usr/bin/python3
# -*- coding: utf-8 -*-
#Author: xiaojian
#Time: 2018/11/16 20:49 import win32gui
import win32con def upload(filepath):
dialog = win32gui.FindWindow("#32770","打开") #一级窗口#如果是其它的浏览器,可能需要改第二个参数,谷歌叫打开
ComboBoxEx32 = win32gui.FindWindowEx(dialog,0,"ComboBoxEx32",None) #二级
ComboBox = win32gui.FindWindowEx(ComboBoxEx32,0,"ComboBox",None) #三级
#路径输入
edit = win32gui.FindWindowEx(ComboBox,0,"Edit",None) #四级
#打开按钮
button = win32gui.FindWindowEx(dialog,0,"Button","打开(&O)") #二级 #filepath = "D:\\appium_server.log"
#输入路径
#点击打开按钮
win32gui.SendMessage(edit,win32con.WM_SETTEXT,None,filepath) #发送文件路径
win32gui.SendMessage(dialog, win32con.WM_COMMAND, 1, button) #点击打开按钮 upload("D:\\appium_server.log")
上一篇:Vue(二) 计算属性


下一篇:基于python的selenium两种文件上传操作