队
描述:尝试使用Appium Server在iOS实际设备上启动应用程序时出现UnreachableBrowserException和SessionNotCreatedException错误。
我正在使用最新的xCode ver8.0-beta,是否会导致此问题? appium不支持最新的xcode UIAutomation选项也已启用
经历了一些博客和评论,例如,其中没有工作: 1.更新chormedriver 2.更改功能中的浏览器名称 3.包括jar文件
以下是我尝试启动应用的代码:
package mytest;
import java.io.File;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.MobileElement;
public class testone {
public static IOSDriver<MobileElement> driver;
@BeforeClass
public static void setupBeforeClass() throws Exception{
File appDir = new File ("//Users//gangaiahl//Downloads//AppFile-Developer");
File app = new File (appDir,"Cars.app");
DesiredCapabilities capabilities = new DesiredCapabilities();
//capabilities.setCapability("noReset", true);
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("deviceName", "Carsguide's iPhone");
capabilities.setCapability("udid", "788760e7244680fab61b93da145b67df8cb5a");
capabilities.setCapability(CapabilityType.BROWSER_NAME, " ");
capabilities.setCapability("platformVersion", "9.3.2");
capabilities.setCapability(CapabilityType.PLATFORM, "MAC");
capabilities.setCapability("app", app.getAbsolutePath());
//capabilities.setCapability("autoAcceptAlerts", true);
//capabilities.setCapability("autoAcceptAlerts", true);
driver = new IOSDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
}
@Test
public void test()
{
System.out.println("Hello");
}
}
以下是Appium日志:
[HTTP] --> POST /wd/hub/session {"capabilities":{"desiredCapabilities": {"app":"/Users/gangaiahl/Downloads/AppFile- Developer/CarsGuide.app","platformVersion":"9.3.2","browserName":" ","platformName":"iOS","udid":"788760e7244680fab61b93d48da145b67df8cb5a","device Name":"Carsguide's iPhone","platform":"MAC"},"requiredCapabilities":null},"desiredCapabilities": {"app":"/Users/gangaiahl/Downloads/AppFile- Developer/CarsGuide.app","platformVersion":"9.3.2","browserName":" ","platformName":"iOS","udid":"788760e7244680fab61b93d48da145b67df8cb5a","device Name":"Carsguide's iPhone","platform":"MAC"},"requiredCapabilities":null}
[debug] [MJSONWP] Bad parameters: BadParametersError: Parameters were incorrect. We wanted {"required":["desiredCapabilities"],"optional": ["requiredCapabilities","sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessionId","id", "sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessionId", "id","sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessio nId","id","sessionId","id","sessionId","id","sessionId","id","sessionId","id","s essionId","id","sessionId","id","sessionId","id"]} and you sent ["capabilities","desiredCapabilities","requiredCapabilities"]
[HTTP] <-- POST /wd/hub/session 400 1 ms - 609
[HTTP] --> POST /wd/hub/session {"capabilities":{"desiredCapabilities":{"app":"/Users/gangaiahl/Downloads/AppFile-Developer/CarsGuide.app","platformVersion":"9.3.2","browserName":" ","platformName":"iOS","udid":"788760e7244680fab61b93d48da145b67df8cb5a","deviceName":"Carsguide's iPhone","platform":"MAC"},"requiredCapabilities":null}}
[debug] [MJSONWP] Bad parameters: BadParametersError: Parameters were incorrect. We wanted {"required":["desiredCapabilities"],"optional": ["requiredCapabilities","sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessionId","id", "sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessionId","id","s essionId","id","sessionId","id","sessionId","id","sessionId","id"]} and you sent ["capabilities"]
[HTTP] <-- POST /wd/hub/session 400 1 ms - 581
[HTTP] --> POST /wd/hub/session {"desiredCapabilities": {"app":"/Users/gangaiahl/Downloads/AppFile- Developer/CarsGuide.app","platformVersion":"9.3.2","browserName":" ","platformName":"iOS","udid":"788760e7244680fab61b93d48da145b67df8cb5a","deviceName":"Carsguide's iPhone","platform":"MAC"},"requiredCapabilities":null}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{"app":"/Users/gangaiahl/D...
[Appium] Creating new IosDriver session
[Appium] Capabilities:
[Appium] app: '/Users/gangaiahl/Downloads/AppFile-Developer/CarsGuide.app'
[Appium] platformVersion: '9.3.2'
[Appium] browserName: ' '
[Appium] platformName: 'iOS'
[Appium] udid: '788760e7244680fab61b93d48da145b67df8cb5a'
[Appium] deviceName: 'Carsguide\'s iPhone'
[Appium] platform: 'MAC'
[Appium] noReset: true
[Appium] nativeInstrumentsLib: true
[Appium] showIOSLog: true
[BaseDriver] The following capabilities were provided, but are not recognized by appium: platform.
[BaseDriver] Session created with session id: 4e92ff24-ebe6-4567-923b-3e439ce09a06
[debug] [iOS] Not auto-detecting udid.
[BaseDriver] Using local app '/Users/gangaiahl/Downloads/AppFile-Developer/CarsGuide.app'
[debug] [iOS] Removing any remaining instruments sockets
[debug] [iOS] Cleaned up instruments socket /var/folders/05/79kfthm94qjd3bngd2l5pv7r0mx69v/T/instruments_sock
[debug] [iOS] No language specified. Using default strings
[debug] [iOS] Strings file not found. Looking in 'en.lproj' directory
[iOS] Could not file localizable strings file 'Localizable.strings'!
[debug] [ios-app-utils] Getting bundle ID from app
[iOS] Extracted bundleID: au.com.onewaytraffic.carsguide from app: /Users/gangaiahl/Downloads/AppFile-Developer/CarsGuide.app
[debug] [iOS] Creating instruments
[debug] [UIAuto] Preparing bootstrap code
[debug] [UIAuto] Dynamic bootstrap dir: /Users/gangaiahl/Library/Application Support/appium/bootstrap
[debug] [UIAuto] Dynamic env: {"nodePath":"/Applications/Appium.app/Contents/Resources/node/bin/node","commandProxyClientPath":"/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-ios-driver/node_modules/appium-uiauto/build/lib/bin/command-proxy-client.js","instrumentsSock":"/var/folders/05/79kfthm94qjd3bngd2l5pv7r0mx69v/T/instruments_sock","interKeyDelay":null,"justLoopInfinitely":false,"autoAcceptAlerts":false,"autoDismissAlerts":false,"sendKeyStrategy":"grouped"}
[debug] [UIAuto] Dynamic bootstrap code: // This file is automatically generated. Do not manually modify!
...
[debug] [UIAuto] Dynamic bootstrap path: /Users/gangaiahl/Library/Application Support/appium/bootstrap/bootstrap-c05643b7d8d19d44.js
[debug] [UIAuto] Reusing dynamic bootstrap: /Users/gangaiahl/Library/Application Support/appium/bootstrap/bootstrap-c05643b7d8d19d44.js
[debug] [iOS] Reset not set, continuing
[debug] [iOSLog] Attempting iOS device log capture via libimobiledevice idevicesyslog
[debug] [iOSLog] Found idevicesyslog: '/usr/local/bin/idevicesyslog'
[debug] [iOS] Creating iDevice object with udid 788760e7244680fab61b93d48da145b67df8cb5a
[debug] [iOS] App is not installed. Will try to install.
[MJSONWP] Encountered internal error running command: Error: Installing /Users/gangaiahl/Downloads/AppFile-Developer/CarsGuide.app failed
at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-ios-driver/node_modules/node-idevice/main.js:159:6
at ChildProcess.exithandler (child_process.js:193:7)
at emitTwo (events.js:100:13)
at ChildProcess.emit (events.js:185:7)
at maybeClose (internal/child_process.js:850:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
[HTTP] <-- POST /wd/hub/session 500 1349 ms - 213
以下是Eclipse控制台日志:
[TestNG] Running:
/private/var/folders/05/79kfthm94qjd3bngd2l5pv7r0mx69v/T/testng-eclipse- -2055605734/testng-customsuite.xml
Sep 12, 2016 3:00:36 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
Sep 12, 2016 3:00:36 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to straight W3C remote end connection
Sep 12, 2016 3:00:36 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to original OSS JSON Wire Protocol.
[Utils] Attempting to create /Users/gangaiahl/Documents/workspace/mytest/test-output/Default suite/Default test.xml
[Utils] Directory /Users/gangaiahl/Documents/workspace/mytest/test-output/Default suite exists: true
FAILED CONFIGURATION: @BeforeClass setupBeforeClass
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '3.0.0-beta3', revision: 'c7b525d', time: '2016-09-01 14:57:03 -0700'
System info: host: 'NCA1005547', ip: '10.65.212.71', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_66'
Driver info: driver.version: IOSDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:618)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:40)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:36)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:114)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:132)
at io.appium.java_client.ios.IOSDriver.<init>(IOSDriver.java:82)
at mytest.testone.setupBeforeClass(testone.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:216)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:143)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:169)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:746)
at org.testng.TestRunner.run(TestRunner.java:600)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
at org.testng.SuiteRunner.run(SuiteRunner.java:268)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1264)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1189)
at org.testng.TestNG.runSuites(TestNG.java:1104)
at org.testng.TestNG.run(TestNG.java:1076)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:152)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:57)
Caused by: org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{app=/Users/gangaiahl/Downloads/AppFile-Developer/CarsGuide.app, platformVersion=9.3.2, browserName= , platformName=iOS, udid=788760e7244680fab61b93d48da145b67df8cb5a, deviceName=Carsguide's iPhone, platform=MAC}], required capabilities = null
Build info: version: '3.0.0-beta3', revision: 'c7b525d', time: '2016-09-01 14:57:03 -0700'
System info: host: 'NCA1005547', ip: '10.65.212.71', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_66'
Driver info: driver.version: IOSDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:80)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:69)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:597)
... 36 more
SKIPPED: test
===============================================
Default test
Tests run: 1, Failures: 0, Skips: 1
Configuration Failures: 1, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 1, Failures: 0, Skips: 1
Configuration Failures: 1, Skips: 0
===============================================
[TestNG] Time taken by org.testng.reporters.XMLReporter@5419f379: 9 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@36d4b5c: 18 ms
[Utils] Attempting to create /Users/gangaiahl/Documents/workspace/mytest/test-output/junitreports/TEST- mytest.testone.xml
[Utils] Directory /Users/gangaiahl/Documents/workspace/mytest/test-output/junitreports exists: true
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@20e2cbe0: 3 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@7c16905e: 5 ms
[Utils] Attempting to create /Users/gangaiahl/Documents/workspace/mytest/test-output/old/Default suite/toc.html
[Utils] Directory /Users/gangaiahl/Documents/workspace/mytest/test-output/old/Default suite exists: true
[Utils] Attempting to create /Users/gangaiahl/Documents/workspace/mytest/test-output/old/Default suite/Default test.properties
[Utils] Directory /Users/gangaiahl/Documents/workspace/mytest/test-output/old/Default suite exists: true
[Utils] Attempting to create /Users/gangaiahl/Documents/workspace/mytest/test-output/old/Default suite/index.html
[Utils] Directory /Users/gangaiahl/Documents/workspace/mytest/test-output/old/Default suite exists: true
[Utils] Attempting to create /Users/gangaiahl/Documents/workspace/mytest/test-output/old/Default suite/main.html
[Utils] Directory /Users/gangaiahl/Documents/workspace/mytest/test-output/old/Default suite exists: true
[Utils] Attempting to create /Users/gangaiahl/Documents/workspace/mytest/test-output/old/Default suite/groups.html
[Utils] Directory /Users/gangaiahl/Documents/workspace/mytest/test-output/old/Default suite exists: true
[Utils] Attempting to create /Users/gangaiahl/Documents/workspace/mytest/test-output/old/Default suite/classes.html
[Utils] Directory /Users/gangaiahl/Documents/workspace/mytest/test-output/old/Default suite exists: true
[Utils] Attempting to create /Users/gangaiahl/Documents/workspace/mytest/test-output/old/Default suite/reporter-output.html
[Utils] Directory /Users/gangaiahl/Documents/workspace/mytest/test-output/old/Default suite exists: true
[Utils] Attempting to create /Users/gangaiahl/Documents/workspace/mytest/test-output/old/Default suite/methods-not-run.html
[Utils] Directory /Users/gangaiahl/Documents/workspace/mytest/test-output/old/Default suite exists: true
[Utils] Attempting to create /Users/gangaiahl/Documents/workspace/mytest/test-output/old/Default suite/testng.xml.html
[Utils] Directory /Users/gangaiahl/Documents/workspace/mytest/test-output/old/Default suite exists: true
[Utils] Attempting to create /Users/gangaiahl/Documents/workspace/mytest/test-output/old/index.html
[Utils] Directory /Users/gangaiahl/Documents/workspace/mytest/test-output/old exists: true
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@100fc185: 8 ms
[Utils] Attempting to create /Users/gangaiahl/Documents/workspace/mytest/test-output/testng-failed.xml
[Utils] Directory /Users/gangaiahl/Documents/workspace/mytest/test-output exists: true
[Utils] Attempting to create /Users/gangaiahl/Documents/workspace/mytest/test-output/Default suite/testng-failed.xml
[Utils] Directory /Users/gangaiahl/Documents/workspace/mytest/test-output/Default suite exists: true
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 3 ms
更多信息: 甚至尝试从Appium检查器启动应用程序时它不起作用,下面的错误总是会抛出:
HTTP] --> GET /wd/hub/status {}
[MJSONWP] Calling AppiumDriver.getStatus() with args: []
[MJSONWP] Responding to client with driver.getStatus() result: {"build":{"version":"1.5.3"...
[HTTP] <-- GET /wd/hub/status 200 9 ms - 83
[HTTP] --> GET /wd/hub/sessions {}
[MJSONWP] Calling AppiumDriver.getSessions() with args: []
[MJSONWP] Responding to client with driver.getSessions() result: []
[HTTP] <-- GET /wd/hub/sessions 200 2 ms - 40
[HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"platformName":"iOS","platformVersion":"9.3.2","app":"/Users/gangaiahl/Downloads/CarsGuide.app","automationName":"Appium","udid":"788760e7244680fab61b93d48da145b67df8cb5a","deviceName":"CarsGuideDev\rCarsguideiPhone"}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{"platformName":"iOS","pla...
[Appium] Creating new IosDriver session
[Appium] Capabilities:
[Appium] platformName: 'iOS'
[Appium] platformVersion: '9.3.2'
[Appium] app: '/Users/gangaiahl/Downloads/CarsGuide.app'
[Appium] automationName: 'Appium'
[Appium] udid: '788760e7244680fab61b93d48da145b67df8cb5a'
[Appium] deviceName: 'CarsGuideDev\rCarsguideiPhone'
[Appium] noReset: true
[Appium] nativeInstrumentsLib: true
[Appium] showIOSLog: true
[BaseDriver] Session created with session id: 7ad334c3-9a95-44bd-a718-d9e41d79dcd4
[debug] [iOS] Not auto-detecting udid.
[BaseDriver] Using local app '/Users/gangaiahl/Downloads/CarsGuide.app'
[debug] [iOS] Removing any remaining instruments sockets
[debug] [iOS] Cleaned up instruments socket /var/folders/05/79kfthm94qjd3bngd2l5pv7r0mx69v/T/instruments_sock
[debug] [iOS] No language specified. Using default strings
[debug] [iOS] Strings file not found. Looking in 'en.lproj' directory
[iOS] Could not file localizable strings file 'Localizable.strings'!
[debug] [ios-app-utils] Getting bundle ID from app
[iOS] Extracted bundleID: au.com.oewytrfc.cars from app: /Users/gangaiahl/Downloads/CarsGuide.app
[debug] [iOS] Creating instruments
[debug] [UIAuto] Preparing bootstrap code
[debug] [UIAuto] Dynamic bootstrap dir: /Users/gangaiahl/Library/Application Support/appium/bootstrap
[debug] [UIAuto] Dynamic env: {"nodePath":"/Applications/Appium.app/Contents/Resources/node/bin/node","commandProxyClientPath":"/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-ios-driver/node_modules/appium-uiauto/build/lib/bin/command-proxy-client.js","instrumentsSock":"/var/folders/05/79kfthm94qjd3bngd2l5pv7r0mx69v/T/instruments_sock","interKeyDelay":null,"justLoopInfinitely":false,"autoAcceptAlerts":false,"autoDismissAlerts":false,"sendKeyStrategy":"grouped"}
[debug] [UIAuto] Dynamic bootstrap code: // This file is automatically generated. Do not manually modify!
...
[debug] [UIAuto] Dynamic bootstrap path: /Users/gangaiahl/Library/Application Support/appium/bootstrap/bootstrap-c05643b7d8d19d44.js
[debug] [UIAuto] Reusing dynamic bootstrap: /Users/gangaiahl/Library/Application Support/appium/bootstrap/bootstrap-c05643b7d8d19d44.js
[debug] [iOS] Reset not set, continuing
[debug] [iOSLog] Attempting iOS device log capture via libimobiledevice idevicesyslog
[debug] [iOSLog] Found idevicesyslog: '/usr/local/bin/idevicesyslog'
[debug] [iOS] Creating iDevice object with udid 788760e7244680fab61b93d48da145b67df8cb5a
[debug] [iOS] App is not installed. Will try to install.
[MJSONWP] Encountered internal error running command: Error: Installing /Users/gangaiahl/Downloads/CarsGuide.app failed
at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/app ium-ios-driver/node_modules/node-idevice/main.js:159:6
at ChildProcess.exithandler (child_process.js:193:7)
at emitTwo (events.js:100:13)
at ChildProcess.emit (events.js:185:7)
at maybeClose (internal/child_process.js:850:16)
at Socket.<anonymous> (internal/child_process.js:323:11)
at emitOne (events.js:90:13)
at Socket.emit (events.js:182:7)
at Pipe._onclose (net.js:475:12)
[HTTP] <-- POST /wd/hub/session 500 1374 ms - 195