关于 mobile: shell 在更新日志中说明,是从 1.7.1 升级到 1.7.2 中 “Add --relaxed-security, and mobile: shell access to adb”,并搜索 github 中 appium 库,找到需要配置 desiredcapabilities 中 relaxedSecurityEnabled 为 true,但实际执行无效。

TesterHome 社区有没有 Appium 项目组的大牛,能否跟进了解一下这个 mobile: shell 到底如何使用

我的 python 代码:
###
···python
def AndroidAppEmulator(platformVersion, appActivity, appPackage):
caps = {}
caps['relaxedSecurityEnabled'] = True
caps['automationName'] = 'UiAutomator2'
caps['platformName'] = 'Android'
caps['platformVersion'] = platformVersion
caps['deviceName'] = 'Android Emulator'
caps['appPackage'] = appPackage
caps['appActivity'] = appActivity
caps['unicodeKeyboard'] = True
caps['resetKeyboard'] = True
return WebDriver('http://127.0.0.1:4723/wd/hub', caps)

driver = learnappium.AndroidAppEmulator('7.1.1','.DialtactsActivity','com.android.dialer')
opts={'command':'am',
'args':['start','-N','com.android.calculator2/.Calculator']}
driver.execute_script('mobile: shell', opts)


报错信息如下:
###
···
  File "C:/Users/jack/PycharmProjects/AppiumTest/learnappium/Test06.py", line 9, in <module>
    print(driver.execute_script('mobile: shell', opts))
  File "C:\Users\jack\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium-3.8.0-py3.6.egg\selenium\webdriver\remote\webdriver.py", line 546, in execute_script
    'args': converted_args})['value']
  File "C:\Users\jack\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium-3.8.0-py3.6.egg\selenium\webdriver\remote\webdriver.py", line 311, in execute
    self.error_handler.check_response(response)
  File "C:\Users\jack\AppData\Local\Programs\Python\Python36\lib\site-packages\appium_python_client-0.26-py3.6.egg\appium\webdriver\errorhandler.py", line 29, in check_response
  File "C:\Users\jack\AppData\Local\Programs\Python\Python36\lib\site-packages\appium_python_client-0.26-py3.6.egg\appium\webdriver\errorhandler.py", line 24, in check_response
  File "C:\Users\jack\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium-3.8.0-py3.6.egg\selenium\webdriver\remote\errorhandler.py", line 237, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Appium server must have relaxed security flag set in order to run any shell commands
···


↙↙↙阅读原文可查看相关链接,并与作者交流