首页 > 解决方案 > 间歇性发生appium未知服务器端错误

问题描述

我似乎间歇性地遇到这个问题。如果我要拔下并重新插入设备并重新执行测试,则没有错误,但这只是临时修复,直到它再次出现。我有 2 个用于 2 个设备的 appium 服务器实例-

server1
Host-0.0.0.0
server port-5050
Bootstrap port- 4734
allow session overrides- ticked

server2
Host-0.0.0.0
server port-4723
Bootstrap port- 4724
allow session overrides- ticked

appium 版本 - 1.15.1

List of devices attached-
52002dd24392b5a1        device
5200472dec01a4a9        device

appium 服务器控制台上的错误-

  W3C] Encountered internal error running command: Error: Cannot start the 'com.XYZ.XYZ' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Error executing adbExec. Original error: 'Command ''C:\\Users\\XYZ\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe' -P 5037 -s 5200472dec01a4a9 shell am start -W -n com.XYZ.XYZ/host.exp.exponent.LauncherActivity -S' timed out after 120000ms'. Try to increase the 120000ms adb execution timeout represented by 'adbExecTimeout' capability
    [W3C]     at ADB.startApp (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\apk-utils.js:153:11)
    [HTTP] <-- POST /wd/hub/session 500 132866 ms - 1782
    [HTTP] 
    [Instrumentation] .
    [Instrumentation] Time: 123.085
    [Instrumentation] 
    [Instrumentation] OK (1 test)
    [Instrumentation] The process has exited with code 0

IDE上的错误-

org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: Cannot start the 'com.XYZ.XYZ' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Error executing adbExec. Original error: 'Command ''C:\\Users\\XYZ\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe' -P 5037 -s 5200472dec01a4a9 shell am start -W -n com.XYZ.XYZ/host.exp.exponent.LauncherActivity -S' timed out after 120000ms'. Try to increase the 120000ms adb execution timeout represented by 'adbExecTimeout' capability
Driver info: driver.version: AndroidDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Cannot start the 'com.XYZ.XYZ' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Error executing adbExec. Original error: 'Command ''C:\\Users\\XYZ\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe' -P 5037 -s 5200472dec01a4a9 shell am start -W -n com.XYZ.XYZ/host.exp.exponent.LauncherActivity -S' timed out after 120000ms'. Try to increase the 120000ms adb execution timeout represented by 'adbExecTimeout' capability

device1-所需的功能

 DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("deviceName", "Tab");
        capabilities.setCapability("platformVersion", "8.0.0");
        capabilities.setCapability("platformName", "ANDROID");
        capabilities.setCapability("udid", "5200472dec01a4a9");
        capabilities.setCapability("noReset", "true");
        capabilities.setCapability("appPackage", "com.xyz.xyz");
        capabilities.setCapability("appActivity", "host.exp.exponent.LauncherActivity");
        capabilities.setCapability("adbExecTimeout", 120000);
        capabilities.setCapability("newCommandTimeout", 3000);
        capabilities.setCapability("noSign", "true");
        URL mobileURL = new URL("http://0.0.0.0:5050/wd/hub");
        mobileParent = new AndroidDriver(mobileURL, capabilities);

设备的移动功能2-

 capabilities.setCapability("deviceName", "Tab");
        capabilities.setCapability("platformVersion", "8.0.0");
        capabilities.setCapability("platformName", "ANDROID");
        capabilities.setCapability("udid", "52002dd24392b5a1");
        capabilities.setCapability("noReset", "true");
        capabilities.setCapability("appPackage", "com.coachhire.kura");
        capabilities.setCapability("appActivity", "host.exp.exponent.LauncherActivity");
        capabilities.setCapability(AndroidMobileCapabilityType.AUTO_GRANT_PERMISSIONS, true);
        capabilities.setCapability("adbExecTimeout", 120000);
        capabilities.setCapability("newCommandTimeout", 3000);
        capabilities.setCapability("noSign", "true");
        URL mobileURL = new URL("http://0.0.0.0:4723/wd/hub");
        mobileDriver = new AndroidDriver(mobileURL, capabilities);

任何帮助都非常感谢!

标签: appiumappium-androidappium-desktop

解决方案


查看您提供的详细信息,应该没有任何错误。它应该可以正常工作。

当 Appium 无法找出为运行提供的功能列表时,通常会产生未知错误。我建议仔细检查 appPackage 和 appActivity 详细信息是否正确。

此外,尝试在一台设备上运行测试并查看任何错误。查看测试运行的一致性。如果没有错误,您可以再添加一台设备,看看情况如何。

在功能中添加以下内容,

"automationName": "UiAutomator2"

如果您在本地机器上运行测试,请http://127.0.0.1:<Port>/wd/hub改用0.0.0.0

如果您正在远程运行测试,请确保在上面将本地 IP127.0.0.0替换为运行 Appium 服务器的机器 IP。

由于您只运行 Android 设备,我希望根据 Android 测试设置安装必备软件。

对于 mac 设备设置,请按照此处的步骤操作 - https://www.swtestacademy.com/how-to-install-appium-on-mac/

试试下面的步骤,

检查您是否可以通过运行以下命令手动安装该应用程序。

 adb -P <port> -s <device id > shell pm install -t -g <apk path>

如果这可行,则表明该设备没有问题。否则,您应该重置设备并重新测试。

检查 Appium 服务器是否正常运行。并访问此链接,您会在 appium 服务器控制台上看到 200 响应。

http://<appium server ip>:4723/wd/hub/sessions

如果您在此处看到错误,则表明 Appium 存在问题。卸载并安装稳定版Appium并重新测试。

您应该知道有时 Node.js 无法与之对话127.0.0.1:4723,因此请0.0.0.0:4723改用,反之亦然。请记住在代码 (DesiredCapabilities) 和 appium 设置中更改此设置。

所需功能需要尝试“udid”参数 -

示例,caps.setCapability("udid", "ce0217124184c72505");//来自“adb devices”命令的DeviceId


推荐阅读