chromium.connectOverCDP() connects Playwright to an already running Chromium-based browser through a Chrome DevTools Protocol (CDP) endpoint. That does not, by itself, connect Playwright to Chrome on an Android phone. For Android hardware or an Android Virtual Device (AVD), Playwright documents a separate, experimental Android API that uses ADB. Choose the API for the target you actually need to test.
Choose the right Playwright connection
| Approach | What it connects to | Use it for | Important qualification |
|---|---|---|---|
chromium.connectOverCDP() |
An existing Chromium-based browser exposed through a CDP HTTP or WebSocket endpoint. | Attaching to a running desktop Chromium session and inspecting its existing contexts and pages. | Playwright documents this as significantly lower fidelity than its Playwright-protocol connection. See the BrowserType API documentation. |
browserType.connect() |
A browser launched for connection using Playwright’s own protocol. | Workflows that need the Playwright protocol rather than CDP compatibility. | The BrowserType API documentation recommends this connection when CDP’s lower fidelity is a concern. It is not the same as attaching to Chrome on an Android phone. |
| Playwright Android API | Chrome for Android or Android WebView on an Android device or AVD emulator, discovered through ADB. | Automating an Android browser or WebView, including on physical Android hardware. | Support is experimental and has documented prerequisites and limitations. See the Android API documentation. |
| Device emulation | A browser with selected device-like settings, such as user agent, viewport, screen dimensions, and touch behavior. | Simulating mobile browser conditions without connecting to a physical device. | Emulation settings do not exercise actual phone hardware. See the Emulation guide. |
Attach to an existing Chromium browser over CDP
Use CDP when the target is an already running Chromium-based browser that exposes a CDP endpoint. The endpoint can be an HTTP address such as http://localhost:9222 or a CDP WebSocket URL. After connecting, inspect the browser’s contexts and pages to identify the session you need.
Runnable Node.js example
Install Playwright in your Node.js project with npm install playwright. Start the target Chromium browser separately with remote debugging enabled and make its CDP endpoint reachable from the Node.js process. Then run this script, replacing the URL if your browser exposes a different endpoint:
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.connectOverCDP('http://localhost:9222');
const contexts = browser.contexts();
for (const [contextIndex, context] of contexts.entries()) {
const pages = context.pages();
for (const [pageIndex, page] of pages.entries()) {
console.log({
contextIndex,
pageIndex,
url: page.url(),
title: await page.title(),
});
}
}
// Use the selected existing page here, for example:
// await contexts[0].pages()[0].screenshot({ path: 'page.png' });
// Close the Playwright connection when finished. This disconnects the
// client; it is not a request to close the browser you attached to.
await browser.close();
})().catch((error) => {
console.error(error);
process.exitCode = 1;
});
The existing browser may have more than one context or page. Do not assume contexts[0].pages()[0] is the page you intend to test: inspect the URLs, then select the matching page. For a WebSocket endpoint, pass that endpoint URL to connectOverCDP() instead of the localhost HTTP example.
Recommended Free Tools
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Understand the fidelity trade-off
Playwright states: “This connection is significantly lower fidelity than the Playwright protocol connection via browserType.connect().” The warning matters if your workflow depends on Playwright-specific behavior or encounters unsupported functionality. In those cases, use the documented Playwright-protocol connection where it fits your setup; CDP is primarily the attachment route for an existing Chromium browser, not a drop-in equivalent to every Playwright connection mode.
Automate Chrome on an Android device or emulator
For actual Android Chrome or Android WebView automation, use Playwright’s Android API rather than treating a desktop Chrome CDP endpoint as a phone connection. Playwright describes its Android support as experimental.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Check the prerequisites
- An Android device or an Android Virtual Device (AVD) emulator must be available.
- ADB must be installed, authenticated, and able to discover the device.
- The target Chrome for Android version must be Chrome 87 or newer.
- Set the documented Chrome flag required by Playwright’s Android setup before attempting automation; follow the current Android API setup instructions for the exact flag and device preparation.
- Keep the device awake when taking screenshots. Playwright lists an awake device as a screenshot requirement.
Playwright’s Android API does not support raw USB operation. Do not assume that connecting a cable alone is sufficient; set up and authenticate ADB as described in the Android API documentation.
Discover a device, launch Chrome, and take a screenshot
With Playwright installed in a Node.js project and the Android prerequisites satisfied, the documented workflow is to discover an Android device, launch Chrome, navigate a page, and capture it. This example follows that flow; it selects the first discovered device, so check that the intended target is first or adapt the selection when multiple devices are connected.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
const { _android: android } = require('playwright');
(async () => {
const devices = await android.devices();
if (devices.length === 0) {
throw new Error('No Android device found through ADB');
}
const device = devices[0];
const context = await device.launchBrowser();
const page = await context.newPage();
await page.goto('https://example.com');
await page.screenshot({ path: 'android-page.png' });
await device.close();
})().catch((error) => {
console.error(error);
process.exitCode = 1;
});
The Android API also supports targeting Android WebView. Consult the API documentation for the relevant device and browser methods before adapting this Chrome example to a WebView workflow.
Know the Android support limits
- The API is experimental, so its behavior and supported functionality should not be treated as equivalent to stable desktop automation.
- Raw USB operation is not supported by Playwright’s Android API.
- The device must be awake for screenshots.
- Playwright notes that not all tests were run against the device. Validate the behavior your own test suite depends on.
When device emulation is enough
Use device emulation when the question is how a page responds to selected browser settings—such as user agent, viewport or screen dimensions, and touch behavior. Playwright’s Emulation guide covers these configurable browser parameters.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Emulation can be useful for responsive layouts and simulated mobile behavior, but it is not a substitute for checking real hardware when the test depends on the phone, Android operating system, installed browser, or actual device behavior. In particular, changing viewport and touch settings does not turn a desktop Chromium session attached through CDP into Android Chrome.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshoot connection and test failures
- Connection refused or timed out with CDP: Confirm the target Chromium browser is running with remote debugging enabled and that the endpoint and port are reachable from the Playwright process. Use the endpoint the browser actually exposes;
http://localhost:9222is an example, not a universal address. - Connected, but the expected page is missing: Enumerate
browser.contexts()and each context’spages(). The attached browser can expose existing contexts and pages, and the page you need may not be the first one. - CDP connection behaves differently from a Playwright-launched browser: This may reflect the documented lower fidelity of CDP. Try a Playwright-protocol connection with
browserType.connect()if that connection model is available for your setup. - No Android device is discovered: Check that ADB is installed, authenticated, and can see the device or AVD. Revisit the Android API setup instructions if the device has not authorized ADB access.
- Android Chrome launch or automation fails: Verify that Chrome is version 87 or newer and that the documented Chrome flag has been set. The Android API is experimental, so also check its current compatibility and setup guidance.
- Android screenshot is blank or unavailable: Ensure the device is awake during capture; Playwright lists this as a requirement.
- A USB-connected phone still cannot be controlled: Raw USB operation is not supported by Playwright’s Android API. A cable by itself does not resolve that limitation.
- Mobile test passes in emulation but fails on a phone: Emulation changes selected browser parameters; it does not exercise the actual hardware or Android browser environment. Reproduce the test through the Android API on a device or AVD where appropriate.
Or skip the browser setup
If you need a screenshot rather than interactive browser automation, ScreenshotNeo provides a website screenshot API and MCP server for developers. A single GET request can return a PNG, JPEG, WebP, or PDF. It is not a replacement for Playwright tests on an Android device, but it avoids setting up a browser session for straightforward page captures.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteBest Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
For example, the following cURL request saves a WebP screenshot of the target URL. See the ScreenshotNeo documentation for API options and setup.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
- Cookie and consent banners are accepted like a visitor, and 60+ known consent platforms, newsletter popups, and chat widgets can be removed before capture; each step can be turned off.
- Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing. Response headers report the page verdict and whether the shot was billed.
- An MCP server provides
take_screenshot,get_page_info, andcapture_pdftools for AI agents, including Claude, Cursor, and other MCP clients. - The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
FAQ
Does connectOverCDP() connect directly to Chrome on a phone?
No. It attaches to an existing Chromium browser through its CDP endpoint. Playwright’s documented Android device and emulator workflow uses the separate Android API and ADB.
Is an Android Virtual Device considered real-device testing?
An AVD is an Android emulator, not physical hardware. Playwright’s Android API supports an Android device or an AVD target, so distinguish emulator coverage from tests run on a physical phone when reporting results.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesCan I use device emulation and call it a hardware test?
No. Emulation configures selected browser parameters; it does not exercise actual device hardware.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




