In my setup, I am using app1 where upon clicking a button app2 is launched. App2 then launches an in-app webview. Switching context takes 60 seconds (times out), but does not throw an exception. This results in an obvious element not found exception when i try to click google's search textbox. It seems that ChromeDriver cannot handle webview in another app.
Last login: Thu Oct 13 22:10:53 on ttys002
apsomeUsers-MacBook-Pro:~ someUser$ appium
[Appium] Welcome to Appium v1.5.3 (REV 29a9c85389753fa6b3106dca6a9146674e1e5c58)
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"deviceName":"android","platformName":"Android","appActivity":"com.test.app1.MainActivity","appPackage":"com.test.app1","noReset":"true"}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{"deviceName":"android","p...
[Appium] Creating new AndroidDriver session
[Appium] Capabilities:
[Appium] deviceName: 'android'
[Appium] platformName: 'Android'
[Appium] appActivity: 'com.test.app1.MainActivity'
[Appium] appPackage: 'com.test.app1'
[Appium] noReset: 'true'
[BaseDriver] Capability 'noReset' changed from string to boolean. This may cause unexpected behavior
[BaseDriver] Session created with session id: f11e9520-856e-4bde-b8d5-b0104893ea16
[debug] [AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 1.7.0_67
[ADB] Checking whether adb is present
[ADB] Using adb from /Users/someUser/software/android-sdk/platform-tools/adb
[AndroidDriver] Retrieving device list
[debug] [ADB] Trying to find a connected android device
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[AndroidDriver] Using device: 6666b2ca
[ADB] Checking whether adb is present
[ADB] Using adb from /Users/someUser/software/android-sdk/platform-tools/adb
[debug] [ADB] Setting device id to 6666b2ca
[AndroidDriver] App file was not listed, instead we're going to run com.test.app1 directly on the device
[debug] [AndroidDriver] Checking whether package is present on the device
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /Users/someUser/software/android-sdk/platform-tools/adb with args: ["-P",5037,"-s","6666b2ca","shell","pm","list","packages","com.test.app1"]
[AndroidDriver] Starting Android session
[debug] [ADB] Running /Users/someUser/software/android-sdk/platform-tools/adb with args: ["-P",5037,"-s","6666b2ca","wait-for-device"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /Users/someUser/software/android-sdk/platform-tools/adb with args: ["-P",5037,"-s","6666b2ca","shell","echo","ping"]
[debug] [Logcat] Starting logcat capture
[debug] [AndroidDriver] Pushing settings apk to device...
[debug] [ADB] Running /Users/someUser/software/android-sdk/platform-tools/adb with args: ["-P",5037,"-s","6666b2ca","install","/usr/local/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/io.appium.settings/bin/settings_apk-debug.apk"]
[debug] [AndroidDriver] Pushing unlock helper app to device...
[debug] [ADB] Running /Users/someUser/software/android-sdk/platform-tools/adb with args: ["-P",5037,"-s","6666b2ca","install","/usr/local/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/appium-unlock/bin/unlock_apk-debug.apk"]
[ADB] Getting device platform version
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /Users/someUser/software/android-sdk/platform-tools/adb with args: ["-P",5037,"-s","6666b2ca","shell","getprop","ro.build.version.release"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /Users/someUser/software/android-sdk/platform-tools/adb with args: ["-P",5037,"-s","6666b2ca","shell","dumpsys","window"]
[AndroidDriver] Screen already unlocked, doing nothing
[debug] [AndroidBootstrap] Watching for bootstrap disconnect
[debug] [ADB] Forwarding system: 4724 to device: 4724
[debug] [ADB] Running /Users/someUser/software/android-sdk/platform-tools/adb with args: ["-P",5037,"-s","6666b2ca","forward","tcp:4724","tcp:4724"]
[debug] [UiAutomator] Starting UiAutomator
[debug] [UiAutomator] Moving to state 'starting'
[debug] [UiAutomator] Parsing uiautomator jar
[debug] [UiAutomator] Found jar name: 'AppiumBootstrap.jar'
[debug] [ADB] Running /Users/someUser/software/android-sdk/platform-tools/adb with args: ["-P",5037,"-s","6666b2ca","push","/usr/local/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/appium-android-bootstrap/bootstrap/bin/AppiumBootstrap.jar","/data/local/tmp/"]
[debug] [ADB] Attempting to kill all uiautomator processes
[debug] [ADB] Getting all processes with uiautomator
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /Users/someUser/software/android-sdk/platform-tools/adb with args: ["-P",5037,"-s","6666b2ca","shell","ps","uiautomator"]
[ADB] No uiautomator process found to kill, continuing...
[debug] [UiAutomator] Starting UIAutomator
[debug] [ADB] Creating ADB subprocess with args: -P, 5037, -s, 6666b2ca, shell, uiautomator, runtest, AppiumBootstrap.jar, -c, io.appium.android.bootstrap.Bootstrap, -e, pkg, com.test.app1, -e, disableAndroidWatchers, false, -e, acceptSslCerts, false
[debug] [UiAutomator] Moving to state 'online'
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Registered crash watchers.
[AndroidBootstrap] Android bootstrap socket is now connected
[debug] [ADB] Getting connected devices...
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Client connected
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /Users/someUser/software/android-sdk/platform-tools/adb with args: ["-P",5037,"-s","6666b2ca","shell","getprop","ro.build.version.sdk"]
[debug] [ADB] Device API level: 23
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /Users/someUser/software/android-sdk/platform-tools/adb with args: ["-P",5037,"-s","6666b2ca","shell","am","start","-n","com.test.app1/com.test.app1.MainActivity","-S","-a","android.intent.action.MAIN","-c","android.intent.category.LAUNCHER","-f","0x10200000"]
[Appium] New AndroidDriver session created successfully, session f11e9520-856e-4bde-b8d5-b0104893ea16 added to master session list
[MJSONWP] Responding to client with driver.createSession() result: {"platform":"LINUX","webSto...
[HTTP] <-- POST /wd/hub/session 200 6667 ms - 600
[HTTP] --> POST /wd/hub/session/f11e9520-856e-4bde-b8d5-b0104893ea16/element {"using":"id","value":"com.test.app1:id/button"}
[MJSONWP] Calling AppiumDriver.findElement() with args: ["id","com.test.app1:id/but...
[debug] [BaseDriver] Waiting up to 0 ms for condition
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.test.app1:id/button","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.test.app1:id/button","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'com.test.app1:id/button' using 'ID' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.test.app1:id/button]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":{"ELEMENT":"1"}}
[debug] [AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.findElement() result: {"ELEMENT":"1"}
[HTTP] <-- POST /wd/hub/session/f11e9520-856e-4bde-b8d5-b0104893ea16/element 200 722 ms - 87
[HTTP] --> POST /wd/hub/session/f11e9520-856e-4bde-b8d5-b0104893ea16/element/1/click {"id":"1"}
[MJSONWP] Calling AppiumDriver.click() with args: ["1","f11e9520-856e-4bde-b8...
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:click","params":{"elementId":"1"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"1"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: click
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}
[debug] [AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.click() result: true
[HTTP] <-- POST /wd/hub/session/f11e9520-856e-4bde-b8d5-b0104893ea16/element/1/click 200 241 ms - 76
[HTTP] --> GET /wd/hub/session/f11e9520-856e-4bde-b8d5-b0104893ea16/contexts {}
[MJSONWP] Calling AppiumDriver.getContexts() with args: ["f11e9520-856e-4bde-b8d5-b...
[debug] [AndroidDriver] Getting a list of available webviews
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /Users/someUser/software/android-sdk/platform-tools/adb with args: ["-P",5037,"-s","6666b2ca","shell","cat","/proc/net/unix"]
[debug] [AndroidDriver] WEBVIEW_8446 mapped to pid 8446
[debug] [AndroidDriver] Getting process name for webview
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /Users/someUser/software/android-sdk/platform-tools/adb with args: ["-P",5037,"-s","6666b2ca","shell","ps"]
[debug] [AndroidDriver] Parsed pid: 8446 pkg: com.test.app2!
[debug] [AndroidDriver] from: u0_a183,8446,458,2414196,193540,SyS_epoll_,0000000000,S,com.test.app2
[debug] [AndroidDriver] returning process name: com.test.app2
[debug] [AndroidDriver] Found webviews: ["WEBVIEW_com.test.app2"]
[debug] [AndroidDriver] Available contexts: ["NATIVE_APP","WEBVIEW_com.test.app2"]
[MJSONWP] Responding to client with driver.getContexts() result: ["NATIVE_APP","WEBVIEW_com....
[HTTP] <-- GET /wd/hub/session/f11e9520-856e-4bde-b8d5-b0104893ea16/contexts 200 172 ms - 110
[HTTP] --> POST /wd/hub/session/f11e9520-856e-4bde-b8d5-b0104893ea16/context {"name":"WEBVIEW_com.test.app2"}
[MJSONWP] Calling AppiumDriver.setContext() with args: ["WEBVIEW_com.test.app2","f...
[debug] [AndroidDriver] Getting a list of available webviews
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /Users/someUser/software/android-sdk/platform-tools/adb with args: ["-P",5037,"-s","6666b2ca","shell","cat","/proc/net/unix"]
[debug] [AndroidDriver] WEBVIEW_8446 mapped to pid 8446
[debug] [AndroidDriver] Getting process name for webview
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /Users/someUser/software/android-sdk/platform-tools/adb with args: ["-P",5037,"-s","6666b2ca","shell","ps"]
[debug] [AndroidDriver] Parsed pid: 8446 pkg: com.test.app2!
[debug] [AndroidDriver] from: u0_a183,8446,458,2439776,204188,SyS_epoll_,0000000000,S,com.test.app2
[debug] [AndroidDriver] returning process name: com.test.app2
[debug] [AndroidDriver] Found webviews: ["WEBVIEW_com.test.app2"]
[debug] [AndroidDriver] Available contexts: ["NATIVE_APP","WEBVIEW_com.test.app2"]
[debug] [AndroidDriver] Connecting to chrome-backed webview context 'WEBVIEW_com.test.app2'
[debug] [Chromedriver] Changed state to 'starting'
[Chromedriver] Set chromedriver binary as: /usr/local/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver
[Chromedriver] Killing any old chromedrivers, running: pkill -15 -f "/usr/local/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver.*--port=9515"
[Chromedriver] No old chromedrivers seemed to exist
[Chromedriver] Spawning chromedriver with: /usr/local/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver --url-base=wd/hub --port=9515 --adb-port=5037
[Chromedriver] [STDOUT] Starting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 9515
Only local connections are allowed.
[JSONWP Proxy] Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
[Chromedriver] [STDERR] [warn] kq_init: detected broken kqueue; not using.: Undefined error: 0
[JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"\",\"stat...
[JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"ch...
[JSONWP Proxy] Got response with status 200: {"sessionId":"976f0690a1f8a...
[debug] [Chromedriver] Changed state to 'online'
[MJSONWP] Responding to client with driver.setContext() result: null
[HTTP] <-- POST /wd/hub/session/f11e9520-856e-4bde-b8d5-b0104893ea16/context 200 60868 ms - 76
[HTTP] --> POST /wd/hub/session/f11e9520-856e-4bde-b8d5-b0104893ea16/element {"using":"id","value":"lst-ib"}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[JSONWP Proxy] Proxying [POST /wd/hub/session/f11e9520-856e-4bde-b8d5-b0104893ea16/element] to [POST http://127.0.0.1:9515/wd/hub/session/976f0690a1f8a1fa8f834ab56f740828/element] with body: {"using":"id","value":"lst-...
[JSONWP Proxy] Got response with status 200: {"sessionId":"976f0690a1f8a...
[JSONWP Proxy] Replacing sessionId 976f0690a1f8a1fa8f834ab56f740828 with f11e9520-856e-4bde-b8d5-b0104893ea16
[HTTP] <-- POST /wd/hub/session/f11e9520-856e-4bde-b8d5-b0104893ea16/element 200 6 ms - 220
[HTTP] --> DELETE /wd/hub/session/f11e9520-856e-4bde-b8d5-b0104893ea16 {}
[MJSONWP] Calling AppiumDriver.deleteSession() with args: ["f11e9520-856e-4bde-b8d5-b...
[debug] [AndroidDriver] Shutting down Android driver
[debug] [AndroidDriver] Stopping chromedriver for context WEBVIEW_com.test.app2
[debug] [Chromedriver] Changed state to 'stopping'
[JSONWP Proxy] Proxying [DELETE /] to [DELETE http://127.0.0.1:9515/wd/hub/session/976f0690a1f8a1fa8f834ab56f740828] with no body
[JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"976f0690a...
[debug] [Chromedriver] Changed state to 'stopped'
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /Users/someUser/software/android-sdk/platform-tools/adb with args: ["-P",5037,"-s","6666b2ca","shell","am","force-stop","com.test.app1"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /Users/someUser/software/android-sdk/platform-tools/adb with args: ["-P",5037,"-s","6666b2ca","shell","am","force-stop","io.appium.unlock"]
[debug] [ADB] Pressing the HOME button
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /Users/someUser/software/android-sdk/platform-tools/adb with args: ["-P",5037,"-s","6666b2ca","shell","input","keyevent",3]
[debug] [Logcat] Stopping logcat capture
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"shutdown"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"shutdown"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type SHUTDOWN
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":"OK, shutting down"}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [UiAutomator] Shutting down UiAutomator
[debug] [UiAutomator] Moving to state 'stopping'
[debug] [UiAutomator] UiAutomator shut down normally
[debug] [UiAutomator] Moving to state 'stopped'
[debug] [ADB] Attempting to kill all uiautomator processes
[debug] [ADB] Getting all processes with uiautomator
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /Users/someUser/software/android-sdk/platform-tools/adb with args: ["-P",5037,"-s","6666b2ca","shell","ps","uiautomator"]
[ADB] No uiautomator process found to kill, continuing...
[debug] [UiAutomator] Moving to state 'stopped'
[Appium] Removing session f11e9520-856e-4bde-b8d5-b0104893ea16 from our master session list
[debug] [MJSONWP] Received response: null
[debug] [MJSONWP] But deleting session, so not returning
[MJSONWP] Responding to client with driver.deleteSession() result: null
[HTTP] <-- DELETE /wd/hub/session/f11e9520-856e-4bde-b8d5-b0104893ea16 200 2641 ms - 76