Appium试射多台设备上失败 [英] Appium test launch fails on multiple devices

查看:1048
本文介绍了Appium试射多台设备上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作Windows 7计算机上,并试图实现一个Appium测试,推出2款真正的Andr​​oid设备并行。
我能够发动对每个单独的2台设备和测试的预期,但使用JUnit同步推出失败,下面的设备之一堆栈跟踪执行的:

 信息:[调试]推命令appium工作队列:元素:gettext的{elementId:2}]
信息:[调试] [引导] [调试]得到客户数据:{CMD:行动,行动:元素:gettext的,PARAMS:{elementId:2}}
信息:[调试] [引导] [调试]知道类型的动作命令
信息:[调试] [引导] [调试]得到命令操作:的getText
信息:[调试] [引导] [调试]返回结果:{值:注册,状态:0}
信息:[调试]响应成功客户端:{身份:0,值:注册,的sessionId:c730d16f-ca7f-42AA-BE23-da33bbefd9f0}
信息:LT; - GET / WD /集线器/会话/ c730d16f-ca7f-42AA-BE23-da33bbefd9f0 /元/ 2 /文本200 56.413毫秒 - 81 {身份:0,值:注册, 的sessionId:c730d16f-ca7f-42AA-BE23-da33bbefd9f0}
信息: - > DELETE / WD /集线器/会话/ c730d16f-ca7f-42AA-BE23-da33bbefd9f0 {}
信息:关闭appium会议
信息:[调试] pressing HOME按钮
信息:[调试]执行CMD:C:\\用户\\ Kristaps.Mezavilks \\应用程序数据\\本地\\ Android的\\ SDK \\平台工具\\ adb.exe -s 192.168.1.204:5555壳输入的KeyEvent 3
信息:[调试]停止捕获logcat中
信息:[调试] logcat的终止,code空,信号SIGTERM
信息:[调试] [引导] [调试]得到客户数据:{CMD:关机}
信息:[调试] [引导] [调试] GOT型号关机命令
信息:[调试] [引导] [调试]返回结果:{值:OK,关停,状态:0}
信息:[调试] [引导] [调试]关闭客户端连接
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:numtests = 1
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:流=。
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:ID = UiAutomatorTestRunner
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:测试= testRunServer
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:类= io.appium.android.bootstrap.Bootstrap
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:电流= 1
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_ code:0
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:流=
信息:[调试] [UIAUTOMATOR STDOUT]为WatcherResultPrinter =测试结果。
信息:[调试] [UIAUTOMATOR STDOUT]时间:6.985
信息:[调试] [UIAUTOMATOR STDOUT] OK(1试验)
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_ code:-1
信息:[调试]发送shutdown命令,等待UiAutomator停止...
信息:[调试] UiAutomator正常关闭
信息:[调试]清理机器人对象
信息:[调试]清理appium会议
信息:[调试]响应成功客户端:{身份:0,价值:空的sessionId:c730d16f-ca7f-42AA-BE23-da33bbefd9f0}

推出之前,我执行以下操作:


  • 启动硒网格:结果
    Java的罐子硒的服务器独立-2.46.0.jar -role -hub -throwOnCapabilityNot present

  • 2推出节点Appium:结果
    节点appium --nodeconfig C:\\用户\\ Kristaps.Mezavilks \\硒\\ node_p.json -p 4728 --udid 192.168.219:5555 结果
    和结果
    节点appium --nodeconfig C:\\用户\\ Kristaps.Mezavilks \\硒\\ node_c.json -p 4730 --udid 192.168.204:5555

配置文件示例的 node_c.json 的:

  {
   能力:
      {
         browserName:Android的,
         版本:4.4.2
         MAXINSTANCES:3,
         平台:ANDROID
         设备名称:192.168.1.204:5555
      }
   ]
   组态:{
      cleanUpCycle:2000,
      超时:30000,
      代理:org.openqa.grid.selenium.proxy.DefaultRemoteProxy
      URL:HTTP://本地主机:4730 / WD /枢纽,
      主持人:本地主机,
      端口:4730,
      maxSession:1,
      登记:真实,
      registerCycle:5000,
      装有Hubport:4444
      hubHost:192.168.1.216
   }
}

获取Android的驱动程序:

 静态AndroidDriver得到(){
        DesiredCapabilities能力=新DesiredCapabilities();
        capabilities.setPlatform(Platform.ANDROID)
        capabilities.setBrowserName()
        capabilities.setVersion(mobileVersion)
        capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,设备ID);
        capabilities.setCapability(MobileCapabilityType.APP,APPPATH);
        capabilities.setCapability(MobileCapabilityType.UDID,设备ID)
        高清URL remoteAddress =新的URL(HTTP://本地主机:4444 / WD /枢纽)
        新AndroidDriver(remoteAddress,能力)
    }

你有一个想法是什么问题,或者至少你能指出我在正确的方向来查找问题?
非常感谢。

编辑:
之后@Ageoffan建议固定在第一个问题,但现在出现连接复位的问题:

 信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:电流= 1
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:ID = UiAutomatorTestRunner
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:类= io.appium.android.bootstrap.Bootstrap
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:流=
信息:[调试] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:numtests = 1
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:测试= testRunServer
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_ code:1
信息:[调试] [引导] [调试]插孔打开端口4724
信息:[调试] [引导] [调试] Appium套接字服务器就绪
信息:[调试] [引导] [调试]载入中... JSON
信息:[调试]醒来设备,如果它不是活着
信息:[调试]推命令appium工作队列:唤醒,{}]
信息:[调试] [引导] [调试] JSON加载完成。
信息:[调试] [引导] [调试]注册崩溃观察家。
错误:未处理的错误:错误:读ECONNRESET
    在exports._errnoException(util.js中:746:11)
    在TCP.onread(net.js:559:26)背景:POST / WD /集线器/会话{\"desiredCapabilities\":{\"app\":\"C:\\\\Users\\\\Kristaps.Mezavilks\\\\Workspace\\\\android-app\\\\project\\\\build\\\\outputs\\\\apk\\\\project-debug2.apk\",\"browserName\":\"\",\"udid\":\"192.168.1.219:5555\",\"platformName\":\"Android]


解决方案

我处理这个问题一个多星期,但最后我还是主要集中在以下堆栈跟踪行信息:[调试] [引导] [调试]插孔打开端口4724 键,想通了,所有实例连接到同一个插座端口(所有TCP转发命令等于所有实例)。

因此​​,一段时间后,我设法找到了一种通过引导端口参数来定义自定义端口转发 -bp< post_number> 添加到节点命令。之后,我已经建立自定义端口,我能够同时发射平行试验甚至实时4个设备。

由于@Ageoffan的帮助!

I am working on Windows 7 machine and trying to implement an Appium test to launch on 2 real Android devices parallel. I was able to launch on each of the 2 devices separately and test executed as expected but simultaneous launch using JUnit fails with following stacktrace for one of devices:

info: [debug] Pushing command to appium work queue: ["element:getText",{"elementId":"2"}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:getText","params":{"elementId":"2"}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getText
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"Sign up","status":0}
info: [debug] Responding to client with success: {"status":0,"value":"Sign up","sessionId":"c730d16f-ca7f-42aa-be23-da33bbefd9f0"}
info: <-- GET /wd/hub/session/c730d16f-ca7f-42aa-be23-da33bbefd9f0/element/2/text 200 56.413 ms - 81 {"status":0,"value":"Sign up","sessionId":"c730d16f-ca7f-42aa-be23-da33bbefd9f0"}
info: --> DELETE /wd/hub/session/c730d16f-ca7f-42aa-be23-da33bbefd9f0 {}
info: Shutting down appium session
info: [debug] Pressing the HOME button
info: [debug] executing cmd: C:\Users\Kristaps.Mezavilks\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.1.204:5555 shell "input keyevent 3"
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"shutdown"}
info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"OK, shutting down","status":0}
info: [debug] [BOOTSTRAP] [debug] Closed client connection
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [debug] [UIAUTOMATOR STDOUT] Time: 6.985
info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
info: [debug] UiAutomator shut down normally
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"c730d16f-ca7f-42aa-be23-da33bbefd9f0"}

Before launch I perform following actions:

  • launch the Selenium Grid:
    java -jar selenium-server-standalone-2.46.0.jar -role -hub -throwOnCapabilityNotPresent
  • launch 2 Appium nodes:
    node appium --nodeconfig C:\Users\Kristaps.Mezavilks\selenium\node_p.json -p 4728 --udid 192.168.219:5555
    and
    node appium --nodeconfig C:\Users\Kristaps.Mezavilks\selenium\node_c.json -p 4730 --udid 192.168.204:5555

Example of config file node_c.json:

{
   "capabilities":[
      {
         "browserName":"android",
         "version":"4.4.2",
         "maxInstances":3,
         "platform":"ANDROID",
         "deviceName":"192.168.1.204:5555"
      }
   ],
   "configuration":{
      "cleanUpCycle":2000,
      "timeout":30000,
      "proxy":"org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
      "url":"http://localhost:4730/wd/hub",
      "host":"localhost",
      "port":4730,
      "maxSession":1,
      "register":true,
      "registerCycle":5000,
      "hubPort":4444,
      "hubHost":"192.168.1.216"
   }
}

Getting Android driver:

static AndroidDriver get() {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setPlatform(Platform.ANDROID)
        capabilities.setBrowserName("")
        capabilities.setVersion(mobileVersion)
        capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, deviceID);
        capabilities.setCapability(MobileCapabilityType.APP, appPath);
        capabilities.setCapability(MobileCapabilityType.UDID, deviceID)
        def URL remoteAddress = new URL("http://localhost:4444/wd/hub")
        new AndroidDriver(remoteAddress, capabilities)
    }

Do you have an idea what is the problem or at least could you point me in the right direction to look up the problem? Many thanks.

EDIT: After @Ageoffan suggestion fixed the first problem but now there is connection reset problem:

info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
info: [debug] [BOOTSTRAP] [debug] Loading json...
info: [debug] Waking up device if it's not alive
info: [debug] Pushing command to appium work queue: ["wake",{}]
info: [debug] [BOOTSTRAP] [debug] json loading complete.
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
error: Unhandled error: Error: read ECONNRESET
    at exports._errnoException (util.js:746:11)
    at TCP.onread (net.js:559:26) context: [POST /wd/hub/session {"desiredCapabilities":{"app":"C:\\Users\\Kristaps.Mezavilks\\Workspace\\android-app\\project\\build\\outputs\\apk\\project-debug2.apk","browserName":"","udid":"192.168.1.219:5555","platformName":"Android]

解决方案

I was dealing with this problem over a week but finally I focused on the following stacktrace line info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724 and figured out that all instances connect to the same socket port (all tcp forwarding commands was equal for all instances).

So after a while I managed to find a way to define forwarding on custom ports by using bootstrap port parameter -bp <post_number> added to node command. After I had set custom ports I was able to launch simultaneous parallel tests even on 4 devices in real time.

Thanks to @Ageoffan for the help!

这篇关于Appium试射多台设备上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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