#方式一
from pywinauto import Desktop
app = Desktop()
dialog = app[‘打开‘]
dialog["Edit"].type_keys(r"D:\appium.txt")
dialog["Button"].click()
#方式二
import win32gui
import win32con
def upload(filePath):
title = "打开"
dialog = win32gui.FindWindow("#32770", title) # 一级窗口
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)") # 四级
# 往编辑当中,输入文件路径
win32gui.SendMessage(edit, win32con.WM_SETTEXT, None, filePath) # 发送文件路径
win32gui.SendMessage(dialog, win32con.WM_COMMAND, 1, button) # 点击打开按钮
upload("D:\\appium.txt")
selenium-->文件上传