Appium 执行shell命令

直接使用adb shell命令不会报错,但是无法继续调用appium的api

实现某些操作时我们可以通过执行adb命令实现,比如某些点击事件,打开指定的文件等。

但是若在appium服务器内穿插使用adb shell命令,adb命令可正常执行,但是后续的appium的api调用会出现问题

selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: connect ECONNREFUSED 127.0.0.1:8200

新版本的appium服务器在默认情况下禁用了adb shell 等shell命令执行,必须在启动服务器时提供参数--relaxed-security

以启用远程Shell命令执行

参照如下方法,AppiumDriver执行时会自带adb shell

driver.execute_script('mobile: shell', {
    'command': 'echo',
    'args': ['arg1', 'arg2'],
    'includeStderr': True,
    'timeout': 5000
})
原文地址:https://www.cnblogs.com/muxs/p/15162374.html