windows app 自动化

准备

开始

1、开启Windows开发者选项

2、启动 WinAppDriver 服务

注意:WinAppDriver 需要管理员启动

3、开始运行

简易脚本

import time
from appium import webdriver


class TestDemo:
    def setup(self):
        caps = {}
        caps['app'] = r'D:\WeChat\WeChat.exe'
        caps['deviceName'] = 'WindowsPC'
        caps['platformName'] = 'Windows'
        self.driver = webdriver.Remote("http://localhost:4727", desired_capabilities=caps)
        self.driver.implicitly_wait(10)


    def test_demo(self):
        self.driver.find_elements_by_xpath('xxxx')

    def teardown(self):
        time.sleep(10)
        self.driver.quit()

参数解析

app

这个参数要指定启动 app 的 exe 文件

例如:通过快捷方式找到目标文件

deviceName

deviceName 需要指定的参数为 WindowsPC

platformName

platformName 需要指定的参数为 Windows

更多参数请参考:https://github.com/appium/appium-windows-driver#windowsdriver-specific-capabilities