To capture an Android app running in an emulator, create an Appium session with the UiAutomator2 driver, then call Selenium’s screenshot method on that session:
ok = driver.save_screenshot("screenshot.png")
if not ok:
raise IOError("Could not write screenshot.png")
This saves the current WebDriver-controlled Android viewport as a PNG. It does not capture the host computer’s desktop or the emulator window frame. The complete setup, code, failure modes and an API alternative are below.
What Selenium captures
Selenium’s save_screenshot(filename) method writes the current window to a PNG and returns a Boolean success value. You can also obtain the image as bytes with get_screenshot_as_png() or as a Base64 string with get_screenshot_as_base64().
For a native Android app, Selenium needs an Appium session. Appium’s UiAutomator2 driver controls the Android device or emulator and exposes the screenshot command. In native context, the result is the Android viewport. A web-context capture is the browser window viewport instead.
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 glitches#1 Best Overall
- Bluetooth Controller for iPhone & Android: Mocagen mobile gaming controller Compatible with all iPhone models (including 18/17 series) and Android devices. Pairing steps: 1. Turn on Bluetooth on your phone and go to the pairing screen. 2. Press and hold the Home button for 3 sec until LED4 flashes. 3. Find "XBOX Wireless Controller" on your phone and tap to pair. Quick reconnect: After first pairing, simply press the Home button once (with Bluetooth on) to reconnect
- Play Most Controller-Compatible Games: This iPhone game controller supports cloud gaming (e.g., Xb*x Game Pass, GeForce NOW), Xbox Remote Play, emulator games, and native mobile games (e.g., Apple Arcade). Enjoy effortless control and play Fortnite, Call of Duty, Roblox, Genshin Impact, and many more anytime, anywhere. Note: Controller only works with games that support controller input, and does not support PS Remote Play
- 5M-Cycle Lifespan & Zero Drift: MC1 mobile gaming controller features a Hall-effect joystick with a 5M cycle lifespan, 2.5x longer than standard carbon-film sticks. Its innovative electromagnetic induction technology ensures drift-free operation, enabling precise character control in intense games and significantly extending this phone game controller durability
- Ergonomic Grip Design: The handle is ergonomically shaped with a l*ser-engraved texture for anti-slip and enhanced grip, effectively reducing fatigue during long gaming sessions. The scientifically designed joystick and button layout ensures smooth operation. Whether for personal use or as a gift, it delivers a more comfortable and healthier gaming experience
- 7-Color RGB Light Ring & 600mAh Battery: The mobile game controller features a 7-color adjustable light ring on the joystick(ABXY button lights can be turned off, but their colors are not adjustable). The lighting is vibrant yet eye-friendly. The built-in 600mAh battery provides up to 6 hours of battery life in brightness mode — enough for a full day of gaming
Viewport versus desktop capture
| Goal | Use | Result |
|---|---|---|
| Capture the app or device screen during Android automation | Appium UiAutomator2 plus Selenium’s screenshot API | Native Android viewport |
| Capture emulator borders, title bar or the surrounding desktop | A host operating-system screenshot utility | The desktop or emulator application window, outside Selenium’s current-window API |
Prerequisites
Requirements vary with the installed Appium and UiAutomator2 versions. The UiAutomator2 driver documentation lists these foundations:
- Android SDK and SDK Platform Tools.
- An Android SDK path configured in the environment.
- A Java JDK.
- An Android emulator platform image and an AVD (Android Virtual Device).
- Appium Server and the Appium UiAutomator2 driver.
- Python, Selenium and the Appium Python Client.
Install versions that are mutually compatible, then verify the emulator can boot and is visible to Android tooling before debugging Python. The Appium capability appium:avd selects an AVD and can launch it when that named emulator is not already running.
Native app or Chrome?
For a native application, provide its package and launch activity. For Chrome testing, leave the app capability empty and set browserName to Chrome. Chrome must be installed on the emulator and compatible with the ChromeDriver used by Appium.
Step-by-step Python setup
- Prepare the AVD. Create or start the Android Virtual Device you intend to test. Record its exact name.
- Install the automation stack. Install Python, Selenium, the Appium Python Client, Appium Server and the UiAutomator2 driver. Keep the Android SDK, Java and driver versions aligned with their current requirements.
- Start Appium. Run the Appium server separately, normally at
http://127.0.0.1:4723, or use the URL configured in your environment. - Set capabilities. Select Android and UiAutomator2, then identify the AVD and app package/activity (or Chrome).
- Open the session. Connect with
webdriver.Remoteand wait until the target screen is visible. - Write and verify the image. Pass a writable
.pngpath tosave_screenshotand check its return value. - Always quit. Put
driver.quit()in afinallyblock so a failed test does not leave an orphaned session.
Complete native-app example
Replace the placeholder AVD, package and activity with values from your application. This representative script assumes Appium is already running:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
from appium import webdriver
from appium.options.android import UiAutomator2Options
options = UiAutomator2Options()
options.platform_name = "Android"
options.automation_name = "UiAutomator2"
options.avd = "YOUR_AVD_NAME"
options.app_package = "your.app.package"
options.app_activity = "your.app.Activity"
# Appium Server must be running at this URL.
driver = webdriver.Remote(
command_executor="http://127.0.0.1:4723",
options=options,
)
try:
# Perform navigation or interactions before this line if needed.
ok = driver.save_screenshot("screenshot.png")
if not ok:
raise IOError("Screenshot could not be written")
finally:
driver.quit()
The file is created relative to the process’s current working directory. Use an absolute path when a CI job or another process must collect it. Ensure the destination directory exists and that the account running Python has write permission.
Rank #2
- Why Choose the abxylute M4 Snap-On Phone Controller? Designed exclusively for short quick retro gaming, like Game Boy, NES, SNES and etc. Trusted by 6000+ backers on a tech-focused crowdfunding platform. Pocket-sized play, perfect for your rest time. This compact clip-on controller is compatible with iOS and Android, features a Turbo function—crafted for short bursts of play vertically, horizontally or in detached mode, and ideal for packing in your pocket.
- 【Easy Setup – Power On & Play Instantly!】We recommend attaching the magnetic stickers to a phone case for all phones, rather than using a bare phone. ✅ For Apple MagSafe Models: Snap the magnetic ring onto your MagSafe phone case, power on, and start gaming! ✅ For Non‑MagSafe Models: First attach the included magnetic sticker to your phone case, then snap the magnetic ring onto it. Power on and game right away!
- 【Wide Compatibility – Android & iPhone】Compatible for Android devices, iPhones, and card-size phones (Android devices and iPhone 11/SE and earlier models; iPhone 12/13/14/15/16/17 with MagSafe). Works with all mainstream phones for smooth gaming. Fits iPhone Pro/Pro Max models but may feel top-heavy. Not compatible with foldable phones.
- 【Compact Yet No Loss of Fun】Featuring HID, PS and NS modes, it seamlessly connects to gaming devices via Bluetooth.⚫ HID Mode: Local Games for Android⚫ PS Mode: CODM & PS Remote Play for Android & iOS⚫ NS Mode: All kinds of Emulators
- 【Born for Retro Emulators on Mobile】Designed for retro gaming fans, the M4 Controller works smoothly with top emulators such as Delta, RetroArch and PPSSPP on both iOS and Android.It supports classic games for platforms including Game Boy, NES, SNES,3DS, FC, SFC, SS, N64, GBA, GBC, NDS, and more.
Capturing Chrome on the emulator
For a mobile Chrome session, configure Chrome instead of an application package:
from appium import webdriver
from appium.options.android import UiAutomator2Options
options = UiAutomator2Options()
options.platform_name = "Android"
options.automation_name = "UiAutomator2"
options.avd = "YOUR_AVD_NAME"
options.browser_name = "Chrome"
driver = webdriver.Remote(
command_executor="http://127.0.0.1:4723",
options=options,
)
try:
driver.get("https://example.com")
ok = driver.save_screenshot("chrome-emulator.png")
if not ok:
raise IOError("Screenshot could not be written")
finally:
driver.quit()
Do not set both an app package/activity and Chrome browser capabilities for the same session. Confirm Chrome is installed on the emulator and that the Appium-compatible ChromeDriver matches its version.
Other screenshot return formats
PNG bytes
png_bytes = driver.get_screenshot_as_png()
with open("screenshot.png", "wb") as image:
image.write(png_bytes)
Base64
encoded = driver.get_screenshot_as_base64()
Use bytes when another Python component uploads the image directly. Base64 is useful in JSON reports, but it is larger than binary PNG and must be decoded before viewing.
Timing, reliability and repeatable captures
- Take the screenshot only after the screen under test is present; otherwise a successful call can save an intermediate state.
- Use explicit waits for a UI element or a deterministic application state rather than an arbitrary short sleep.
- Give each test a unique filename when running in parallel, such as a test name plus timestamp or worker ID.
- Keep the emulator resolution and density fixed when pixel comparisons matter.
- Archive the Appium server log, Python exception and emulator logcat alongside a missing image.
- Check the Boolean return and the file’s existence; a completed command is not proof that the intended artifact was stored where you expect.
Troubleshooting
Connection refused or session cannot start
Cause: Appium is not running at the URL in command_executor, or a firewall/proxy changes the address.
Fix: Start Appium, verify the host and port, and test the same URL from the machine running Python. Confirm that the UiAutomator2 driver is installed in that Appium installation.
Rank #3
- 1. 【Ultra-Compact Design】Measuring just 3.54 x 1.97 inches, this mini phone is the world's smallest mobile phone, fitting perfectly in your palm for effortless portability. 【❌WiFi ONLY! No SIM Support】
- 2. 【High-Performance Quad-Core Processor】Powered by an efficient quad-core processor and Android 9.0, this phone delivers smooth operation. It's compatible with popular apps like Facebook, YouTube, Instagram, WhatsApp, TikTok, and Twitter via the Google Play Store. Note: Always use the included charging cable to prevent battery or internal damage from high-voltage fast chargers.
- 3. 【Dual-Camera with Facial Recognition】Capture every moment crisply with a 3MP front camera and 5MP rear camera, ideal for landscapes, dynamic scenes, and selfies. Built-in facial recognition ensures enhanced privacy and security, making it easy to protect your data.
- 4. 【Adorable Gift-Ready Option】With its playful, lightweight design and kid-friendly features, this mini phone comes in Black, Blue, and Pink—perfect as a Christmas or New Year gift. It's not only captivating for children's small hands but also serves as a practical backup for travel and business trips.
- 5. 【Expandable Storage】 Use the second slot for a MicroSD card (not included) to expand your storage. Easily store your favorite music, photos, and emergency files, making it a reliable secondary phone for business trips and international roaming.【If you have any questions about the product, please feel free to contact us at any time.】
AVD is not found or never boots
Cause: The avd value does not exactly match a local AVD, the emulator image is missing, or Android SDK paths are not configured.
Fix: List local AVDs, correct the name, boot it manually once, and verify SDK Platform Tools and the Java JDK are available to Appium.
App package or activity errors
Cause: The package/activity identifies a different build, uses a launcher alias, or the app is not installed.
Fix: Install the intended APK, confirm its application ID and launchable activity, and update the capabilities. For Chrome, remove app capabilities and use browserName.
save_screenshot returns false or the file is absent
Cause: The destination is not writable, the parent directory does not exist, or the underlying driver failed.
Rank #4
- Why Choose the abxylute M4 Snap-On Phone Controller? Designed exclusively for short quick retro gaming, like Game Boy, NES, SNES and etc. Trusted by 6000+ backers on a tech-focused crowdfunding platform. Pocket-sized play, perfect for your rest time. This compact clip-on controller is compatible with iOS and Android, features a Turbo function—crafted for short bursts of play vertically, horizontally or in detached mode, and ideal for packing in your pocket.
- 【Easy Setup – Power On & Play Instantly!】We recommend attaching the magnetic stickers to a phone case for all phones, rather than using a bare phone. ✅ For Apple MagSafe Models: Snap the magnetic ring onto your MagSafe phone case, power on, and start gaming! ✅ For Non‑MagSafe Models: First attach the included magnetic sticker to your phone case, then snap the magnetic ring onto it. Power on and game right away!
- 【Wide Compatibility – Android & iPhone】Compatible for Android devices, iPhones, and card-size phones (Android devices and iPhone 11/SE and earlier models; iPhone 12/13/14/15/16/17 with MagSafe). Works with all mainstream phones for smooth gaming. Fits iPhone Pro/Pro Max models but may feel top-heavy. Not compatible with foldable phones.
- 【Compact Yet No Loss of Fun】Featuring HID, PS and NS modes, it seamlessly connects to gaming devices via Bluetooth.⚫ HID Mode: Local Games for Android⚫ PS Mode: CODM & PS Remote Play for Android & iOS⚫ NS Mode: All kinds of Emulators
- 【Born for Retro Emulators on Mobile】Designed for retro gaming fans, the M4 Controller works smoothly with top emulators such as Delta, RetroArch and PPSSPP on both iOS and Android.It supports classic games for platforms including Game Boy, NES, SNES,3DS, FC, SFC, SS, N64, GBA, GBC, NDS, and more.
Fix: Try an absolute path in a writable directory, create the directory first, inspect Appium logs and preserve the exception. Do not ignore the Boolean result.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchImage is blank, black or blocked
Cause: The app may not yet have drawn its content, the session may be on the wrong screen, or Android’s FLAG_SECURE is preventing screenshots for security reasons.
Fix: Wait for a visible target element, verify the current activity and device state, and check whether the application intentionally enables FLAG_SECURE. That security setting cannot be bypassed through the normal screenshot call.
Chrome session fails to launch
Cause: Chrome is absent or its version is incompatible with the ChromeDriver used by Appium.
Fix: Install/enable Chrome on the emulator and align the driver with the installed Chrome version.
Best Value
- Vertical Retro Arcade Controller for Mobile: Transform your phone into a classic vertical handheld gaming device. The GameSir Pocket Taco’s clamp-style design delivers an authentic golden-age arcade feel, perfect for retro titles and vertical shoot ‘em ups.
- Ultra-Portable & Lightweight with Travel Case: Weighing only 62.2 g and including a durable PP storage box, this compact Bluetooth controller slips easily into a pocket or bag. Ideal for on‑the‑go gaming, commuting, or travel.
- Smart Power & Seamless Bluetooth Connectivity: Unfold to auto power on, close to power off. Enjoy low‑latency wireless gaming on Android and other compatible devices without draining your phone’s battery.
- Long-Lasting 600 mAh Battery & Charge-Through Design: Game for hours on a single charge. The hollow‑bottom design aligns perfectly with your phone’s charging port, so you can keep playing while charging your phone.
- Customizable Controls via GameSir App: Remap buttons, enable D‑pad diagonal lock, switch to keyboard mode, and access G‑Touch/V‑Touch support. Responsive membrane ABXY, D‑pad, and tactile triggers ensure precise inputs.
Or skip the browser setup
When the target is a website rather than an app under test, ScreenshotNeo returns a screenshot with one HTTP request. It removes cookie-consent banners, newsletter popups and chat widgets before capture. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients.
cURL
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
See the ScreenshotNeo documentation for options such as full-page lazy-image loading, CSS-selector elements, device presets, retina scale, PDF output, custom JavaScript/CSS, waits, request blocking, headers/cookies, geolocation, caching, signed links, webhooks and bulk capture. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Create a free ScreenshotNeo account.
Choosing the right method
- Use Appium and Selenium when you need to drive a native Android app, reproduce gestures, validate app state or capture the device viewport inside an automated test.
- Use Appium’s Chrome mode when the subject is mobile Chrome and browser compatibility matters.
- Use a desktop capture utility when the requirement includes emulator chrome or the host desktop.
- Use ScreenshotNeo when you need website screenshots without maintaining an Android SDK, AVD, Appium server or ChromeDriver.
Frequently Asked Questions
Does this capture the whole computer screen?
No. Selenium captures the WebDriver-controlled Android or browser viewport. Capturing emulator borders or the desktop requires a host screenshot tool.
Can I capture an app protected with FLAG_SECURE?
Often not. Android applications can enable FLAG_SECURE to prevent screenshots; investigate the app’s security configuration rather than treating a blank image as a Python file error.
Recommended Free Tools
Which capability selects an emulator?
Set the Appium UiAutomator2 capability `appium:avd` (represented by `options.avd` in the Python client) to the exact local AVD name.
What if I only need a website image?
Use ScreenshotNeo’s one-call API instead of maintaining an emulator and Appium stack; its free tier includes 1,000 screenshots per month without a card.
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.

