Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resetApp() fails with Didn't know how to handle switching to context 'NATIVE_APP' #451

uterator opened this issue May 15, 2019 · 1 comment


None yet
2 participants
Copy link

commented May 15, 2019

Trying to uninstall/install the app by calling espressoDriver.resetApp(), but it fails and throws Error: Didn't know how to handle switching to context 'NATIVE_APP'

fullReset = true, noReset = false.

The log:

14:30:06:230 - [HTTP] 
14:30:06:232 - [HTTP] --> POST /wd/hub/session/3cabf603-05ce-420f-bca3-cdbd891c0d46/appium/app/reset
14:30:06:232 - [HTTP] {}
14:30:06:232 - [debug] [W3C (3cabf603)] Calling AppiumDriver.reset() with args: ["3cabf603-05ce-420f-bca3-cdbd891c0d46"]
14:30:06:233 - [debug] [ADB] Getting install status for apk
14:30:06:233 - [debug] [ADB] Running 'sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell dumpsys package apk'
14:30:06:305 - [debug] [ADB] 'apk' is installed
14:30:06:306 - [debug] [ADB] Running 'sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell am force-stop apk'
14:30:06:460 - [debug] [Espresso] [Instrumentation] [STDOUT] io.appium.espressoserver.EspressoServerRunnerTest:INSTRUMENTATION_RESULT: shortMsg=Process crashed.
14:30:06:460 - [debug] [Espresso] [Instrumentation] [STDOUT] INSTRUMENTATION_CODE: 0
14:30:06:544 - [debug] [AndroidDriver] Running full reset on 'apk' (reinstall)
14:30:06:544 - [debug] [ADB] Uninstalling apk
14:30:06:544 - [debug] [ADB] Getting install status for apk
14:30:06:544 - [debug] [ADB] Running 'sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell dumpsys package apk'
14:30:06:687 - [Espresso] Instrumentation process exited with code 0 from signal null
14:30:06:695 - [debug] [ADB] 'apk' is installed
14:30:06:695 - [debug] [ADB] Running 'sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell am force-stop apk'
14:30:06:810 - [debug] [ADB] Running 'sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 uninstall apk'
14:30:07:148 - [debug] [ADB] 'adb uninstall apk' command output: Success
14:30:07:148 - [ADB] apk was successfully uninstalled
14:30:07:197 - [debug] [ADB] Running 'sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell 'ls -t -1 /data/local/tmp/appium_cache 2>&1 || echo _ERROR_''
14:30:07:380 - [debug] [ADB] The count of applications in the cache: 3
14:30:07:380 - [ADB] The application at 'build.apk' is already cached to '/data/local/tmp/appium_cache/0f0a095c635519b9b9a3e51105a1434e08a829be.apk'
14:30:07:381 - [debug] [ADB] Running 'sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell pm install -r /data/local/tmp/appium_cache/0f0a095c635519b9b9a3e51105a1434e08a829be.apk'
14:30:16:646 - [HTTP] --> POST /wd/hub/session/3cabf603-05ce-420f-bca3-cdbd891c0d46/element
14:30:16:651 - [HTTP] {"using":"class name","value":"android.widget.FrameLayout"}
14:30:16:652 - [W3C (3cabf603)] Driver proxy active, passing request on via HTTP proxy
14:30:17:004 - [ADB] The installation of 'apk' took 9.624s
14:30:17:005 - [debug] [ADB] Install command stdout: Success
14:30:17:005 - [debug] [AndroidDriver] Getting a list of available webviews
14:30:17:005 - [debug] [ADB] Running 'sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell cat /proc/net/unix'
14:30:17:186 - [debug] [AndroidDriver] Found webviews: []
14:30:17:186 - [debug] [AndroidDriver] Available contexts: ["NATIVE_APP"]
14:30:17:188 - [debug] [WD Proxy] Matched '/wd/hub/session/3cabf603-05ce-420f-bca3-cdbd891c0d46/element' to command name 'findElement'
14:30:17:188 - [debug] [WD Proxy] Proxying [POST /wd/hub/session/3cabf603-05ce-420f-bca3-cdbd891c0d46/element] to [POST http://localhost:8314/session/0e7a7811-1c72-451d-916f-d4ff7dc33786/element] with body: {"using":"class name","value":"android.widget.FrameLayout"}
14:30:17:189 - [debug] [W3C (3cabf603)] Encountered internal error running command: Error: Didn't know how to handle switching to context 'NATIVE_APP'
14:30:17:189 - [debug] [W3C (3cabf603)]     at EspressoDriver.switchContext (Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\commands\context.js:80:11)
14:30:17:189 - [debug] [W3C (3cabf603)]     at EspressoDriver.switchContext [as setContext] (Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\commands\context.js:58:14)
14:30:17:189 - [debug] [W3C (3cabf603)]     at <anonymous>
14:30:17:190 - [HTTP] <-- POST /wd/hub/session/3cabf603-05ce-420f-bca3-cdbd891c0d46/appium/app/reset 500 10958 ms - 769
14:30:17:190 - [HTTP] 

For reproduce, start an Espresso session and call resetApp().
Appium version is "1.13.0-beta.3"


This comment has been minimized.

Copy link

commented May 16, 2019

The fix has been published in appium@beta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.