【问题标题】:Robotframework - adb clearing user data is forbiddenRobotframework - 禁止 adb 清除用户数据
【发布时间】:2021-09-14 11:15:25
【问题描述】:

我需要在安卓设备上运行移动浏览器,但是我遇到了这个错误

WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: 'Command 'adb -P 5037 -s emulator-5554 shell pm clear com.android.chrome' exited with code 255'; Stderr: 'Security exception: adb clearing user data is forbidden.

java.lang.SecurityException: adb clearing user data is forbidden.
        at com.android.server.am.ActivityManagerService.clearApplicationUserData(ActivityManagerService.java:7612)
        at com.android.server.pm.PackageManagerShellCommand.runClear(PackageManagerShellCommand.java:1616)
        at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:199)
        at android.os.ShellCommand.exec(ShellCommand.java:103)
        at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:24713)
        at android.os.Binder.shellCommand(Binder.java:634)
        at android.os.Binder.onTransact(Binder.java:532)
        at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:3075)
        at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4713)
        at android.os.Binder.execTransact(Binder.java:731)'; Code: '255'

androidUseRunningAppnoReset True 不适合我

现在有人如何克服这个错误吗? 这就是我正在尝试的

AndroidConnection
    ${Options}    Create Dictionary    androidPackage    com.android.chrome
    ${caps}    Create Dictionary    chromeOptions    ${Options}
    Set to Dictionary    ${caps}    platformName    Android
    Set to Dictionary    ${caps}    platformVersion    9.0
    Set To Dictionary    ${caps}    deviceName    emulator-5554
    Set To Dictionary    ${caps}    browserName    Chrome
    Set To Dictionary    ${caps}    noReset    true
    Create Webdriver    Remote    command_executor=http://localhost:4723/wd/hub    desired_capabilities=${caps}
    go to    https://google.com
    Close Browser
AndroidConnection
    ${Options}    Create Dictionary    androidPackage    com.android.chrome
    ${caps}    Create Dictionary    chromeOptions    ${Options}
    Set to Dictionary    ${caps}    platformName    Android
    Set to Dictionary    ${caps}    platformVersion    9.0
    Set To Dictionary    ${caps}    deviceName    emulator-5554
    Set To Dictionary    ${caps}    browserName    Chrome
    Set To Dictionary    ${caps}    androidUseRunningApp    true
    Create Webdriver    Remote    command_executor=http://localhost:4723/wd/hub    desired_capabilities=${caps}
    go to    https://google.com
    Close Browser

【问题讨论】:

  • 你在使用root设备吗?
  • 不,我使用的是无根设备(Realme C2)

标签: selenium selenium-chromedriver appium robotframework


【解决方案1】:
  1. 启动 Android SDK 的 Android Debug Bridge (adb) 服务器:

    adb start-server
    
  2. 如果在版本 33 之前的 Chrome 应用上进行测试,请确保 adb shell 对设备上的 /data/local 目录具有读/写权限:

    adb shell su -c chmod 777 /data/local
    

运行这个命令,你的手机上会有一个通知。点击接受

否则设置 chrome 选项,

 detach:false

【讨论】:

  • 执行adb shell su -c chmod 777 /data/local 时出现/system/bin/sh: su: not found 错误。我在移动设备上使用 chrome 版本 91
  • 确保你启动了 adb start-server,你能看到使用 adb devices 的设备吗?你开启开发者模式了吗?你启用usb调试了吗?
  • 是的,我有启动服务器,可以看到带有adb devices 的设备,并且当我运行adb shell 时可以连接到设备但是在adb shell 上运行su 命令时出现错误。使用detach:false 的另一个选项如何在robotframework 中添加此选项? ` AndroidConnection ${Options} Create Dictionary androidPackage com.android.chrome ${caps} Create Dictionary chromeOptions ${Options} Set To Dictionary ${caps} detach false ` 仍然收到同样的错误 adb clearing data is disabled
  • 有谁知道如何解决这个问题?
猜你喜欢
  • 2021-04-04
  • 1970-01-01
  • 2022-11-28
  • 2015-12-02
  • 2012-04-01
  • 1970-01-01
  • 2011-04-02
  • 2013-08-14
  • 1970-01-01
相关资源
最近更新 更多