无法启动 WebDriverAgent:无法将命令代理到远程服务器。原始错误:错误:连接 ECONNREFUSED 127.0.0.1:8100
Posted
技术标签:
【中文标题】无法启动 WebDriverAgent:无法将命令代理到远程服务器。原始错误:错误:连接 ECONNREFUSED 127.0.0.1:8100【英文标题】:Unable to start WebDriverAgent : Could not proxy command to remote server. Original error: Error: connect ECONNREFUSED 127.0.0.1:8100 【发布时间】:2017-09-21 23:45:45 【问题描述】:我有一个简单的 ios 自动化脚本。但是它会在指定的模拟器上启动 WebDriverAgent,之后会产生以下错误
[调试] [XCUITest] 无法启动 WebDriverAgent 会话:无法将命令代理到远程服务器。原始错误:错误:连接 ECONNREFUSED 127.0.0.1:8100
注意: 它总是使用 8100 的端口,即使我随机生成端口并在功能中设置 wdaLocalPort。
供您参考,请找到以下代码用于在模拟器上启动应用程序。
setup.java
int wdaDevicePort = 8000 + (int)(Math.random() * ((9000 - 8000) + 1));
File app = new File(inputMap.get(CommonConstant.APK_FILE_OR_WEBDRIVER_PATH));
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "");
capabilities.setCapability(MobileCapabilityType.VERSION, inputMap.get(CommonConstant.BUILD_VERSION));
capabilities.setCapability(MobileCapabilityType.PLATFORM, inputMap.get(CommonConstant.PLATFORM_NAME));
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, inputMap.get(CommonConstant.DEVICE_NAME));
capabilities.setCapability(MobileCapabilityType.NO_RESET, true);
capabilities.setCapability(MobileCapabilityType.FULL_RESET, false);
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest");
capabilities.setCapability(MobileCapabilityType.UDID, inputMap.get(CommonConstant.PHYSICAL_DEVICE_ID));
capabilities.setCapability("wdaLocalPort", wdaDevicePort);
capabilities.setCapability("useNewWDA", true);
capabilities.setCapability("app", app.getAbsolutePath());
driverUrl = inputMap.get(CommonConstant.DRIVER_URL);
driverUrl = driverUrl.replace("Port", Integer.toString(appiumPort));
driver = new IOSDriver(new URL(driverUrl), capabilities);
在WebDriverAgentRunner xcode项目文件的FBConfiguration.m中随机生成端口。
+ (NSRange)bindingPortRange
int lower = 7200;
int upper = 8200;
int Port = lower + arc4random() % (upper - lower);
// 'WebDriverAgent --port 8080' can be passed via the arguments to the process
if (self.bindingPortRangeFromArguments.location != NSNotFound)
return self.bindingPortRangeFromArguments;
// Existence of USE_PORT in the environment implies the port range is managed by the launching process.
if (NSProcessInfo.processInfo.environment[@"USE_PORT"])
return NSMakeRange([NSProcessInfo.processInfo.environment[@"USE_PORT"] integerValue] , 1);
return NSMakeRange(Port, DefaultPortRange);
Appium 日志:-
[Appium] Creating new XCUITestDriver (v2.27.1) session
[Appium] Capabilities:
[Appium] app: '/Users/thangaraj/Desktop/test.ipa'
[Appium] noReset: true
[Appium] automationName: 'XCUITest'
[Appium] useNewWDA: true
[Appium] browserName: ''
[Appium] udid: 'B7E75AA9-029B-4372-9910-8DD252004D31'
[Appium] platformName: 'iOS'
[Appium] version: '10.2'
[Appium] deviceName: 'iPhone 7'
[Appium] fullReset: false
[Appium] platform: 'IOS'
[Appium] wdaLocalPort: 8739
[debug] [XCUITest] XCUITestDriver version: 2.27.1
[BaseDriver] The following capabilities were provided, but are not recognized by appium: version, platform.
[BaseDriver] Session created with session id: de33e720-342a-4229-97c7-a98d9ba2fd7c
[debug] [XCUITest] Xcode version set to '8.2.1' (tools v8.3.0.0.1.1490382677)
[debug] [XCUITest] iOS SDK Version set to '10.2'
[debug] [BaseDriver] Event 'xcodeDetailsRetrieved' logged at 1493096693782 (10:34:53 GMT+0530 (IST))
[iOSSim] Constructing iOS simulator for Xcode version 8.2.1 with udid 'B7E75AA9-029B-4372-9910-8DD252004D31'
[XCUITest] Determining device to run tests on: udid: 'B7E75AA9-029B-4372-9910-8DD252004D31', real device: false
[XCUITest] No platformVersion specified. Using device version: '10.2'
[BaseDriver] Using local app '/Users/thangaraj/Desktop/Test.ipa'
[debug] [BaseDriver] Copying local zip to tmp dir
[debug] [BaseDriver] Unzipping /var/folders/q4/4h_fx95j46n76_vv4f1g_km00000gp/T/2017325-19461-1sgjiao.vf4glgcik9/appium-app.zip
[debug] [BaseDriver] Testing zip archive: /var/folders/q4/4h_fx95j46n76_vv4f1g_km00000gp/T/2017325-19461-1sgjiao.vf4glgcik9/appium-app.zip
[BaseDriver] Unzipped local app to '/var/folders/q4/4h_fx95j46n76_vv4f1g_km00000gp/T/2017325-19461-1sgjiao.vf4glgcik9/Payload/Buckitdream_Test.app'
[debug] [BaseDriver] Event 'appConfigured' logged at 1493096696880 (10:34:56 GMT+0530 (IST))
[debug] [XCUITest] Checking whether app '/var/folders/q4/4h_fx95j46n76_vv4f1g_km00000gp/T/2017325-19461-1sgjiao.vf4glgcik9/Payload/Test.app' is actually present on file system
[debug] [XCUITest] App is present
[debug] [iOS] Getting bundle ID from app '/var/folders/q4/4h_fx95j46n76_vv4f1g_km00000gp/T/2017325-19461-1sgjiao.vf4glgcik9/Payload/Test.app': 'xxxxxx..xxxxx.xxxx'
[debug] [BaseDriver] Event 'resetStarted' logged at 1493096696926 (10:34:56 GMT+0530 (IST))
[debug] [XCUITest] Reset: noReset is on. Leaving simulator as is
[debug] [BaseDriver] Event 'resetComplete' logged at 1493096696929 (10:34:56 GMT+0530 (IST))
[debug] [iOSLog] Starting iOS 10.2 simulator log capture
[debug] [iOSLog] System log path: /Users/thangaraj/Library/Logs/CoreSimulator/B7E75AA9-029B-4372-9910-8DD252004D31/system.log
[debug] [BaseDriver] Event 'logCaptureStarted' logged at 1493096696952 (10:34:56 GMT+0530 (IST))
[XCUITest] Setting up simulator
[debug] [iOS] No reason to set locale
[debug] [iOS] No iOS / app preferences to set
[XCUITest] Simulator with udid 'B7E75AA9-029B-4372-9910-8DD252004D31' already booted
[debug] [BaseDriver] Event 'simStarted' logged at 1493096697177 (10:34:57 GMT+0530 (IST))
[debug] [XCUITest] App 'xxxxx.xxxxxx.xxxxx' is already installed. No need to reinstall.
[debug] [BaseDriver] Event 'appInstalled' logged at 1493096697180 (10:34:57 GMT+0530 (IST))
[debug] [BaseDriver] Event 'wdaStartAttempted' logged at 1493096697182 (10:34:57 GMT+0530 (IST))
[XCUITest] Using WDA path: '/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent'
[XCUITest] Using WDA agent: '/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj'
[debug] [XCUITest] Capability 'useNewWDA' set, so uninstalling WDA before proceeding
[debug] [XCUITest] Removing WDA application from device
[debug] [BaseDriver] Event 'wdaUninstalled' logged at 1493096697289 (10:34:57 GMT+0530 (IST))
[XCUITest] Launching WebDriverAgent on the device
[debug] [XCUITest] Carthage found: '/usr/local/bin/carthage'
[debug] [XCUITest] Killing hanging processes
[debug] [XCUITest] Beginning test with command 'xcodebuild build-for-testing test-without-building -project /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=B7E75AA9-029B-4372-9910-8DD252004D31 -configuration Debug IPHONEOS_DEPLOYMENT_TARGET=10.2' in directory '/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent'
[debug] [XCUITest] Output from xcodebuild will not be logged
[debug] [XCUITest] Waiting up to 60000ms for WebDriverAgent to start
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [XCUITest] Log file for xcodebuild test: /Users/thangaraj/Library/Developer/Xcode/DerivedData/WebDriverAgent-brdadhpuduowllgivnnvuygpwhzy/Logs/Test/2542656F-009B-417F-A8EA-84F977F6F28D/Session-WebDriverAgentRunner-2017-04-25_103459-D5oEtt.log
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET
[debug] [XCUITest] Unable to connect to running WebDriverAgent: Could not proxy command to remote server. Original error: Error: connect ECONNREFUSED 127.0.0.1:8100
[XCUITest] Getting status of WebDriverAgent on device timed out. Continuing
[debug] [BaseDriver] Event 'wdaSessionAttempted' logged at 1493096759516 (10:35:59 GMT+0530 (IST))
[debug] [XCUITest] Sending createSession command to WDA
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [XCUITest] Failed to create WDA session. Retrying...
注意:-
我参考了 youtube 上的一个教程,但是他们运行自动化的 appium 日志具有以下行 iproxy 通过 USB 将本地端口连接到设备端口。 但在我的 appium 日志中不包含该活动。
不知道是不是这个问题?如果是问题,请提供解决步骤。提前致谢!!!
【问题讨论】:
【参考方案1】:确保开发者资料在苹果的开发者门户中有应用程序的详细信息 UDID 和捆绑 ID。如果 IPA 没有任何有效的配置文件,它将无法工作。 推荐你通过这个链接-http://appium.io/docs/en/drivers/ios-xcuitest-real-devices/
【讨论】:
【参考方案2】:而不是使用
[Appium] 应用程序:'/Users/thangaraj/Desktop/test.ipa'
在您的 xcode 中找到 .app 文件并替换路径。 那么它应该可以正常工作。
路径应该是这样的: 用户/thangaraj/Desktop/Xcode/DerivedData/mobile-ios-abc/Build/Products/Debug-iphonesimulator/abc.app
【讨论】:
以上是关于无法启动 WebDriverAgent:无法将命令代理到远程服务器。原始错误:错误:连接 ECONNREFUSED 127.0.0.1:8100的主要内容,如果未能解决你的问题,请参考以下文章
运行Appium服务时,启动不了WebDriverAgent的解决方法
WebdriverAgent:链接器命令失败,退出代码为 1(使用 -v 查看调用)