如何确保appium节点仅连接到一部手机? [英] How to make sure the appium node is connected to only one phone?

查看:224
本文介绍了如何确保appium节点仅连接到一部手机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行(全部在一台机器上)多个作为节点连接到硒网格集线器的appium服务器,并且在端口5555上有多个电话连接到我的adb(在我的情况下是通过WiFi).

I run (all on one machine) multiple appium servers connected as nodes to a selenium-grid hub and I have multiple phones connected to my adb on port 5555 (in my case via WiFi).

问题,我遇到的问题是三部手机中有两部具有相匹配的功能(Android 7.1.1,Chrome浏览器).因此,当我为连接9进行测试时,如果占用了连接6的网格节点,或者反之,我会要求在连接6上运行测试,但该测试被占用了,但是测试在连接6上进行.关联9.因此,我想要/需要的是一种配置,我可以使用它来使其具有足够的唯一性,以启动仅连接到一部手机的appium服务器.

The issue I have with this is that two of the three phones have capabilities that are matching (Android 7.1.1, Chrome browser). So when I fire up a test for the nexus 9, if occupies the grid node for nexus 6. Or even the other way around, I ask to run the test on the nexus 6, this one get occupied, but the test runs on the nexus 9. So what I want/need is a configuration I can use to make it unique enough to fire up an appium server that only connects to one phone.

我的设置

  • Windows 10(x64)
  • Ruby v2.3.3(32位)和gems watir v6.8.4, selenium-webdriver v3.6.0
  • Selenium-Standalone-Server v3.6.0
  • Appium Desktop v1.2.5(服务器v1.7.1)
  • 或通过命令行Appium服务器v1.6.5
  • Windows 10 (x64)
  • Ruby v2.3.3 (32 bit) with the gems watir v6.8.4, selenium-webdriver v3.6.0
  • Selenium-Standalone-Server v3.6.0
  • Appium Desktop v1.2.5 (server v1.7.1)
  • Or via command line Appium server v1.6.5

测试设备

  • Nexus 5(电话)-Android 6.0.1-192.1.1.120:5555(在adb设备列表中)
  • Nexus 6(电话)-Android 7.1.1-192.1.1.63:5555(在adb设备列表中)
  • Nexus 9(平板电脑)-Android 7.1.1-192.1.1.55:5555(在adb设备列表中)

网格

java -jar selenium-standalone-server3.6.0.jar -role hub

通过命令行(或桌面应用)启动appium服务器

appium -a 0.0.0.0 -p 4723 -bp 4724 --nodeconfig node_nexus5.json

appium -a 0.0.0.0 -p 4725 -bp 4726 --nodeconfig node_nexus6.json

appium -a 0.0.0.0 -p 4727 -bp 4728 --nodeconfig node_nexus9.json

node_nexus6.json(节点5和9仅在platformVersion,deviceName,udid和applicationName上有所不同)

{
  "capabilities":[
    {
    "platform": "ANDROID",
    "platformName": "Android",
    "platformVersion": "7.1.1",
    "browserName": "chrome",
    "version": "6",
    "deviceName": "Nexus6",
    "udid": "192.1.1.63:5555",
    "applicationName": "Nexus6",
    "maxInstances": 1
    }
  ],
  "configuration":
    {
    "cleanUpCycle":2500,
    "timeout":30000,
    "maxSession": 1,
    "register": true,
    "registerCycle": 1000,
    "hubPort": 4444,
    "hubHost": "localhost"
    }
}

我尝试过的事情

设备名称,应用程序名称,版本功能

The deviceName, applicationName, version capability

browser = Watir::Browser.new :chrome, {
    url: "http://localhost:4444/wd/hub",  
    platformName: "Android",
    platformVersion: "7.1.1",
    browserName: "chrome",
    version: "6",
    deviceName: "Nexus6",
    applicationName: "Nexus6"
}

结果

Results

仅使用设备名称时,结果最奇怪. 在网格上,联系6被占用.但是我看到我想对nexus 5做出响应的服务器来承担这项工作,但是它在nexus 9上执行了.

When only using the device name, the result was the weirdest. On the grid the nexus 6 was being occupied. But I saw the server I wanted to respond to the nexus 5 to take the job, but it got executed on the nexus 9

当我包含applicationName时,正确的网格节点已被占用(nexus 6),我以为要响应的appium服务器确实响应了,但是它再次在nexus 9设备上执行了测试.

When I included the applicationName, the correct grid node was occupied (nexus 6), the appium server I thought was going to respond did respond, but it again executed the test on the nexus 9 device.

版本与applicationName相同.

Version did the same as applicationName.

我没有尝试过,因为它只会像超时一样覆盖此功能.

Udid I did not try because it will just overwrite this capability like a timeout.

主要问题

如何将appium服务器节点配置为仅服务于一部特定的电话,而无需编写自定义功能匹配器?

How can I configure the appium server node to only serve one specific phone without the need for writing a custom capability matcher?

推荐答案

令我惊讶的是,我之前尝试过的功能没有起作用,因为在其他论坛帖子中,它似乎对其他人有用(尽管通常不清楚他们是否使用了硒网格).

I was surprised that the capabilities I tries before did not work since in other forum posts it seemed to have worked for others (although usually not clear if they use a selenium-grid).

到目前为止,我的解决方案是使用以下appium服务器(网格节点)配置(必须包括udid和版本)

My solution so far is to use the following appium server (grid node) config (both udid and version need to be included)

{
  "capabilities":[
    {
    "platform": "ANDROID",
    "platformName": "Android",
    "platformVersion": "7.1.1",
    "browserName": "chrome",
    "version": "6",
    "deviceName": "Nexus6",
    "udid": "192.1.1.63:5555",
    "maxInstances": 1
    }
  ],
  "configuration":
    {
    "cleanUpCycle":2500,
    "timeout":30000,
    "maxSession": 1,
    "register": true,
    "registerCycle": 1000,
    "hubPort": 4444,
    "hubHost": "localhost"
    }
}

对于启动会话,同样适用(包括udid和version)

And for starting the session the same applies (include udid and version)

Watir::Browser.new :chrome, {
    url: "http://localhost:4444/wd/hub",  
    platformName: "Android",
    platformVersion: "7.1.1",
    browserName: "chrome",
    version: "6",
    deviceName: "Nexus6",
    udid: "192.1.1.63:5555"
}

仍然很高兴知道我尝试的上述解决方案为何不起作用.从我读过的所有东西中,我认为这就是原因. 网格仅查看platformName,platformVersion,browserName,version(browserVersion)和deviceName(尽管最后一个被忽略).基于此,它将所有功能转发到匹配的appium节点.然后udid被appium节点识别为一种功能,并用于与我想要的电话建立连接. 如果我忽略了udid,它将连接到与其他功能匹配的电话,并忽略我在初始配置中设置的udid.最后是我不明白为什么会这样的原因,但是对我来说,这种设置(带有udid)是可行的.

It would still be good to know why the above solutions I tried did not work. From all things I did read I assume this is the reason. The grid only looks at platformName, platformVersion, browserName, version(browserVersion) and deviceName (although this last one is being ignored). Based on that it will forward all capabilities to a matching appium node. Then udid is recognized as a capability by the appium node and used to make a connection to the phone I want. If I leave out the udid, it will connect to a phone that is matching the other capabilities and ignores the udid I set in the initial config. That last is what I don't understand why this is the case, but for me this setup (with udid) works.

这篇关于如何确保appium节点仅连接到一部手机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆