Error: Unhandled error: TypeError: Cannot read property 'path' of undefined

error: Unhandled error: TypeError: Cannot read property ‘path’ of undefined

This issue get resolved when i delete by code and checkout again from svn.
This issue is very specific to iOS.
Here to start appium i am using AppiumDriverLocalService

Here i am setting path by HashMap env = new HashMap(); env.put(“ANDROID_HOME”, Constants.ANDROID_HOME); /** This to give the ANDROID_HOME path to AppiumDriverLocalService / env.put(“PATH”, “/usr/local/bin:” + System.getenv(“PATH”)); /* This to give the PATH to AppiumDriverLocalService for iOS testing */
After that service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder() .usingDriverExecutable(new File("/Applications/Appium.app/Contents/Resources/node/bin/node")) .withAppiumJS(new File("/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js")) .withIPAddress(Constants.APPIUM_SERVER_HOST) .usingAnyFreePort() .withStartUpTimeOut(60, TimeUnit.SECONDS) .withEnvironment(env) .withLogFile(new File(Constants.basePath + “/Logs/Appium.log”)))
LOGS

2016-05-20 07:46:16:493 - info: Welcome to Appium v1.4.13 (REV c75d8adcb66a75818a542fe1891a34260c21f76a) 2016-05-20 07:46:16:497 - info: Appium REST http interface listener started on 127.0.0.1:31932 2016-05-20 07:46:16:500 - info: [debug] Non-default server args: {“address”:“127.0.0.1”,“port”:31932,“log”:"/Users/nirajkumar/Documents/workspace/ABC.UI_PHASE_2/Logs/Appium.log"} 2016-05-20 07:46:16:501 - info: Console LogLevel: debug 2016-05-20 07:46:16:501 - info: File LogLevel: debug 2016-05-20 07:46:16:555 - info: --> GET /wd/hub/status {} 2016-05-20 07:46:16:557 - info: [debug] Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.4.13”,“revision”:“c75d8adcb66a75818a542fe1891a34260c21f76a”}}} 2016-05-20 07:46:16:572 - info: <-- GET /wd/hub/status 200 17.400 ms - 105 {“status”:0,“value”:{“build”:{“version”:“1.4.13”,“revision”:“c75d8adcb66a75818a542fe1891a34260c21f76a”}}} 2016-05-20 07:46:16:594 - info: --> GET /wd/hub/status {} 2016-05-20 07:46:16:595 - info: [debug] Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.4.13”,“revision”:“c75d8adcb66a75818a542fe1891a34260c21f76a”}}} 2016-05-20 07:46:16:598 - info: <-- GET /wd/hub/status 200 3.724 ms - 105 {“status”:0,“value”:{“build”:{“version”:“1.4.13”,“revision”:“c75d8adcb66a75818a542fe1891a34260c21f76a”}}} 2016-05-20 07:46:17:537 - info: --> POST /wd/hub/session {“desiredCapabilities”:{“app”:"/Users/nirajkumar/Documents/workspace/ABC.UI_PHASE_2/apps/UAPP_D.ipa",“platformVersion”:“9.3.1”,“udid”:“c8d3d65b8fcfc83d82099f26cffdfdghh4f”,“platformName”:“iOS”,“deviceName”:“iPhone 6”,“autoAcceptAlerts”:“true”}} 2016-05-20 07:46:17:538 - info: Client User-Agent string: Apache-HttpClient/4.3.6 (java 1.5) 2016-05-20 07:46:17:539 - warn: Converting cap autoAcceptAlerts from string to boolean. This might cause unexpected behavior. 2016-05-20 07:46:17:542 - info: [debug] Using local .ipa from desired caps: /Users/nirajkumar/Documents/workspace/KMA.UI_PHASE_2/apps/UAPP_D.ipa 2016-05-20 07:46:17:543 - info: [debug] Copying local zip to tmp dir 2016-05-20 07:46:17:551 - error: Unhandled error: TypeError: Cannot read property ‘path’ of undefined at /Applications/Appium.app/Contents/Resources/node_modules/appium/lib/helpers.js:44:46 at tryCatcher (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-support/node_modules/bluebird/js/main/util.js:26:23) at Promise.errorAdapter (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-support/node_modules/bluebird/js/main/nodeify.js:36:34) at bound (domain.js:254:14) at Promise.runBound (domain.js:267:12) at Promise._settlePromiseAt (/Applications/Aappium.app/Contents/Resources/node_modules/appium/node_modules/appium-support/node_modules/bluebird/js/main/promise.js:575:21) at Promise._settlePromiseAtPostResolution (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-support/node_modules/bluebird/js/main/promise.js:244:10) at Async._drainQueue (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-support/node_modules/bluebird/js/main/async.js:128:12) at Async._drainQueues (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-support/node_modules/bluebird/js/main/async.js:133:10) at Immediate.Async.drainQueues [as _onImmediate] (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-support/node_modules/bluebird/js/main/async.js:15:14) at processImmediate [as _immediateCallback] (timers.js:367:17) context: [POST /wd/hub/session {“desiredCapabilities”:{“app”:"/Users/nirajkumar/Documents/workspace/KMA.UI_PHASE_2/apps/UAPP_D.ipa",“platformVersion”:“9.3.1”,“udid”:“c8d3d65b8fcfc83d82099f26cffdfdghh4f”,“platformName”:“iOS”,"d]

This issue get resolved when i delete by code and checkout again from svn.

Looks like you are quoting the boolean value. Boolean values don’t need to be quoted. Try this:

"autoAcceptAlerts":true

Tried. But still facing same issue.

Can you show the log where you tried? Also how you are setting that capability.

desiredCapabilities = new DesiredCapabilities();
Log.info(“Desired Capabilties object is created”);
desiredCapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, Constants.deviceName);
desiredCapabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, Constants.devicePlatformVersion);
desiredCapabilities.setCapability(MobileCapabilityType.UDID, Constants.udid);
desiredCapabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());

            switch (Constants.devicePlatform.toLowerCase()){
            case "android" :
                desiredCapabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);  
                desiredCapabilities.setCapability(AndroidMobileCapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, Constants.UNEXPECTED_ALERT_BEHAVIOUR);
                desiredCapabilities.setCapability(AndroidMobileCapabilityType.PAGE_LOADING_STRATEGY, Constants.PAGE_LOAD_STRATEGY);
                Log.info("Desired capabilties for Android is set");
                break;

            case "ios" :
                desiredCapabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.IOS);
                desiredCapabilities.setCapability(IOSMobileCapabilityType.AUTO_ACCEPT_ALERTS, true);

This comment has me thinking. Are you using any kind of IDE that might change the property to a String? It sounds like you wrote everything correctly and when you run it the first couple of times everything is fine, then something changes and you get the error. Deleting the code and checking out again solves the issue.

So the next time this happens, before you delete the code could you do an svn diff against master (or whatever the parent branch is)? Then you can see what’s changed and maybe get an idea of where this change is coming from.