有问题可提前回帖
参考资料
- https://chromedevtools.github.io/devtools-protocol/
- chrome devtools需要自带梯子
- https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/web/chromedriver.md
- https://www.w3schools.com/cssref/css_selectors.asp
adb foward
networking:
connect HOST[:PORT] connect to a device via TCP/IP [default port=5555]
disconnect [HOST[:PORT]]
disconnect from given TCP/IP device [default port=5555], or all
forward --list list all forward socket connections
forward [--no-rebind] LOCAL REMOTE
forward socket connection using:
tcp:<port> (<local> may be "tcp:0" to pick any open port)
localabstract:<unix domain socket name>
localreserved:<unix domain socket name>
localfilesystem:<unix domain socket name>
dev:<character device name>
jdwp:<process pid> (remote only)
forward --remove LOCAL remove specific forward socket connection
forward --remove-all remove all forward socket connections
webview的探测
- 模拟器默认可以找到webview的domian socket (网易mumu模拟器默认不可以)
- 真机上需要研发在app内打开webview的调试属性
如果可以被调试,可以通过命令找到
adb shell cat /proc/net/unix | grep webview
chrome remote debug
adb forward tcp:9222 localabstract:webview_devtools_remote_29977
使用chrome的devtools远程调试协议
http://127.0.0.1:9222/json/version
{
"Android-Package": "com.xueqiu.android",
"Browser": "Chrome/44.0.2403.119",
"Protocol-Version": "1.1",
"User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Android SDK built for x86 Build/MASTER; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/44.0.2403.119 Mobile Safari/537.36",
"WebKit-Version": "537.36 (@200258)"
}
http://127.0.0.1:9222/json/list
[ {
"description": "{\\"attached\\":true,\\"empty\\":false,\\"height\\":1971,\\"screenX\\":0,\\"screenY\\":253,\\"visible\\":true,\\"width\\":1440}",
"devtoolsFrontendUrl": "http://chrome-devtools-frontend.appspot.com/serve_rev/@200258/inspector.html?ws=127.0.0.1:9222/devtools/page/9131963C-1696-49A0-8904-0598D61599F6",
"faviconUrl": "https://cdn.snowballsecurities.com/static/images/favicon.9b631977.png",
"id": "9131963C-1696-49A0-8904-0598D61599F6",
"title": "雪盈证券",
"type": "page",
"url": "https://i.snowballsecurities.com/trade?r=30003001",
"webSocketDebuggerUrl": "ws://127.0.0.1:9222/devtools/page/9131963C-1696-49A0-8904-0598D61599F6"
} ]
使用chrome 62版本调试android webview
分析网络性能
分析元素用于定位
python操作webview
def test_webview_simulator_css(self):
print(self.driver.contexts)
print(self.driver.current_context)
self.driver.switch_to.context(self.driver.contexts[1])
print(self.driver.current_context)
chromedriver问题
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: No Chromedriver found that can automate Chrome '44.0.2403'. See https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/web/chromedriver.md for more details.