DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk5 min

How to Take Mobile Viewport Screenshots with Selenium and Chrome

Set up ChromeDriver mobile emulation before starting Selenium, then save a screenshot of the current viewport. Learn how to choose device metrics, distinguish viewport from full-page captures, and handle common errors.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To capture a mobile-sized viewport in Selenium, enable ChromeDriver’s mobile emulation before starting Chrome, navigate to the page, wait for the state you want to document, and save a WebDriver screenshot. You can use a DevTools device preset or set the viewport dimensions and pixel ratio yourself. The steps below capture the visible viewport—not the entire page.

Configure Chrome mobile emulation before creating the driver

ChromeDriver accepts mobile emulation through Chrome options. Set it before constructing the WebDriver session: emulation is a browser-session capability, not a setting to apply after a page has loaded. See the ChromeDriver mobile emulation documentation.

As an Amazon Associate I earn from qualifying purchases.

Use explicit viewport metrics

Explicit metrics make the intended CSS viewport and device pixel ratio clear. This runnable Python example uses a 390-by-844 viewport and a pixel ratio of 3.0; those are illustrative settings, not a claim that they match a particular phone.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
from selenium import webdriver

mobile_emulation = {
    "deviceMetrics": {
        "width": 390,
        "height": 844,
        "pixelRatio": 3.0,
    },
    "mobile": True,
    "touch": True,
}

options = webdriver.ChromeOptions()
options.add_experimental_option("mobileEmulation", mobile_emulation)
driver = webdriver.Chrome(options=options)
try:
    driver.get("https://example.com")
    # Wait for the page state you intend to document.
    driver.save_screenshot("mobile-viewport.png")
finally:
    driver.quit()

Replace the example URL and choose dimensions appropriate to the layout you need to inspect. ChromeDriver documents width, height, and pixelRatio under deviceMetrics. Its documentation says mobile and touch default to true in the documented settings, but setting them explicitly makes the requested behavior visible in your configuration.

#1 Best Overall
Sale
Samsung Galaxy A17 5G Smart Phone 128GB US 1 Yr Manufacturer Warranty Black | Large AMOLED, High-Res Camera, Durable Design, Super Fast Charging, Expandable Storage, Circle to Search, 2025
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.

Use a named device preset

If you want a preset listed in the DevTools emulated-device data, configure its exact device name instead of custom metrics:

from selenium import webdriver

mobile_emulation = {"deviceName": "Nexus 5"}
options = webdriver.ChromeOptions()
options.add_experimental_option("mobileEmulation", mobile_emulation)
driver = webdriver.Chrome(options=options)

The name here is an example; use one available to your ChromeDriver and Chrome combination. Preset availability can vary by version. An unavailable name causes an error, so use explicit metrics when the desired preset is not recognized.

Navigate, wait for the intended state, and save the viewport

  1. Create the Chrome driver with mobile emulation already configured.
  2. Call driver.get(url) to load the page.
  3. Wait for the page state the screenshot should show. Depending on the site, that may mean waiting for a particular element or for client-side content to render; a navigation call alone does not guarantee that every dynamic element is ready.
  4. Call driver.save_screenshot("mobile-viewport.png"). Selenium saves an image of the current browser viewport.
  5. Call driver.quit() in a finally block so the browser session is closed even if navigation or capture fails.

Selenium’s WebDriver API documents screenshot support, including saving a screenshot to a file: Selenium WebDriver documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Tracfone Motorola Moto G 2025, 64GB, Saphire Blue (Locked to
  • Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Tracfone plan required, activating is easy, just 3 steps.
  • DISPLAY: Immersive viewing on a 6.7-inch super-bright 120Hz display with powerful stereo speakers and Bass Boost for cinematic entertainment.
  • CAMERA SYSTEM: Advanced 50MP Quad Pixel camera captures sharp, detailed photos and videos in any lighting condition
  • PERFORMANCE: Lightning-fast 5G connectivity paired with a powerful processor and RAM Boost for smooth multitasking.
  • BATTERY LIFE: Long-lasting 5000mAh battery with TurboPower charging technology delivers hours of power in minutes.

Choose dimensions and pixel ratio deliberately

  • Width and height: These set the emulated viewport dimensions used to lay out the page. Use the dimensions relevant to the screen-sized view you want to inspect; custom metrics are not limited to named presets.
  • Pixel ratio: Device pixel ratio relates physical screen pixels to CSS pixels and affects rendering density and screenshot output resolution. Match it to the target when pixel density matters.
  • Mobile and touch settings: Mobile emulation is not just a smaller browser window. ChromeDriver exposes mobile behavior and touch-event emulation, which can affect page behavior as well as appearance.
  • Preset or metrics: A preset is convenient when it exists in the version you are running. Explicit metrics are preferable when you need a custom size or a repeatable configuration that does not depend on a device name.

Viewport screenshots are not full-page screenshots

driver.save_screenshot() captures the currently visible viewport. Content below or outside that viewport is not included just because the page has loaded. Chrome DevTools labels its distinct full-page command “Capture a full size screenshot”; choose a full-page capture method when you need off-screen content rather than a screen-sized image. The Chrome documentation distinguishes these capture scopes in its Device Mode guidance.

Understand what mobile emulation can prove

Chrome DevTools describes device mode as a first-order approximation: the page runs in desktop Chrome, not on a physical mobile device. Emulation cannot reproduce every hardware, CPU-architecture, browser, or device-specific behavior. A screenshot therefore documents the selected Chrome viewport and emulation settings; it does not by itself establish that a site works on every phone or browser. For behavior that depends on real hardware or a particular mobile browser, validate on that device, using remote debugging where appropriate. Device type can also affect touch and click event behavior.

Troubleshooting Selenium mobile screenshots

Chrome rejects the device name

Cause: The requested deviceName is not present in the DevTools emulation data available to that ChromeDriver and Chrome version.

Rank #3
Sale
Samsung Galaxy A17 5G Smart Phone 128GB, US 1 Yr Manufacturer Warranty Blue | Large AMOLED, High-Res Camera, Durable Design, Super Fast Charging, Expandable Storage, Circle to Search, 2025
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.

Fix: Choose a currently available preset or switch to deviceMetrics with explicit width, height, and pixel ratio. Do not assume a device name remains available across versions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The image has desktop layout or the wrong dimensions

Cause: Mobile emulation may not have been passed in Chrome options when the driver session was created, or the configured metrics may not describe the viewport you intended.

Fix: Confirm that add_experimental_option("mobileEmulation", mobile_emulation) runs before webdriver.Chrome(options=options). Check the width, height, pixel ratio, and mobile setting in the configuration, then create a new driver session.

Rank #4
Sale
Samsung Galaxy S26 Ultra, Unlocked Android Smartphone, 512GB, Black
  • PRIVACY DISPLAY: Automatically hide your screen from those beside you. The built-in privacy display can be preset¹ to turn on when receiving notifications, typing passwords, or using specific apps
  • TYPE IT IN. TRANSFORM IT FAST: Enhance any shot in seconds on your smartphone by using Photo Assist² with Galaxy AI.³ Add objects, restore details, or apply new styles by simply typing or tapping
  • NIGHTS, CAPTURED CLEARLY: From gigs to city lights, record and capture moments after dark with clarity using Nightography so your photos and videos stay crisp and clear on your Samsung Galaxy
  • MAKE IT. EDIT IT. SHARE IT: Turn everyday moments into something personal with creative tools built right into your mobile phone, whether it’s a special contact photo, custom wallpaper, an invitation or more⁴
  • HELP THAT KEEPS UP: Stay in the moment while Now Nudge with Galaxy AI helps you respond faster and stay organized with smart suggestions⁵ that appear exactly when you need them on your phone

Dynamic content is missing

Cause: The screenshot was taken before the page reached the state you wanted to capture. A successful navigation does not guarantee that all client-rendered content, images, or interactions are ready.

Fix: Wait for a meaningful page condition—such as a required element appearing—before calling save_screenshot(). Choose the condition based on the page rather than relying on an arbitrary delay where possible.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Content below the fold is absent

Cause: The WebDriver screenshot is a viewport capture.

Best Value
Tracfone Moto g Play 2024 Prepaid Phone with a 1-Yr Plan Included
  • Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Activating is easy, just 3 steps.
  • ACTIVATION Promotion: Includes 1500 min, 1500 texts & 1500 MB Data + add more as you need it
  • CAMERA SYSTEM: 50MP Quad Pixel camera. Capture sharper, more vibrant photos day or night with 4x the light sensitivity.
  • PERFORMANCE: Blazing-fast Qualcomm performance. Get the speed you need for great entertainment with a Snapdragon 680 processor and 4GB of RAM.
  • 64GB built-in storage. Get plenty of room for photos, movies, songs, and apps. Made for US

Fix: Use a full-page capture approach when off-screen page content is required; do not treat the viewport image as a full-page result.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo can return a screenshot from one API request. See the ScreenshotNeo API documentation for request options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server lets AI agents use screenshot tools. The free plan includes 1,000 screenshots per month with no card required; paid plans start at $5 for 3,000 screenshots.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sign up for ScreenshotNeo’s free plan.

FAQ

Does Selenium mobile emulation run Chrome on a phone?

No. It emulates selected mobile settings in desktop Chrome; use a real device when device-specific behavior must be verified.

Does this method capture content below the viewport?

No. The example saves the current viewport. Use a separate full-page capture method for off-screen content.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.