I need to use chrome-har-capturer with an Android phone via ADB.
With Chrome on the local machine, one can start Chrome with the following switch:
--remote-debugging-port=<port>
and then use chrome-hat-capturer as below to connect to the specified port for remote debugging:
chrome-hat-capturer --port <port> -o out.har
The issue with Android is that while I can start Chrome on Android using ADB, It doesn't accept the remote debugging switch:
db shell am start -n com.android.chrome/com.google.android.apps.chrome.Main --remote-debugging-port=9222
Error: Unknown option: --remote-debugging-port=9222
Any idea how to do this?
For anyone else trying to do this, I found how to do this:
On you local machine:
1) Run chrome:
adb shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
2) Forward the debugging port:
adb forward tcp:9222 localabstract:chrome_devtools_remote
3) Run chrome-har-capturer:
chrome-har-capturer --force --port 9222 -o my.har http://www.example.com
Note that you must use the --force option.