【问题标题】:How to instruct Appium to prefer the emulated device instead of physical如何指示 Appium 更喜欢模拟设备而不是物理设备
【发布时间】:2018-07-04 09:50:56
【问题描述】:

我正在使用 Appium 在 Android 上自动化我的 UI 测试。

我有一个连接到我的计算机的物理设备,以及一个从 Android Studio 启动的模拟器:

$ adb devices
List of devices attached
0831bd3b21320609    no permissions (My phiscal Nexus 5)
emulator-5554   device (My Emulated device)

当我启动 Appium 并运行我的测试时,它会拿起我的物理设备。 Appium 日志:

[debug] [ADB] Running '/home/babken/android-sdk/platform-tools/adb' with args: ["-P",5037,"-s","0831bd3b21320609","wait-for-device"]
[debug] [ADB] Restarting adb
[debug] [ADB] Killing adb server on port 5037
[debug] [ADB] Getting connected devices...
[debug] [ADB] 2 device(s) connected
...

测试挂起,我收到错误,因为它连接到错误的设备。

我的 appium 功能中有这个:

desired_caps = {
    'platformName': 'Android',
    'deviceName': 'Android Device',
    'autoGrantPermissions': True,
    'app': apk_location,
    'newCommandTimeout': 36000,
}

我知道我可以将udid 功能设置为emulator-5554,但模拟器的名称可以更改。

作为一种解决方法,我也可以关闭我的 Nexus 或关闭 USB 调试,但这不是我的解决方案。

【问题讨论】:

    标签: android adb appium appium-android python-appium


    【解决方案1】:

    您是否尝试过使用“avd”功能?

    有点像

    desired_caps = {
        'platformName': 'Android',
        'deviceName': 'Android Emulator',
        'avd': 'emulator',
        'autoGrantPermissions': True,
        'app': apk_location,
        'newCommandTimeout': 36000,
    }
    

    在网站上,他们举了一个例子:api19,所以也许你可以指定你的模拟器 API 版本而不是名称。 (我没试过,但它可能有效) 你也应该输入 deviceName 'Android Emulator'

    https://appium.io/docs/en/writing-running-appium/caps/

    【讨论】:

    • 我不想让 Appium 启动模拟器,我希望它在已经运行的模拟器上运行。
    • 好的,你试过 deviceName = Android Emulator 吗?
    • 是的,它仍然会使用我的物理设备。
    猜你喜欢
    • 1970-01-01
    • 2018-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-08
    • 2020-06-09
    • 2014-12-08
    相关资源
    最近更新 更多