简体   繁体   English

并行在真实设备上运行

[英]Parallel runs in appium on real devices

All these days I am running my android test cases using appium on only one connected device to my system 所有这些天我运行我的Android测试案例使用appium只有一个连接设备到我的系统

Now i need to run on two devices which was connected to my system with two different ports on appium 现在我需要运行两个连接到我的系统的设备,在appium上有两个不同的端口

I am launching two appium's with different ports I am running two test cases with different capabilities But two tests are launching on the same device 我正在使用不同的端口启动两个appium我正在运行两个具有不同功能的测试用例但是在同一个设备上启动了两个测试

I wish to know how to set capabilities so that test will launch on particular device 我想知道如何设置功能,以便测试将在特定设备上启动

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

Please let me know what are the capabilities to set so that test will launch on particular device 请告诉我设置的功能,以便在特定设备上启动测试

I was able to run parallel tests on separate real devices by starting several instances of appium using unique ports for each. 通过使用每个的唯一端口启动appium的几个实例,我能够在单独的真实设备上运行并行测试。 Then when I would create my appium driver, I would pass the UDID of the device I wanted along with the port of the appium instance that I wanted to use for that specific device. 然后当我创建我的appium驱动程序时,我会传递我想要的设备的UDID以及我想用于该特定设备的appium实例的端口。

Here is my streamlined (only 1 device) python code for instantiating the appium driver: 这是我的简化(只有1个设备)python代码,用于实例化appium驱动程序:

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

I had to make copies of my test methods and put them in their own file then passed along what device to run using ddt : 我必须复制我的测试方法并将它们放在自己的文件中,然后传递使用ddt运行的设备:

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

Then I would run each test module from a command file (MAC) to get them to run in parallel (and using py.test for better reporting): 然后我将从命令文件(MAC)运行每个测试模块以使它们并行运行(并使用py.test进行更好的报告):

results=$(date "+Results%Y%m%d-%H%M%S.html") 结果= $(日期“+结果%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 py.test / Users / jdoe / Documents / workspace / Unit \\ Tests \\ 2 / UnitTests2Package / Python-Selenium / Tests_P2A.py --html = $ results --self-contained-html

open $results 打开$结果

Hopefully, there will come a day when we can run multiple devices in parallel from the same test method, but until then this is the best I could come up with. 希望有一天,我们可以通过相同的测试方法并行运行多个设备,但在此之前,这是我能想到的最好的设备。

capabilities.setCapability(UDID_KEY, UDID_VALUE);

UDID_VALUE is unique for every device. UDID_VALUE对于每个设备都是唯一的。

It can be taken by using adb devices on cmd. 可以在cmd上使用adb设备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM