Appium测试启动在多个设备上失败

克里斯塔普斯·梅萨维克(KristapsMežavilks)

我正在Windows 7计算机上工作,并尝试实施Appium测试以在2个实际的Android设备上并行启动。我能够分别在2个设备上分别启动并按预期执行测试,但是使用JUnit同时启动失败,其中一个设备的堆栈跟踪如下:

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"}

在启动之前,我执行以下操作:

  • 启动Selenium Grid:
    java -jar selenium-server-standalone-2.46.0.jar -role -hub -throwOnCapabilityNotPresent
  • 启动2个Appium节点:
    node appium --nodeconfig C:\Users\Kristaps.Mezavilks\selenium\node_p.json -p 4728 --udid 192.168.219:5555

    node appium --nodeconfig C:\Users\Kristaps.Mezavilks\selenium\node_c.json -p 4730 --udid 192.168.204:5555

配置文件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"
   }
}

获取Android驱动程序:

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)
    }

您有什么问题的想法吗?或者至少您可以指出正确的方向来查找问题?非常感谢。

编辑: @Ageoffan建议修复了第一个问题后,现在有连接重置问题:

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]
克里斯塔普斯·梅萨维克(KristapsMežavilks)

我花了一周的时间来解决这个问题,但最终我专注于以下stacktrace行info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724,发现所有实例都连接到相同的套接字端口(所有tcp转发命令对于所有实例都是相同的)。

因此,过了一会儿,我设法找到一种方法,通过使用-bp <post_number>添加到node命令的引导端口参数来定义自定义端口上的转发设置自定义端口后,即使在4个设备上,我也能够实时启动并行并行测试。

感谢@Ageoffan的帮助!

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Appium无法在真正的iOS设备上从Eclipse启动

Appium无法在iPhone Simulator上启动,在设备上成功

启动MediaRecorder的某些设备上的错误启动失败-19

Appium REAL IOS设备应用程序测试:xcodebuild失败:“ xcodebuild失败,代码为65”。

“所选的启动设备失败。”

Xcode UI测试失败,因为物理设备上的XCApplicationStateRunningActive

量角器的waitForAngular()在angular-webapp上失败(真实设备上的appium / chrome)

Swift UI测试无法在iOS 12.3之前的设备上启动

无法在真实设备上的iOS 10上运行Appium测试

通过命令提示符启动多个设备的appium服务器的步骤是什么

如何使用Appium / Python在真实设备上启动应用程序?

如何在多个设备上并行运行测试?

无法使用 Windows 10 机器在 iOS 真实设备上运行 appium 测试

是否可以在 Windows 中的真实 ios 设备上运行 appium 测试

我为Real iOS设备设置了Appium,因为xcodebuild失败并显示代码65,所以无法启动WebDriverAgent

设备上的RenderScript测试

如何在Mac OS上设置Appium以在Android和iOS设备上运行来自JAVA类的自动化测试

SafariLauncher应用程序,用于使用Appium在Safari上的iOS真实设备上测试自动化是否必要?

介质测试失败,找不到启动设备,如果在Dell Inspiron 15R特别版(7520)上再次启动笔记本电脑,则可以正常工作

使用Appium启动整个测试套件

访问AWS设备场上的Appium测试的其他测试文件

尝试通过自制软件为 Appium 安装移动设备驱动程序时,Mac 上的 Chown 失败

在PostgreSQL上启动失败

Appium无法在Android设备上找到按钮

Appium如何在物理设备上运行

在多个设备上训练

每个启动前报告中的某些设备上的FragmentActivity失败的入职活动

在 kubuntu 上启动时出现失败消息“无法重置设备”

在单个测试中运行多个 Appium 会话