基本信息

环境:Android(hybird)+robotframework+appium+w8
版本:appium-1.4.0.0

实现功能

对 Android 内的 WEBVIEW 部分实现输入等操作,如图

问题

进入当前页面后,在 robotframework 里面用关键字 Get Contexts 获取可用的 context 只有 NATIVE_APP,也无法切换到 WEBVIEW 模式下,请教哪位知道原因?万分感激!

LOG

info: <-- GET /wd/hub/session/9fdcfc84-4767-4208-8714-1c7df1ae4eac/screenshot 200 1055.742 ms - 107518 {"status":0,"value":"iVBORw0KGgoAAAANSUhEUgAAAtAAAAUACAYAAABuzmU9AAAABHNCSVQICAgIfAhkiAAAIABJREFUeJzs3Xd8k1UXwPFfnswuStmjyJK9tyzZewgyZIiIMhUQEEThlaEooCxFmTJkDwEVEVEQGQIyZCp779HS3ey8f9TElq6kTVuQ8/3IR5rc5z43JePkPueeqwoJCXEghBBCCCGEcIuS1QMQQgghhBDiSSIBtBBCCCGEEB6QAFoIIYQQQggPSAAthBBCCCGEBySAFkIIIYQQwgMSQAshhBBCCOEBCaCFEEIIIYTwgCarByA8o1KpUKvVKIqCSqUCwOFwYLfbXX+EEEIIIUTGkQD6CaBSqdBoNOj1erRareu2+ByOuP1wrFYrRqMRq9Xqui0zORwOVCoVDocDk8mEw+FI9zgcDgcBAQFERUWh1WrRarWu8wghhBBCZDaV7ET4+FIUBZ1Oh16vR61Wu4LR+EGpSqVK8MfJZrNhMpkwm82ZNivtcDgwm80EBATg7++fYeexWq08ePAg2S8TQgghhBAZSQLox5RWq8XHxweNRoPD4cBisbiCYbvdniCAVhQFtVrtmp2NH1BarVZiY2OxWCwZOl673U5sbCyFChXK0PPE53A4CAkJSfTlQQghhBAiI0kKx2NGpVKh0+nw8/MDUg+AnfnPVqsVk8mERqPB19cXjSbun1aj0RAQEEBMTIwrpcLbHA4HNpsNvV7v9b5TolKpiImJwcfHB7VanannFkIIIcTTSwLox4hKpcJgMGAwGLDb7RiNRo+DXqvVSmRkJHq9HoPBgKLEFVrx8fFBpVJhNBq9HkTb7XY0Gg1BQUFe7dcdBoMBq9WaYFFlRnA44GCYhRmXjBjtEGX1/Hfoq1bRMo+WgYUNqGXCXAghhHhiSQD9GNHpdBgMBlQqFVFRUWlOu3A4HK6FhP7+/jgcDtRqNQaDwXVfRsiKNIro6OhMmfne8cDMlAtGHo2bVYA7D9sBRFodrL9l...","sessionId":"9fdcfc84-4767-4208-8714-1c7df1ae4eac"}
info: --> GET /wd/hub/session/9fdcfc84-4767-4208-8714-1c7df1ae4eac/contexts {}
info: [debug] Getting a list of available webviews
info: [debug] executing cmd: "C:\Program Files\android-sdk-windows\platform-tools\adb.exe" -s 8b2242c1 shell "cat /proc/net/unix"
info: [debug] Available contexts:
info: [debug] []
info: [debug] Available contexts: NATIVE_APP
info: [debug] Responding to client with success: {"status":0,"value":["NATIVE_APP"],"sessionId":"9fdcfc84-4767-4208-8714-1c7df1ae4eac"}
info: <-- GET /wd/hub/session/9fdcfc84-4767-4208-8714-1c7df1ae4eac/contexts 200 115.125 ms - 86 {"status":0,"value":["NATIVE_APP"],"sessionId":"9fdcfc84-4767-4208-8714-1c7df1ae4eac"}
info: --> GET /wd/hub/session/9fdcfc84-4767-4208-8714-1c7df1ae4eac/contexts {}
info: [debug] Getting a list of available webviews
info: [debug] executing cmd: "C:\Program Files\android-sdk-windows\platform-tools\adb.exe" -s 8b2242c1 shell "cat /proc/net/unix"
info: [debug] Available contexts: NATIVE_APP

解决方法

webview 的 debug 开关未开启,找开发加一段代码即可 WebView.setWebContentsDebuggingEnabled(true)
PS:此方法好像只支持 4.4 及以上的系统


↙↙↙阅读原文可查看相关链接,并与作者交流