Problems with Appium config on Mac

I had no problems getting Appium setup on my PC for an Android app, but I’ve been struggling to get Appium running on a Mac for an iOS app. I’m using the 1.4.13 install of the Appium GUI, and the Appium Doctor shows that all prerequisites are installed correctly (for both iOS and Android).

When I try to run a simple test in Eclipse with TestNG, I get back:
———

FAILED CONFIGURATION: @BeforeTest setup
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: ‘2.53.0’, revision: ‘35ae25b’, time: ‘2016-03-15 17:00:58’
System info: host: ‘C02R4E98G8WN.local’, ip: ‘10.15.152.113’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.11.4’, java.version: ‘1.8.0_77’
Driver info: driver.version: IOSDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:43)
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:249)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:144)
at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:39)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:69)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:78)
at io.appium.java_client.ios.IOSDriver.(IOSDriver.java:55)
at iOSTest2.setup(iOSTest2.java:28)
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:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
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.TestRunner.beforeRun(TestRunner.java:656)
at org.testng.TestRunner.run(TestRunner.java:624)
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:1225)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1150)
at org.testng.TestNG.runSuites(TestNG.java:1075)
at org.testng.TestNG.run(TestNG.java:1047)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:137)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:58)
Caused by: org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:4723 [/127.0.0.1] failed: Connection refused
Build info: version: ‘2.53.0’, revision: ‘35ae25b’, time: ‘2016-03-15 17:00:58’
System info: host: ‘STLC02R4E98G8WN.local’, ip: ‘10.15.152.113’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.11.4’, java.version: ‘1.8.0_77’
Driver info: driver.version: IOSDriver
————
I’ve tried both 127.0.0.1 and 0.0.0.0 as the server address. I’ve tried different port numbers besides 4723. My code is:

public class iOSTest2 {
IOSDriver driver;

@BeforeTest 
public void setup() throws MalformedURLException { 
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("deviceName", "iPhone 6 Plus");
    capabilities.setCapability("udid", "8b7050735c97a567e87da4da004983b58f19023e");
    capabilities.setCapability("platformName", "iOS");
    capabilities.setCapability("platformVersion", "8.4.1");
    
    capabilities.setCapability("app", "/Users/stu/Documents/SeleniumJars/app-qarc-1.59.1.1.ipa");
    driver = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

———

I’ve tried upgrading Appium to 1.52 but that didn’t make a difference so I backed down to 1.4.13 (since the Appium Doctor and Inspector have issues in that version). I can run an app on my device via Xcode without a problem. I’ve tried my physical device as well as Simulators but something isn’t configured right. If I try to launch the Inspector I get back “Could not launch Appium Inspector. Could not get list of sessions from Appium Server. Be sure the Appium server is running with an application opened…”. I get this error when I have manually launched the app to test and when I haven’t launched it. I’ve tried using the App Path as well as the BundleID but same results.

Any ideas what could be wrong? Thanks

I don’t use the GUI myself, but are you sure you’ve actually launched the Appium server from the GUI? Launching the GUI only launches the graphical portion of Appium. You have to click the “Launch” button to actually start the background server for Appium.

Yes, I definitely launch the Appium server via the Launch button on the GUI. The Appium logs show:

Launching Appium with command: ‘/Applications/Appium.app/Contents/Resources/node/bin/node’ lib/server/main.js --address “127.0.0.1” --debug-log-spacing --platform-version “8.4” --platform-name “iOS” --app “/Users/stu/Documents/SeleniumJars/app-qarc-1.59.1.1.ipa” --udid “8b7050735c97a567e87da4da004983b58f19014e” --device-name “iPhone 6 Plus STL”

info: Welcome to Appium v1.4.13 (REV c75d8adcb66a75818a542fe1891a34260c21f76a)

info: Appium REST http interface listener started on 127.0.0.1:4723

info: [debug] Non-default server args: {“app”:"/Users/stu/Documents/SeleniumJars/app-qarc-1.59.1.1.ipa",“udid”:“8b7050735c97a567e87da4da004983b58f19014e”,“address”:“127.0.0.1”,“deviceName”:“iPhone 6 Plus STL”,“platformName”:“iOS”,“platformVersion”:“8.4”,“debugLogSpacing”:true}

info: Console LogLevel: debug

info: --> GET /wd/hub/status {}

info: [debug] Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.4.13”,“revision”:“c75d8adcb66a75818a542fe1891a34260c21f76a”}}}

info: <-- GET /wd/hub/status 200 8.132 ms - 105 {“status”:0,“value”:{“build”:{“version”:“1.4.13”,“revision”:“c75d8adcb66a75818a542fe1891a34260c21f76a”}}}

info: --> GET /wd/hub/status {}

info: [debug] Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.4.13”,“revision”:“c75d8adcb66a75818a542fe1891a34260c21f76a”}}}

info: <-- GET /wd/hub/status 200 2.982 ms - 105 {“status”:0,“value”:{“build”:{“version”:“1.4.13”,“revision”:“c75d8adcb66a75818a542fe1891a34260c21f76a”}}}

info: --> POST /wd/hub/session {“desiredCapabilities”:{“app”:"/Users/stu/Documents/SeleniumJars/app-qarc-1.59.1.1.ipa",“udid”:“8b7050735c97a567e87da4da004983b58f19014e”,“platformName”:“iOS”,“deviceName”:“iPhone 6 Plus STL”,“platformVersion”:“8.4.1”}}

info: Client User-Agent string: Apache-HttpClient/4.5.1 (Java/1.8.0_77)
info: *************************************
info: **** NEW SESSION ***
info: *************************************
info: [debug] Using local .ipa from desired caps: /Users/stu/Documents/SeleniumJars/app-qarc-1.59.1.1.ipa
info: [debug] Copying local zip to tmp dir

info: [debug] /Users/stu/Documents/SeleniumJars/app-qarc-1.59.1.1.ipa copied to /var/folders/hv/z0cp2_j10xv5369mc3h7j1br3gw1kr/T/11649-1272-mrv8cz/appium-app.zip

info: [debug] Unzipping /var/folders/hv/z0cp2_j10xv5369mc3h7j1br3gw1kr/T/11649-1272-mrv8cz/appium-app.zip

info: [debug] Testing zip archive: /var/folders/hv/z0cp2_j10xv5369mc3h7j1br3gw1kr/T/11649-1272-mrv8cz/appium-app.zip

info: [debug] Zip archive tested clean

info: [debug] Unzip successful

info: [debug] Using locally extracted app: /var/folders/hv/z0cp2_j10xv5369mc3h7j1br3gw1kr/T/11649-1272-mrv8cz/Payload/PaneraQARC.app

info: [debug] Creating new appium session c10c06e3-906e-4718-bc09-9eed2f5a21d5
info: [debug] Removing any remaining instruments sockets
info: [debug] Cleaned up instruments socket /tmp/instruments_sock
info: [debug] Auto-detecting iOS udid…
info: [debug] Not auto-detecting udid, running on sim

info: [debug] Parsed app Info.plist (as binary)
info: [debug] Parsed app Localizable.strings
info: [debug] Getting bundle ID from app
info: [debug] Parsed app Info.plist (as binary)
info: [debug] Creating instruments

info: [debug] Preparing uiauto bootstrap
info: [debug] Dynamic bootstrap dir: /Users/stu/Library/Application Support/appium/bootstrap
info: [debug] Dynamic env: {“nodePath”:"/Applications/Appium.app/Contents/Resources/node/bin/node",“commandProxyClientPath”:"/Applications/Appium.app/Contents/Resources/node_modules/appium/submodules/appium-uiauto/bin/command-proxy-client.js",“instrumentsSock”:"/tmp/instruments_sock",“interKeyDelay”:null,“justLoopInfinitely”:false,“autoAcceptAlerts”:false,“autoDismissAlerts”:false,“sendKeyStrategy”:“grouped”}

info: [debug] Dynamic bootstrap code: // This file is automatically generated. Do not manually modify!..
info: [debug] Dynamic bootstrap path: /Users/stu/Library/Application Support/appium/bootstrap/bootstrap-5923cadea0343e3f.js
info: [debug] Reusing dynamic bootstrap: /Users/stu/Library/Application Support/appium/bootstrap/bootstrap-5923cadea0343e3f.js
info: [debug] Attempting iOS device log capture via libimobiledevice idevicesyslog

info: [debug] Creating iDevice object with udid 8b7050735c97a567e87da4da004983b58f19014e

info: --> GET /wd/hub/status {}

info: [debug] Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.4.13”,“revision”:“c75d8adcb66a75818a542fe1891a34260c21f76a”},“isShuttingDown”:false},“sessionId”:“c10c06e3-906e-4718-bc09-9eed2f5a21d5”}

info: <-- GET /wd/hub/status 200 1.453 ms - 179 {“status”:0,“value”:{“build”:{“version”:“1.4.13”,“revision”:“c75d8adcb66a75818a542fe1891a34260c21f76a”},“isShuttingDown”:false},“sessionId”:“c10c06e3-906e-4718-bc09-9eed2f5a21d5”}

info: --> GET /wd/hub/status {}

info: [debug] Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.4.13”,“revision”:“c75d8adcb66a75818a542fe1891a34260c21f76a”},“isShuttingDown”:false},“sessionId”:“c10c06e3-906e-4718-bc09-9eed2f5a21d5”}
info: <-- GET /wd/hub/status 200 1.095 ms - 179 {“status”:0,“value”:{“build”:{“version”:“1.4.13”,“revision”:“c75d8adcb66a75818a542fe1891a34260c21f76a”},“isShuttingDown”:false},“sessionId”:“c10c06e3-906e-4718-bc09-9eed2f5a21d5”}

(This repeats every minute for about 10 minutes, then it returns:

info: --> POST /wd/hub/session {“desiredCapabilities”:{“app”:"/Users/stu/Documents/SeleniumJars/app-qarc-1.59.1.1.ipa",“udid”:“8b7050735c97a567e87da4da004983b58f19014e”,“platformName”:“iOS”,“deviceName”:“iPhone 6 Plus STL”,“platformVersion”:“8.4.1”}}

info: Client User-Agent string: Apache-HttpClient/4.5.1 (Java/1.8.0_77)
info: *************************************

error: Failed to start an Appium session, err was: Error: Requested a new session but one was in progress
info: [debug] Error: Requested a new session but one was in progress
at [object Object].Appium.start (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/appium.js:139:15)
at exports.createSession (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/server/controller.js:188:16)
at Layer.handle [as handle_request] (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/layer.js:82:5)
at next (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/route.js:110:13)
at Route.dispatch (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/route.js:91:3)
at Layer.handle [as handle_request] (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/layer.js:82:5)
at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/index.js:267:22
at Function.proto.process_params (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/index.js:321:12)
at next (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/index.js:261:10)
at next (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/route.js:100:14)
at next (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/route.js:104:14)
at next
at /Applications/Appium.app/Contents/Resources/node_modules/appium/lib/server/controller.js:39:7
at Layer.handle [as handle_request] (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/layer.js:82:5)
at next (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_module
s/express/lib/router/route.js:110:13)

Have you tried using the real IP address of your machine instead of 127.0.0.1 or 0.0.0.0. I’ve never had success with it unless I use real IP in my experience.

Thanks for the suggestion. I tried the real ip address as well as ‘localhost’ but I still have the same problem. Error shown in the TestNG console (which is similar to the error displayed in the Appium GUI:
FAILED CONFIGURATION: @BeforeTest setup
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Requested a new session but one was in progress) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 602.11 seconds
Driver info: io.appium.java_client.ios.IOSDriver
** at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)**
** at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)**

I noticed that one of my lines of code has a warning:
**IOSDriver is a raw type. References to generic type IOSDriver should be parameterized

This is the line of code:
driver = new IOSDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);

Could this be causing the problem?

I don’t think not using generics can cause this problem. When I used to work with iOS devices, unexplainable errors would always show up. Sometimes restarting the machine fixed things. Have you tried restarting your computer?

I’m not sure what I did to fix it, but after restarting the Appium server a few times, swapping USB cables on my iPhone and restarting my Mac, I’m finally able to connect to the Appium server. Thanks for the help.

Hii all,

I have installed below listed versions (mac machine):-

1.Java - 1.8.0_131
2.xcode - 8.3.3
3.Appium -Version 1.5.3
4.Selenium- 3.4.0
5.Eclipse- 4.7.0

While running the code showing the error “Unable to create new remote session”

Please anyone help me out from this situation.

What capabilities are you using to launch the app on the iOS device? With xcode 8.3.3 you’ll need to be using ios9 or 10, and the xcuitest driver for ios. I think you’ll need to go to appium 1.6.4 or 1.6.5 to get it working properly

@ken let me check this with latest version