3

我正在尝试使用以下节点配置来配置 Appium Grid。

-Hub 正在从 testng 接收正确的功能,但集线器正在向我仅有的两个节点发送错误的功能。(节点配置如下)

请建议我哪里出错了。

模拟器节点配置

运行节点的命令: node appium.js --port 4723 --nodeconfig G:\Selenium2\Grid\AppiumEmulatorNode.json

{
    "capabilities": [{
        "browserName": "Emulator_5.1.0",
        "version": "5.1.0",
        "maxInstances": 1,
        "platform": "ANDROID"
    }],
    "configuration": {
        "cleanUpCycle": 2000,
        "timeout": 30000,
        "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
        "url": "http://192.168.0.104:4723/wd/hub",
        "host": 192.168.0.104,
        "port": 4723,
        "maxSession": 1,
        "register": true,
        "registerCycle": 5000,
        "hubPort": 4444 ,
        "hubHost": "192.168.0.104"
    }
}

真实设备节点配置

运行节点的命令:node appium.js --port 4724 --nodeconfig G:\Selenium2\Grid\AppiumRealDevice.json

{
    "capabilities": [{
        "browserName": "Sony Xperia SP",
        "version": "5.1.1",
        "maxInstances": 1,
        "platform": "ANDROID"
    }],
    "configuration": {
        "cleanUpCycle": 2000,
        "timeout": 30000,
        "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
        "url": "http://192.168.0.104:4724/wd/hub",
        "host": "192.168.0.104",
        "port": 4724,
        "maxSession": 1,
        "register": true,
        "registerCycle": 5000,
        "hubPort": 4444 ,
        "hubHost": "192.168.0.104"
    }
}

测试文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="TestsSuite" parallel="tests" thread-count="2" verbose="5">

    <test name="Test1">
        <parameter name="UdidOrDeviceName" value="YT910LQ91K"></parameter>
        <parameter name="MobileVersion" value="5.2.0"></parameter>
        <classes>
            <class name="com.apps.AppiumTest.AppiumMessengerTest" />
        </classes>
    </test>
    <test name="Test2">
        <parameter name="UdidOrDeviceName" value="192.168.113.101:5555"></parameter>
        <parameter name="MobileVersion" value="5.1.0"></parameter>
        <classes>
            <class name="com.apps.AppiumTest.AppiumMessengerTest" />
        </classes>
    </test>
</suite>

电网枢纽输出

   19:47:56.092 INFO - Registered a node http://192.168.0.104:4723
19:51:05.917 INFO - Registered a node http://192.168.0.104:4724
19:51:31.419 INFO - Got a request to create a new session: Capabilities [{appActivity=com.android.mms.ui.ConversationList, appPackage=com.android.mms, platformVersion=5.2.0, newCOmmandTimeout=1000, platformName=Android, deviceName=YT910LQ91K}]
19:51:31.433 INFO - Available nodes: [http://192.168.0.104:4723, http://192.168.0.104:4724]
19:51:31.438 INFO - Got a request to create a new session: Capabilities [{appActivity=com.android.mms.ui.ConversationList, appPackage=com.android.mms, platformVersion=5.1.0, newCOmmandTimeout=1000, platformName=Android, deviceName=192.168.113.101:5555}]
19:51:31.438 INFO - Trying to create a new session on node http://192.168.0.104:4723
19:51:31.460 INFO - Trying to create a new session on test slot {maxInstances=3, platformName=ANDROID, deviceName=192.168.113.101:5555, version=5.1.0}
19:51:31.476 INFO - Available nodes: [http://192.168.0.104:4724, http://192.168.0.104:4723]
19:51:31.486 INFO - Trying to create a new session on node http://192.168.0.104:4724
19:51:31.501 INFO - Trying to create a new session on test slot {browserName=Sony Xperia SP, maxInstances=1, version=5.1.1, platform=ANDROID}

模拟器节点输出

此节点从 Selenium Grid 接收错误的数据集。它应该接收仿真器功能,但它已接收真实设备功能

C:\Program Files (x86)\Appium\node_modules\appium\bin>node appium.js --port 4723 --nodeconfig G:\Selenium2\Grid\AppiumEmulatorNode.json
info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
info: Appium REST http interface listener started on 0.0.0.0:4723
info: [debug] Non-default server args: {"nodeconfig":"G:\\Selenium2\\Grid\\AppiumEmulatorNode.json"}
info: Console LogLevel: debug
info: [debug] starting auto register thread for grid. Will try to register every 5000 ms.
info: [debug] Appium successfully registered with the grid on 192.168.0.104:4444
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: <-- GET /wd/hub/status 200 28.871 ms - 105 {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: <-- GET /wd/hub/status 200 11.314 ms - 105 {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: --> POST /wd/hub/session {"desiredCapabilities":{"appActivity":"com.android.mms.ui.ConversationList","appPackage":"com.android.mms","platformVersion":"5.2.0","newCOmmandTimeout":1000,"platformName":"Android","deviceName":"YT910LQ91K"}}
info: Client User-Agent string: Apache-HttpClient/4.5.1 (Java/1.8.0_65)

真实设备节点输出

此节点从 Selenium Grid 接收错误的数据集。它应该接收真实设备功能,但它已接收仿真器功能

C:\Program Files (x86)\Appium\node_modules\appium\bin>node appium.js --port 4724 --nodeconfig G:\Selenium2\Grid\AppiumRealDevice.json
info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
info: Appium REST http interface listener started on 0.0.0.0:4724
info: [debug] Non-default server args: {"port":4724,"nodeconfig":"G:\\Selenium2\\Grid\\AppiumRealDevice.json"}
info: Console LogLevel: debug
info: [debug] starting auto register thread for grid. Will try to register every 5000 ms.
info: [debug] Appium successfully registered with the grid on 192.168.0.104:4444
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: <-- GET /wd/hub/status 200 22.103 ms - 105 {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: <-- GET /wd/hub/status 200 12.602 ms - 105 {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: <-- GET /wd/hub/status 200 11.690 ms - 105 {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: <-- GET /wd/hub/status 200 11.460 ms - 105 {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: <-- GET /wd/hub/status 200 11.927 ms - 105 {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: --> POST /wd/hub/session {"desiredCapabilities":{"appActivity":"com.android.mms.ui.ConversationList","appPackage":"com.android.mms","platformVersion":"5.1.0","newCOmmandTimeout":1000,"platformName":"Android","deviceName":"192.168.113.101:5555"}}
info: Client User-Agent string: Apache-HttpClient/4.5.1 (Java/1.8.0_65)
info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : newCOmmandTimeout
info: [debug] Didn't get app but did get Android package, will attempt to launch it on the device
info: [debug] Creating new appium session 515cbed7-46c0-4fce-a2e0-652976c5a659
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.8.0_71
info: [debug] Checking whether adb is present
info: [debug] Using adb from C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe
warn: No app capability, can't parse package/activity
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Not checking whether app is present since we are assuming it's already on the device
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices...
info: [debug] executing cmd: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe devices
info: [debug] 2 device(s) connected
info: Found device 192.168.113.101:5555
info: [debug] Setting device id to 192.168.113.101:5555
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 wait-for-device
info: [debug] executing cmd: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 shell "echo 'ready'"
info: [debug] Starting logcat capture
info: [debug] Getting device API level
info: [debug] executing cmd: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 22
info: Device API level is: 22
info: [debug] Extracting strings for language: default
info: [debug] Apk doesn't exist locally
info: [debug] Could not get strings, but it looks like we had an old strings file anyway, so ignoring
info: [debug] executing cmd: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 shell "rm -rf /data/local/tmp/strings.json"
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Skipping install since we launched with a package instead of an app path
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device...
info: [debug] executing cmd: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 push "C:\\Program Files (x86)\\Appium\\node_modules\\appium\\build\\android_bootstrap\\AppiumBootstrap.jar" /data/local/tmp/
info: [debug] Pushing settings apk to device...
info: [debug] executing cmd: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 install "C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
info: [debug] Pushing unlock helper app to device...
info: [debug] executing cmd: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 install "C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk"
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}},"sessionId":"515cbed7-46c0-4fce-a2e0-652976c5a659"}
info: <-- GET /wd/hub/status 200 69.204 ms - 156 {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}},"sessionId":"515cbed7-46c0-4fce-a2e0-652976c5a659"}
info: Starting App
info: [debug] Attempting to kill all 'uiautomator' processes
info: [debug] Getting all processes with 'uiautomator'
info: [debug] executing cmd: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 shell "ps 'uiautomator'"
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.android.mms -e disableAndroidWatchers false
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_RESULT: shortMsg=java.lang.IllegalStateException
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_RESULT: longMsg=UiAutomationService android.accessibilityservice.IAccessibilityServiceClient$Stub$Proxy@1034d97calready registered!
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_CODE: 0
info: [debug] UiAutomator exited
info: [debug] executing cmd: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 shell "echo 'ping'"
info: [debug] Attempting to uninstall app
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Cleaning up android objects
error: UiAutomator quit before it successfully launched
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: UiAutomator quit before it successfully launched
info: [debug] Error: UiAutomator quit before it successfully launched
    at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android.js:205:23)
    at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-hybrid.js:249:5)
    at Object.async.eachSeries (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:142:20)
    at [object Object].androidHybrid.stopChromedriverProxies (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-hybrid.js:233:9)
    at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android.js:200:10)
    at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android.js:222:9)
    at [object Object].androidCommon.uninstallApp (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:478:5)
    at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android.js:220:12)
    at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android.js:229:11)
    at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:901:7
    at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:180:9)
    at ChildProcess.exithandler (child_process.js:194:7)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at maybeClose (internal/child_process.js:818:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: UiAutomator quit before it successfully launched)","origValue":"UiAutomator quit before it successfully launched"},"sessionId":null}
4

1 回答 1

2

以下是 Grid 如何决定将测试路由到哪个节点。

它使用称为能力匹配器的东西来帮助它决定应该将测试路由到其节点中的哪个节点。如果您不提供自定义功能匹配器 [您可以查看我的这篇博客以了解如何插入您自己的自定义变体],它会依靠DefaultCapabilityMatcher来完成此匹配工作。

由于您尚未设置默认功能匹配器理解的任何属性 [参见此处了解这些属性],因此它始终将第一个节点与测试匹配。这就是你看到混乱的原因。

它只了解browserNameplatformversionapplicationName,对于 browserName 、 platform ,您不能传入任何任意值,而只能使用预定义的值。请参阅BrowserTypePlatform java 类。

因此,要解决您的问题,您有两种选择。

选项 1:您构建适合您需求的自己的能力匹配器(您可以参考我在上面分享的我的博客文章链接)并使用它。

选项 2:您求助于使用“应用程序名称”功能,其中您为每个节点提供唯一值,然后依靠您的测试在测试级别添加此额外功能。

那应该可以解决您的问题。

于 2016-05-23T03:57:31.547 回答