Cannot start driver on iOS simulator

  • Platform: iOS
  • Appium version: 1.9.0
  • Emulator: XCode iPhone Simulator
  • Client langauage: Java
  • OS: OSX

I could not start driver, without error message. Is there anything wrong? I used testNG to set the capabilities by xml. The similar code works well for Android testing on Windows. The Xcode iPhone simulator is launched before running the program. By debugging, I found the setup fails when creating the driver.

.xml: (path to the .app is correct)

Java class:
public class AppiumTestCase {
protected AppiumDriver driver;

@Parameters({“port”, “platformName”, “platformVersion”, “deviceName”, “automationName”, “app”, “noReset”})
@BeforeTest
public void setUp(String appiumPort, String platformName, String platformVersion, String deviceName,
String automationName, String app, String noReset) {
System.out.println("[-----------Parameters-----------] port=" + appiumPort);
capabilities.setCapability(“platformName”, platformName);
capabilities.setCapability(“platformVersion”, platformVersion);
capabilities.setCapability(“deviceName”, deviceName);
capabilities.setCapability(“automationName”, automationName);
capabilities.setCapability(“app”, app);
capabilities.setCapability(“noReset”, noReset);
capabilities.setCapability(“showXcodeLog”, true);
capabilities.setCapability(“unicodeKeyboard”, true);
capabilities.setCapability(“resetKeyboard”, true);

System.out.println(capabilities.toString());
try {
System.out.println(driver);
driver = new IOSDriver(new URL(“http://0.0.0.0:”+ appiumPort + “/wd/hub”), capabilities);
System.out.println("driver done "+driver);
wait = new WebDriverWait(driver,15);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (Exception exception) {
exception.printStackTrace();
}
}

Output:

I am in onStart method Login
[-----------Parameters-----------] port=4723
Capabilities [{app=/Users/~/simulator-debug.app, noReset=true, showXcodeLog=true, platformVersion=11.4, automationName=XCUITest, unicodeKeyboard=true, platformName=iOS, deviceName=iPhone 5s, resetKeyboard=true}]
null
I am in onTestStart method login_Email start
I am in onTestSkipped method login_Email skipped
I am in onTestStart method login_MobileNumber start
I am in onTestSkipped method login_MobileNumber skipped
I am in onTestStart method login_WrongPassword start
I am in onTestSkipped method login_WrongPassword skipped
I am in onTestStart method login_WrongUsername start
I am in onTestSkipped method login_WrongUsername skipped
I am in onFinish method Login

iPhone5s
Total tests run: 4, Failures: 0, Skips: 4
Configuration Failures: 1, Skips: 2

ConfigurationFailures: [[TestResult name=setUp status=FAILURE method=AppiumTestCase.setUp(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)[pri:0, instance:tests.LoginTest@12e61fe6] output={null}]]
FailedTests: []

According to your screenshot, this doesn’t have a value:

name="app" value=""

You need to set that as a path to the simulator build of your app.

Thanks for your reply.
The path has been set, I just covered the value by white color.
The value was like this: “/Users/yuki.chen/eclipse-workspace/commonFramework/src/main/resources/DEMO-simulator-debug.app”, the value was got by copying the path to clipboard.

By the way, I am not using Appium desktop but start Appium by in-program command instead.

String cmd = appium + " --session-override " + " -p " + port + " -bp " + bootstrapPort + " --chromedriver-port " + chromeDriverPort + " -g " + logPath;
System.out.println(cmd);
process = Runtime.getRuntime().exec(cmd);

After executing this, I can got input stream matching “Appium REST http interface listener started on”. Besides of the capabilities set in the XML, is there any additional configuration required to let Appium find the simulator?

You may want to debug this using the Appium Desktop and use it’s server just to make sure your capabilities are correct, then move backwards to setting up the appium server after that.

Couple questions regarding the failure to create the driver:

  1. Is the java client finding the appium server / connecting to it?
  2. Is the problem that the appium server doesn’t see the simulator?

I tried Appium Desktop and it can launch the app on the simulator, so I edited the capabilities/commands, removed bootstrap port and added webDriverAgent port. However, the program still doesn’t work.
As for the questions, I am not sure is the java client working well, but I used “-g” to save the server log, which is like this:

2018-10-02 02:39:59:259 - info: [Appium] Welcome to Appium v1.9.0
2018-10-02 02:39:59:263 - info: [Appium] Non-default server args:
2018-10-02 02:39:59:263 - info: [Appium] sessionOverride: true
2018-10-02 02:39:59:264 - info: [Appium] log: /Users/yuki.chen/eclipse-workspace/commonFramework/appium.log
2018-10-02 02:39:59:317 - info: [Appium] Appium REST http interface listener started on 0.0.0.0:4723

And it seems that the server doesn’t see the simulator.
I also used breakpoints to debug the line creating the driver, after running the line, nothing shown in the variables list. Even try catch cannot get anything.

To check whether it is due to the java client, I deleted the java client jar file and use maven to import the java-client 6.1.0, then I got this error:

org.openqa.selenium.WebDriverException: It is impossible to create a new session because ‘createSession’ which takes HttpClient, InputStream and long was not found or it is not accessible
Build info: version: ‘3.4.0’, revision: ‘unknown’, time: ‘unknown’
System info: host: ‘local’, ip: ‘fe80:0:0:0:4a9:11d6:ec64:aeea%en0’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.13.6’, java.version: ‘10.0.2’
Driver info: driver.version: IOSDriver
at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:195)
at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:209)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:231)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
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:250)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:137)
at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:38)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:84)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:94)
at io.appium.java_client.ios.IOSDriver.(IOSDriver.java:95)
at tests.AppiumTestCase.setUp(AppiumTestCase.java:85)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:217)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:144)
at org.testng.TestRunner.beforeRun(TestRunner.java:634)
at org.testng.TestRunner.run(TestRunner.java:602)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:387)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1218)
at org.testng.TestNG.runSuites(TestNG.java:1133)
at org.testng.TestNG.run(TestNG.java:1104)
at utilities.RunSuite.main(RunSuite.java:24)

Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:185)
… 35 more

Caused by: java.lang.AbstractMethodError: org.openqa.selenium.remote.internal.OkHttpClient.execute(Lorg/openqa/selenium/remote/http/HttpRequest;Z)Lorg/openqa/selenium/remote/http/HttpResponse;
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:343)
… 40 more

[UPDATE] I used java-client 6.0.0-BETA4 instead, then the test worked.
It seems that there is an issue on httpClient 6.1.0: https://github.com/appium/java-client/issues/987
Although somebody suggested to use JitPack(https://jitpack.io/#appium/java-client/a873737fce) to get the latest version, I prefer importing a released version instead of handling the tag number.

Anyway, thanks @wreed @bennid