Error: The following desired capabilities are required, but were not provided: platformName, deviceName

When running a test, the app launches, then when I click on ‘Inspector’ I get ‘Failed to connect to the server. Please check that it is running’ error dialog message displayed. What is confusing is the appium server console error log indicates desired capabilities are required, but not present, yet I can see them in the log and below is my code snippet?

Please point me to a solution, or what further details you need?

  1. I’m automating android 5.1

  2. using appium (for windows) v 1.4.16.1

  3. using android emulator (from android studio’s v 2.2.1) AVD manager

  4. I’m using python v 3
    Here is the code snippet used to launch the test:

     from appium import webdriver
    
     desired_caps = {}
     desired_caps['platformName'] = 'Android'
     desired_caps['platformVersion'] = '6.0'
     desired_caps['deviceName'] = 'Android Emulator'
     desired_caps['app'] = 'C:\\test\\TimeWorksMobile.apk'
     driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
    
  5. Here is appium console log message:

right before clicking inspector button, this is displayed (note that platform name and device name are provided):

info: ← GET /wd/hub/session/41c7ebc6-4d02-4ce1-86a6-f4d2ec64ada7 200 0.879 ms - 540 {“status”:0,“value”:{“platform”:“LINUX”,“browserName”:“Android”,“platformVersion”:“5.1.1”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“platformVersion”:“6.0”,“app”:“C:\test\TimeWorksMobile.apk”,“platformName”:“Android”,“deviceName”:“Android Emulator”},“app”:“C:\test\TimeWorksMobile.apk”,“platformName”:“Android”,“deviceName”:“emulator-5554”},“sessionId”:“41c7ebc6-4d02-4ce1-86a6-f4d2ec64ada7”}

  1. this is what the logs show once inspector ‘refresh’ button is clicked:

info: → POST /wd/hub/session {“desiredCapabilities”:{}}
info: Client User-Agent string: undefined
info: Found an existing session to clobber, shutting it down first…
info: Shutting down appium session
info: [debug] Pressing the HOME button
info: [debug] executing cmd: C:\Users\mwebster\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell “input keyevent 3”
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“shutdown”}
info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:“OK, shutting down”}
info: [debug] [BOOTSTRAP] [debug] Closed client connection
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [debug] [UIAUTOMATOR STDOUT] Time: 39.379
info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
info: [debug] Sent shutdown command, waiting for UiAutomator to stop…
info: [debug] UiAutomator shut down normally
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: Old session shut down OK, proceeding to new session
error: The following desired capabilities are required, but were not provided: platformName, deviceName
info: [debug] Got configuration error, not starting session
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: The following desired capabilities are required, but were not provided: platformName, deviceName
info: [debug] Error: The following desired capabilities are required, but were not provided: platformName, deviceName
at [object Object].Capabilities.checkValidity (C:\Program Files (x86)\Appium\node_modules\appium\lib\server\capabilities.js:146:13)
at [object Object].Appium.configure (C:\Program Files (x86)\Appium\node_modules\appium\lib\appium.js:238:35)
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\lib\appium.js:118:10)
at C:\Program Files (x86)\Appium\node_modules\appium\lib\appium.js:136:7
at [object Object].Appium.cleanupSession (C:\Program Files (x86)\Appium\node_modules\appium\lib\appium.js:338:5)
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\lib\appium.js:376:10)
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android.js:458:11)
at [object Object].UiAutomator.exitHandler (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\uiautomator.js:70:10)
at ChildProcess.emit (events.js:110:17)
at Process.ChildProcess._handle.onexit (child_process.js:1075:12)
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: The following desired capabilities are required, but were not provided: platformName, deviceName)”,“origValue”:“The following desired capabilities are required, but were not provided: platformName, deviceName”},“sessionId”:null}
info: ← POST /wd/hub/session 500 405.752 ms - 314