Is there command line alternative to Chrome Remote Debugging ?

Manually, I can open tabs from chrome://inspect/#devices . As well as I can open Chrome on desktop from CLI - e.g. chrome.exe --incognito --remote-debugging-port=9222.

But is there option to open tabs on Chrome on Android, which is connected to PC from CLI ? I need such option to semi-automate tests. thanks !


Note: You would need root access to run any command mentioned below for Android 4.2.1.

Contrary to traditional desktop OS, apps in Android are called upon using their component, an Activity. While developers can call the activities using the programming, the end-users are left with command-line to do the calling.

Android has an Activity Manager am to manage the activities, and among other things it can do, the most basic thing it does is to call an activity of an app.

Before we proceed, setup ADB on PC if you haven't since we're going to rely on it. Also make sure that the device is getting detected in PC and by ADB.

The Chrome for Android app's activity responsible for managing tabs is com.google.android.apps.chrome.ChromeTabbedActivity. You can find this activity listed in the said app's AndroidManifest.xml (inside the APK). As for how I came to know about it, I simply launched Chrome, opened a tab, and looked upon the most recent activity using the command:

adb shell dumpsys activity recents

Replace recents with activities for Android 4.2.1.

The real question is:

[Is] there [an] option to open tabs [in] Chrome on Android?

(Obsolete) Enter the following command to do that:

adb shell am start -n com.android.chrome/com.google.android.apps.chrome.ChromeTabbedActivity -d "<URL>" --activity-clear-task

(Tested on Sept 21, 2015) It seems that Chrome has changed the name of the activity responsible for tabs. The new command is:

adb shell am start -n com.android.chrome/org.chromium.chrome.browser.ChromeTabbedActivity -d "about:newtab" --activity-clear-task

See step 3. in this answer to know the details of the command, if you're interested.

Replace <URL> with the address you want, e.g., google.com.

  • thanks ! btw, is there a documentation on options for Chrome for Android activities ? Want to explore the possibilities. – themoah Jul 28 '15 at 10:56
  • @Aviv: I don't know. I just wanted to tell you: If you are happy with this answer, please don't forget to click the gray checkmark next to it. This will give Firelord some extra reputation points. – unforgettableidSupportsMonica Aug 26 '15 at 13:33
  • @Firelord Any way to start in incognito mode? I tried: am start -n com.android.chrome/com.google.android.apps.chrome.document.IncognitoDocumentActivity -d http://google.com, but it didn't work.. – Gokul NC Jun 12 '16 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.