I am using Appium to automate my testing cases, and I need to switch to WebView context in some cases. But the switching process did not work on some sdk versions and emulators. The running environment is CentOS release 6.8. Chromedriver version is 2.30.477691. The main stderr is Address Family Not Supported by Protocol. The detail is as follows:
> 2017-08-15 13:31:03:051 - info: [MJSONWP] Responding to client with driver.getContexts() result: [“NATIVE_APP”,"WEBVIEW_com…
2017-08-15 13:31:03:052 - info: [HTTP] <-- GET /wd/hub/session/39812841-2e57-4c33-896f-56e3002a197f/contexts 200 52 ms - 119 2017-08-15 13:31:03:054 - info: [HTTP] --> POST /wd/hub/session/39812841-2e57-4c33-896f-56e3002a197f/context {"name":"WEBVIEW_com.hexin.plat.android"} 2017-08-15 13:31:03:054 - info: [MJSONWP] Calling AppiumDriver.setContext() with args: ["WEBVIEW_com.hexin.plat.an... 2017-08-15 13:31:03:055 - info: [debug] [AndroidDriver] Getting a list of available webviews 2017-08-15 13:31:03:055 - info: [debug] [ADB] Getting connected devices... 2017-08-15 13:31:03:061 - info: [debug] [ADB] 1 device(s) connected 2017-08-15 13:31:03:061 - info: [debug] [ADB] Running /home/autotest/Android/Sdk/platform-tools/adb with args: ["-P",5037,"-s","emulator-5554","shell","cat","/proc/net/unix"] 2017-08-15 13:31:03:075 - info: [debug] [AndroidDriver] WEBVIEW_2435 mapped to pid 2435 2017-08-15 13:31:03:076 - info: [debug] [AndroidDriver] Getting process name for webview 2017-08-15 13:31:03:076 - info: [debug] [ADB] Getting connected devices... 2017-08-15 13:31:03:081 - info: [debug] [ADB] 1 device(s) connected 2017-08-15 13:31:03:082 - info: [debug] [ADB] Running /home/autotest/Android/Sdk/platform-tools/adb with args: ["-P",5037,"-s","emulator-5554","shell","ps"] 2017-08-15 13:31:03:106 - info: [debug] [AndroidDriver] Parsed pid: 2435 pkg: com.hexin.plat.android! 2017-08-15 13:31:03:106 - info: [debug] [AndroidDriver] from: u0_a57,2435,1230,1283480,126412,ep_poll,00f73ba045,S,com.hexin.plat.android 2017-08-15 13:31:03:107 - info: [debug] [AndroidDriver] returning process name: com.hexin.plat.android 2017-08-15 13:31:03:107 - info: [debug] [AndroidDriver] Found webviews: ["WEBVIEW_com.hexin.plat.android"] 2017-08-15 13:31:03:107 - info: [debug] [AndroidDriver] Available contexts: ["NATIVE_APP","WEBVIEW_com.hexin.plat.android"] 2017-08-15 13:31:03:107 - info: [debug] [AndroidDriver] Connecting to chrome-backed webview context 'WEBVIEW_com.hexin.plat.android' 2017-08-15 13:31:03:109 - info: [debug] [Chromedriver] Changed state to 'starting' 2017-08-15 13:31:03:114 - info: [Chromedriver] Set chromedriver binary as: /home/autotest/node-v5.8.0-linux-x64/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/linux/chromedriver_64 2017-08-15 13:31:03:115 - info: [Chromedriver] Killing any old chromedrivers, running: pkill -15 -f "/home/autotest/node-v5.8.0-linux-x64/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/linux/chromedriver_64.*--port=9515" 2017-08-15 13:31:03:129 - info: [Chromedriver] No old chromedrivers seemed to exist 2017-08-15 13:31:03:129 - info: [Chromedriver] Spawning chromedriver with: /home/autotest/node-v5.8.0-linux-x64/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/linux/chromedriver_64 --url-base=wd/hub --port=9515 --adb-port=5037 2017-08-15 13:31:03:177 - info: [Chromedriver] [STDOUT] Starting ChromeDriver 2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57) on port 9515 Only local connections are allowed. 2017-08-15 13:31:03:179 - info: [JSONWP Proxy] Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body 2017-08-15 13:31:03:191 - info: [JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"\",\"stat... 2017-08-15 13:31:03:192 - info: [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"ch... 2017-08-15 13:31:03:446 - info: [Chromedriver] [STDERR] [0.269][SEVERE]: CreatePlatformSocket() returned an error, errno=97: Address Family Not Supported by Protocol 2017-08-15 13:31:03:449 - info: [JSONWP Proxy] Got response with status 200: {"sessionId":"ba7df09e67125... 2017-08-15 13:31:03:450 - info: [debug] [Chromedriver] Changed state to 'online' 2017-08-15 13:31:03:450 - info: [MJSONWP] Responding to client with driver.setContext() result: null 2017-08-15 13:31:03:451 - info: [HTTP] <-- POST /wd/hub/session/39812841-2e57-4c33-896f-56e3002a197f/context 200 397 ms - 76 2017-08-15 13:31:03:453 - info: [HTTP] --> POST /wd/hub/session/39812841-2e57-4c33-896f-56e3002a197f/element {"using":"css selector","value":".head-login-btn"} 2017-08-15 13:31:03:454 - info: [MJSONWP] Driver proxy active, passing request on via HTTP proxy 2017-08-15 13:31:03:454 - info: [JSONWP Proxy] Proxying [POST /wd/hub/session/39812841-2e57-4c33-896f-56e3002a197f/element] to [POST http://127.0.0.1:9515/wd/hub/session/ba7df09e67125b6e95271576495a920e/element] with body: {"using":"css selector","va... 2017-08-15 13:31:03:456 - info: [JSONWP Proxy] Got response with status 200: {"sessionId":"ba7df09e67125... 2017-08-15 13:31:03:457 - info: [JSONWP Proxy] Replacing sessionId ba7df09e67125b6e95271576495a920e with 39812841-2e57-4c33-896f-56e3002a197f 2017-08-15 13:31:03:458 - info: [HTTP] <-- POST /wd/hub/session/39812841-2e57-4c33-896f-56e3002a197f/element 200 4 ms - 236 2017-08-15 13:31:03:963 - info: [HTTP] --> POST /wd/hub/session/39812841-2e57-4c33-896f-56e3002a197f/element {"using":"css selector","value":".head-login-btn"} 2017-08-15 13:31:03:963 - info: [MJSONWP] Driver proxy active, passing request on via HTTP proxy 2017-08-15 13:31:03:964 - info: [JSONWP Proxy] Proxying [POST /wd/hub/session/39812841-2e57-4c33-896f-56e3002a197f/element] to [POST http://127.0.0.1:9515/wd/hub/session/ba7df09e67125b6e95271576495a920e/element] with body: {"using":"css selector","va... 2017-08-15 13:31:03:965 - info: [JSONWP Proxy] Got response with status 200: {"sessionId":"ba7df09e67125... 2017-08-15 13:31:03:966 - info: [JSONWP Proxy] Replacing sessionId ba7df09e67125b6e95271576495a920e with 39812841-2e57-4c33-896f-56e3002a197f 2017-08-15 13:31:03:966 - info: [HTTP] <-- POST /wd/hub/session/39812841-2e57-4c33-896f-56e3002a197f/element 200 3 ms - 236 2017-08-15 13:31:04:470 - info: [HTTP] --> POST /wd/hub/session/39812841-2e57-4c33-896f-56e3002a197f/element {"using":"css selector","value":".head-login-btn"} 2017-08-15 13:31:04:470 - info: [MJSONWP] Driver proxy active, passing request on via HTTP proxy 2017-08-15 13:31:04:470 - info: [JSONWP Proxy] Proxying [POST /wd/hub/session/39812841-2e57-4c33-896f-56e3002a197f/element] to [POST http://127.0.0.1:9515/wd/hub/session/ba7df09e67125b6e95271576495a920e/element] with body: {"using":"css selector","va... 2017-08-15 13:31:04:472 - info: [JSONWP Proxy] Got response with status 200: {"sessionId":"ba7df09e67125... 2017-08-15 13:31:04:472 - info: [JSONWP Proxy] Replacing sessionId ba7df09e67125b6e95271576495a920e with 39812841-2e57-4c33-896f-56e3002a197f 2017-08-15 13:31:04:472 - info: [HTTP] <-- POST /wd/hub/session/39812841-2e57-4c33-896f-56e3002a197f/element 200 3 ms - 236 2017-08-15 13:31:04:976 - info: [HTTP] --> POST /wd/hub/session/39812841-2e57-4c33-896f-56e3002a197f/element {"using":"css selector","value":".head-login-btn"} 2017-08-15 13:31:04:976 - info: [MJSONWP] Driver proxy active, passing request on via HTTP proxy 2017-08-15 13:31:04:977 - info: [JSONWP Proxy] Proxying [POST /wd/hub/session/39812841-2e57-4c33-896f-56e3002a197f/element] to [POST http://127.0.0.1:9515/wd/hub/session/ba7df09e67125b6e95271576495a920e/element] with body: {"using":"css selector","va... 2017-08-15 13:31:04:978 - info: [JSONWP Proxy] Got response with status 200: {"sessionId":"ba7df09e67125... 2017-08-15 13:31:04:979 - info: [JSONWP Proxy] Replacing sessionId ba7df09e67125b6e95271576495a920e with 39812841-2e57-4c33-896f-56e3002a197f 2017-08-15 13:31:04:979 - info: [HTTP] <-- POST /wd/hub/session/39812841-2e57-4c33-896f-56e3002a197f/element 200 3 ms - 236 2017-08-15 13:31:05:483 - info: [HTTP] --> POST /wd/hub/session/39812841-2e57-4c33-896f-56e3002a197f/element {"using":"css selector","value":".head-login-btn"} 2017-08-15 13:31:05:483 - info: [MJSONWP] Driver proxy active, passing request on via HTTP proxy