如果我运行了TestNG测试类,它将显示错误------------ org.openqa.selenium.WebDriverException:处理命令时发生未知的服务器端错误。 原始错误:无法将命令代理到远程服务器。原始错误:错误:套接字挂起(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:281毫秒 构建信息:版本:'2.53.1',修订版本:'a36b8b1cd5757287168e54b817830adce9b0158d',时间:'2016-06-30 19:26:09' 系统信息:主机:'MON-PC305',ip:'10 .101.0.119',操作系统名称:'Windows 10',os.arch:'amd64',os.version:'10 .0',java.version:'1.8 .0_144' 驱动程序信息:io.appium.java_client.android.AndroidDriver 功能[{appPackage = com.app.android.game.app,statBarHeight = 84,noReset = false,viewportRect = {top = 84,left = 0,width = 1440,height = 2308},deviceName = emulator-5554,平台= LINUX,deviceUDID = emulator-5554,所需= {app =“ app path”,appPackage = com.app.android.game.app,appActivity = com.app.android.game.app.activities.login.riskWarningLogin.RiskWarningLoginActivity ,noReset = false,automationName = uiautomator2,skipUnlock = true,platformName = Android,deviceName = emulator-5554},platformVersion = 9,webStorageEnabled = false,automationName = uiautomator2,takesScreenshot = true,skipUnlock = true,javascriptEnabled = true,platformName = Android,deviceApiLevel = 28,deviceManufacturer = Google,app = C:\ Users *** \ eclipse-workspace \ appname \ app.apk,deviceScreenSize = 1440x2560,networkConnectionEnabled = true,警告= {},databaseEnabled = false,appActivity = com .app.android.game.app.activities.login.riskWarningLogin.RiskWarningLoginActivity,pixelRatio = 3.5,locationContextEnabled = false,deviceScreenDensity = 560,devi ceModel =为x86构建的Android SDK}] 会话ID:d275d496-08b0-4652-9aa9-67ae0476cdc8
答案 0 :(得分:0)
不确定是否相同,但是当我通过uiautomator2运行appium自动化时,我在vivo手机上遇到了类似的问题。 appium错误日志就像
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
//Printing factors help
void print(std::vector<int> const& factors)
{
for (int i = 0; i < factors.size(); i++) {
std::cout << factors.at(i) << ' ';
}
}
int main() {
//Restarting it
std::string again;
again = "Yes";
//Actual loop
while (again == "Yes") {
//Variable/vectors
std::string pfacts;
double input = 0;
double result = 0;
double looper = 2;
int looper2 = 2;
int printed = 0;
int printed2 = 0;
std::vector<int> factors;
std::vector<int> holders;
//Asking for number
std::cout << "Please enter your number.\n";
std::cin >> input;
double holder = input;
//Ratting out trolls
if (input == 0) {
std::cout << "Your number is neither.\n";
looper = 1000003;
}
if (input == 1) {
std::cout << "Your number is neither.\n";
looper = 1000003;
}
//Prime/composite loop
while (looper < 1000002 and input != 1 and fmod(result, 1) == 0) {
result = input / looper;
//Finding composite
if (fmod(result, 1) == 0 and printed == 0) {
std::cout << "Your number is composite.\n";
printed = 1;
looper = 1000003;
}
//Finding prime
else if (fmod(result, 1) != 0 and printed2 == 0) {
std::cout << "Your number is prime.\n";
printed2 = 1;
}
}
//Asking about factors
if (printed == 1) {
std::cout << "Would you like to know it's prime factors? (Please type Yes or No exactly)\n";
std::cin >> pfacts;
}
//Actually finding them
if (pfacts == "Yes") {
while (looper2 < 1000002) {
if (holder / looper2 == 0) {
factors.push_back(holder);
looper2 = 1000003;
}
if (looper2 < 1000002 and fmod (fmod(holder, looper2), 1) == 0 and looper2 % 2 != 0 or looper2 / 2 == 1) {
factors.push_back(looper2);
holder = holder / looper2;
}
looper2 = looper2 + 1;
}
//Printing them
print(factors);
std::cout << "\n";
}
//Again?
std::cout << "Do you need to input another number? (Please type, exactly: Yes or No)\n";
std::cin >> again;
}
}
我这个问题的原因是io.appium.uiautomator2.server被系统进程com.vivo.abe杀死,导致我从logcat捕获了以下日志
[debug] [W3C (9ae907c5)] Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to remote server. Original error: Error: socket hang up
[debug] [W3C (9ae907c5)] at JWProxy.command (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:261:13)
[HTTP] <-- POST /wd/hub/session/9ae907c5-5319-4f0b-92dc-fdaa47cfdcc5/element 500 139 ms - 530
com.vivo.abe(名称为Vivo Wisdom引擎)是vivo手机上的系统应用,无法卸载或强制停止。有一种解决方案可以解决此问题,只需将io.appium.uiautomator2.server添加到白名单中,则com.vivo.abe将不再对应用程序执行kill。
方法设置->电池->高背景功耗,然后将io.appium.uiautomator2.server添加到允许列表中。
执行该操作后,io.appium.uiautomator2.server将不再被杀死,并且自动化脚本可以顺利运行。
希望这可以为解决该问题提供参考。
答案 1 :(得分:0)
发生这种情况是因为您在代码中打开了 2 个驱动程序实例。
URL url = new URL(Common.getProperty("URL"));
driver = new AndroidDriver<WebElement>(url, capabilities);
以上内容。确保你只在你的套装中初始化过一次,否则它会遇到你遇到的同样错误。