gpt4 book ai didi

java - 在真实设备上的 appium 中并行运行

转载 作者:行者123 更新时间:2023-11-29 04:38:46 24 4
gpt4 key购买 nike

所有这些天,我只在一个连接到我系统的设备上使用 appium 运行我的 android 测试用例

现在我需要在两个连接到我的系统的设备上运行,它们在 appium 上有两个不同的端口

我正在启动两个具有不同端口的 appium 我正在运行两个具有不同功能的测试用例但是两个测试在同一台设备上启动

我想知道如何设置功能以便在特定设备上启动测试

I had tried with this capability but no use
capabilities.setCapability("deviceName", "TA09401JJY");

请让我知道要设置哪些功能才能在特定设备上启动测试

最佳答案

我能够通过为每个应用程序使用唯一端口启动多个 appium 实例,在单独的真实设备上运行并行测试。然后,当我创建我的 appium 驱动程序时,我会传递我想要的设备的 UDID 以及我想用于该特定设备的 appium 实例的端口。

这是我用于实例化 appium 驱动程序的精简(仅 1 个设备)python 代码:

from appium import webdriver

def CreateDriver(value):
appiumHub = None
port = None

desired_caps = {}
desired_caps['autoAcceptAlerts'] = True
desired_caps['newCommandTimeout'] = '120'

if value == 'iPhone6s':
desired_caps['platformName'] = 'iOS'
desired_caps['deviceName'] = 'iPhone1'
desired_caps['platformVersion'] = '8.3'

desired_caps['udid'] = 'df33dh93827364kj3iujgr3g32t22hg878ww7878'

port = 4723

appiumHub = 'http://localhost:' + str(port) + '/wd/hub'
desired_caps['bundleId'] = 'com.someplace.myapp'

driver = webdriver.Remote(appiumHub, desired_caps)

return driver

我不得不复制我的测试方法并将它们放入自己的文件中,然后使用 ddt 传递要运行的设备。 :

@data('iPhone6s')
def test_P2A_Accept(self, value):
# Some test method

然后我将从命令文件 (MAC) 运行每个测试模块,让它们并行运行(并使用 py.test 以获得更好的报告):

results=$(date "+Results%Y%m%d-%H%M%S.html")

py.test /Users/jdoe/Documents/workspace/Unit\ Tests\ 2/UnitTests2Package/Python-Selenium/Tests_P2A.py --html=$results --self-contained-html

open $results

希望有一天我们可以通过相同的测试方法并行运行多个设备,但在那之前这是我能想到的最好的方法。

关于java - 在真实设备上的 appium 中并行运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40124068/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com