python使用appium时出现错误
{“status”:100,“value”:{“error”:“invalid argument”,“message”:“Bad capabilities. Specify either app or appTopLevelWindow to create a session”}}
下方是生成的json内容,不能匹配winAppDriver的规则
{"capabilities":{"firstMatch":[{"platformName":"Windows","appium:app":"Microsoft.WindowsCalculator_8wekyb3d8bbwe!App","appium:deviceName":"WindowsPC","ms:experimental-webdriver":true}]}}
正确的内容应该是没有前缀"appium:",如下
{"capabilities": {"firstMatch": [{"platformName": "Windows", "appium:deviceName": "WindowsPC", "appium:app": "C:\\Windows\\System32\\notepad.exe"}]}, "desiredCapabilities": {"platformName": "Windows", "deviceName": "WindowsPC", "app": "C:\\Windows\\System32\\notepad.exe"}}
查询appium的文档说明,是因为2.0版本使用了与1.0版本不同的json生成公式,
可以使用1.0版本的appium-python-client 来替代
https://pypi.tuna.tsinghua.edu.cn/simple/appium-python-client/
在尝试使用Python的Appium库连接WinAppDriver时遇到了错误,错误信息提示需指定'app'或'appTopLevelWindow'来创建会话。分析发现,生成的JSON内容不匹配WinAppDriver的要求,缺少了对于'appium:'前缀的适配。根据Appium文档,这是由于版本2.0采用了不同的JSON格式。为解决此问题,建议回退到1.0版本的appium-python-client库,该版本的语法更符合WinAppDriver的期望。





