Skip to content

Instantly share code, notes, and snippets.

@yuriteixeira
Created August 28, 2018 08:41
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuriteixeira/f2d9e330d7c77021189909770a31eac4 to your computer and use it in GitHub Desktop.
Save yuriteixeira/f2d9e330d7c77021189909770a31eac4 to your computer and use it in GitHub Desktop.
Puppeteer/Chrome Dev Tools Protocol: How to manipulate Android Chrome or WebViews

First of all, get prepared by installing the Android SDK and SDK tools in order to get the adb executable. Then:

  1. adb connect <device ip>

  2. To get the service name `adb shell "cat /proc/net/unix | grep devtools_remote", which will give you something like this output:

00000000: 00000002 00000000 00010000 0001 01 423897 @webview_devtools_remote_18279
  1. Now we need to make a port forwarding between the open socket on the android device and your local machine: adb forward tcp:9222 localabstract:webview_devtools_remote_18279 (assuming that webview_devtools_remote_18279 was returned by the command on step 2.

  2. To make sure it worked, just open http://localhost:9222 in your browser, and you should see something like this

screenshot 2018-08-28 10 32 19

  1. Now you can curl the JSON endpoint to get the so much desired webSocketDebuggerUrl: curl localhost:9222/json or curl localhost:9222/json/version (varies depending on the Chrome/Chromium version)
@ZhymabekRoman
Copy link

You a lifesaver! Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment