October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Browser Testing

How to Customize a Local Browser with Cookies, Viewport, and More

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

For a repeatable local browser session, use a Playwright browser context: set viewport and emulation defaults when you create it, then load only the cookies and local storage your test needs. Change a page’s viewport separately when you need a one-off size. These settings emulate browser conditions; they do not make a desktop machine identical to a physical phone or other device.

What “customize a local browser” means

A browser context is an isolated session configured by your code. It can start with known storage and context-wide settings, so a development page or test sees a predictable combination of cookies, viewport, locale, and related properties. This is different from changing a person’s everyday browser profile through its settings UI: the Playwright documentation cited here covers automated contexts, not a complete comparison of manual profile-customization tools.

The examples use Playwright’s JavaScript API with Chromium. The same general approach applies across Playwright’s supported browser engines, but confirm that a particular option is supported by the browser and version you actually run. Playwright names Chromium, WebKit, Firefox, Google Chrome, and Microsoft Edge in its browser guide. Playwright browser guide.

Create a context with a predictable viewport

Install Playwright and the browser binaries needed by your project using the official installation instructions. The following is a complete small script once Playwright is installed. It opens a page at a fixed viewport and reports its dimensions:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Logitech M185 Compact Ambidextrous 2.4 GHz Wireless Mouse - Swift Grey
  • Compact Mouse: With a comfortable and contoured shape, this Logitech ambidextrous wireless mouse feels great in either right or left hand and is far superior to a touchpad
  • Durable and Reliable: This USB wireless mouse features a line-by-line scroll wheel, up to 1 year of battery life (2) thanks to a smart sleep mode function, and comes with the included AA battery
  • Universal Compatibility: Your Logitech mouse works with your Windows PC, Mac, or laptop, so no matter what type of computer you own today or buy tomorrow your mouse will be compatible
  • Plug and Play Simplicity: Just plug in the tiny nano USB receiver and start working in seconds with a strong, reliable connection to your wireless computer mouse up to 33 feet / 10 m (5)
  • Better than touchpad: Get more done by adding M185 to your laptop; according to a recent study, laptop users who chose this mouse over a touchpad were 50% more productive (3) and worked 30% faster (4)
const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch({ headless: true });
  const context = await browser.newContext({
    viewport: { width: 1440, height: 900 }
  });
  const page = await context.newPage();

  await page.goto('https://example.com');
  console.log(await page.evaluate(() => ({
    width: window.innerWidth,
    height: window.innerHeight
  })));

  await browser.close();
})();

Replace the URL with a page you control or are authorized to test. A context-wide viewport is useful when every page in a test should begin at the same size. Playwright documents a default viewport of 1280×720 if you do not set one. Setting viewport: null allows the operating-system host window to determine the viewport, which can make results nondeterministic; prefer explicit dimensions for repeatable automation. Browser API.

Change the size for just one page

If most pages should use the context default but one scenario needs a different visible area, change that page’s viewport:

await page.setViewportSize({ width: 390, height: 844 });

This changes the page viewport, not every device characteristic. The screen dimensions and device scale factor are separate settings from viewport width and height. Treat the viewport as the page’s visible layout area, not as a complete description of the display or hardware.

Rank #2
Sale
Logitech G305 Lightspeed Wireless Gaming Mouse - Black
  • The next-generation optical HERO sensor delivers incredible performance and up to 10x the power efficiency over previous generations, with 400 IPS precision and up to 12,000 DPI sensitivity
  • Ultra-fast LIGHTSPEED wireless technology gives you a lag-free gaming experience, delivering incredible responsiveness and reliability with 1 ms report rate for competition-level performance
  • G305 wireless mouse boasts an incredible 250 hours of continuous gameplay on just 1 AA battery; switch to Endurance mode via Logitech G HUB software and extend battery life up to 9 months
  • Wireless does not have to mean heavy, G305 lightweight mouse provides high maneuverability coming in at only 3.4 oz thanks to efficient lightweight mechanical design and ultra-efficient battery usage
  • The durable, compact design with built-in nano receiver storage makes G305 not just a great portable desktop mouse, but also a great laptop travel companion, use with a gaming laptop and play anywhere

Set cookies and browser storage

Cookies are scoped data, not just name-and-value pairs. A cookie’s domain and path determine where it applies; records may also include expiration and security attributes such as httpOnly, secure, and sameSite. A leading dot in a domain allows a cookie to apply to subdomains. Seed a context with a storage-state file when you need a known set of cookies and local storage:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  const context = await browser.newContext({
    viewport: { width: 1280, height: 800 },
    storageState: 'state.json'
  });
  const page = await context.newPage();
  await page.goto('https://example.com');
  await browser.close();
})();

The state file can be created from an existing Playwright context with await context.storageState({ path: 'state.json' }). It can contain cookies and local storage for the origins represented in that state. If you instead need to add cookies directly, use the context API and provide the URL or the appropriate domain and path:

await context.addCookies([
  {
    name: 'theme',
    value: 'dark',
    domain: 'example.com',
    path: '/',
    expires: -1,
    httpOnly: false,
    secure: true,
    sameSite: 'Lax'
  }
]);

For domain-wide subdomain coverage, Playwright accepts a leading dot in the cookie domain, for example .example.com. Choose a domain and path that match the requests under test. A cookie for one host or path may not be sent to another, and a Secure cookie is intended for secure contexts. Consult the BrowserContext API for the current accepted cookie fields and storage-state behavior.

Rank #3
Sale
Logitech M185 Compact Ambidextrous Wireless Mouse with Rubber Grips - Blue
  • Compact Mouse: With a comfortable and contoured shape, this Logitech ambidextrous wireless mouse feels great in either right or left hand and is far superior to a touchpad
  • Durable and Reliable: This USB wireless mouse features a line-by-line scroll wheel, up to 1 year of battery life (2) thanks to a smart sleep mode function, and comes with the included AA battery
  • Universal Compatibility: Your Logitech mouse works with your Windows PC, Mac, or laptop, so no matter what type of computer you own today or buy tomorrow your mouse will be compatible
  • Plug and Play Simplicity: Just plug in the tiny nano USB receiver and start working in seconds with a strong, reliable connection to your wireless computer mouse up to 33 feet / 10 m (5)
  • Better than touchpad: Get more done by adding M185 to your laptop; according to a recent study, laptop users who chose this mouse over a touchpad were 50% more productive (3) and worked 30% faster (4)

Keep authentication state safe

Saved storage state can contain credentials or session tokens. Use the minimum state a local test needs, do not commit a real account’s state file to source control, and do not copy a live account cookie merely because it is technically possible. Create a clean context when you want to test first-visit behavior rather than an already-authenticated or previously configured session.

Emulate more than a viewport

A narrow viewport alone does not turn a desktop browser into a phone. Playwright’s device presets and context options can configure additional behavior, including user agent, screen dimensions, device scale factor, touch/mobile behavior, locale, timezone, geolocation, permissions, color scheme, reduced motion, media type, and whether JavaScript is enabled. Use only the dimensions that affect the scenario; adding unrelated overrides makes the test harder to interpret. Playwright emulation guide.

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

Use a device preset when it matches the test

Playwright includes device descriptors that can be passed to a context, for example:

Rank #4
Amazon Basics 3-Button USB Wired Mouse with Responsive Tracking, Plug & Play, Compatible with Windows and Mac, Black
  • Computer mouse for easily navigating a computer interface; click, scroll, and more
  • USB-A wired connection; if existing device only supports USB-C, an additional adapter will be required
  • High-definition (1000 dpi) optical tracking ensures responsive cursor control for precise tracking and easy text selection
  • 3 buttons offer effortless fingertip control
  • Plug-and-go ready for instant use
const { chromium, devices } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  const device = devices['iPhone 13'];
  const context = await browser.newContext({ ...device });
  const page = await context.newPage();
  await page.goto('https://example.com');
  await browser.close();
})();

Use a descriptor available in the installed Playwright version; device definitions can change. A preset applies a bundle of emulation values, rather than proving that the result is indistinguishable from the named physical device. For a layout check, explicit viewport settings may be enough. For behavior that depends on a real operating system, hardware, browser build, or touch interaction, verify on the actual target device as well.

Set context-wide properties for an entire scenario

When every page in a scenario needs the same locale, time zone, or color scheme, set those at context creation rather than patching individual pages. For example:

const context = await browser.newContext({
  viewport: { width: 1280, height: 800 },
  locale: 'en-GB',
  timezoneId: 'Europe/London',
  colorScheme: 'dark',
  reducedMotion: 'reduce'
});

Geolocation and permissions should also be treated as test inputs, not incidental defaults. Configure the location and grant the relevant permission only if the page’s behavior depends on them. Consult the official emulation guide for option-specific details and browser support.

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.
Best Value
Acer Wireless Mouse for Laptop, 2.4GHz Computer Mouse 3 Adjustable 1600 DPI
  • 【Plug and Play for Home/Office/School】The wireless computer mouse features 2.4GHz connectivity, delivering a stable, interference-free connection up to 32ft. Designed for 𝐦𝐞𝐝𝐢𝐮𝐦 𝐭𝐨 𝐥𝐚𝐫𝐠𝐞 𝐬𝐢𝐳𝐞𝐝 𝐡𝐚𝐧𝐝𝐬, it ensures comfortable use all day. Simply plug in the USB-A receiver for instant pairing—no drivers needed. 📌📌 If the mouse isn’t suitable, place the USB receiver in the battery compartment and return both.
  • 【3 Levels Adjustable DPI】This travel USB mouse offers 3 adjustable DPI settings (800, 1200, 1600), allowing you to customize sensitivity for precise design work. Effortlessly switch to match your task and elevate your productivity. 📌 Please remove the film at the bottom of the mouse before use.
  • 【Effortless Browsing】Equipped with forward and backward buttons, this computer mice streamlines your workflow, making it easy to navigate through web pages and files with a simple click. 📌Side button does not work on Mac.
  • 【Visible Indicator Light】 The pc mouse features a visual indicator for DPI levels and low battery alerts. The red light flashes once for 800 DPI, twice for 1200 DPI, and three times for 1600 DPI. When the battery level is below 10%, the light flashes red until the mouse is completely out of power.
  • 【Click to Wake】With smart sleep mode, it saves power by standby after 10 inactive minutes, just 2-3 clicks to wake. This efficient design delivers 3x longer battery life than motion-wake mice. Engineered for durability, its buttons and scroll wheel are tested for 10 million clicks, ensuring long-term reliability and consistent performance.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose context defaults, per-page changes, or clean state

Need Use Why
Same settings across a test session Set options in browser.newContext() All pages created in that context share the configured session conditions.
One page at a different size page.setViewportSize() Change that page’s viewport without redefining the whole context.
Known cookies and local storage storageState when creating a context Start the session from a saved state rather than relying on prior manual browsing.
First-visit or unauthenticated behavior Create a fresh context without saved state A clean session avoids accidentally inheriting prior cookies or local storage.
Real hardware or OS-specific behavior Test on the actual device as well Emulation does not establish equivalence to physical hardware.

Use configuration in Playwright Test

For a test suite, configure reusable defaults in the test configuration or fixtures rather than repeating them in every test. Playwright Test supports browser context options as configuration. For example, a configuration can establish a common viewport:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  use: {
    viewport: { width: 1440, height: 900 },
    locale: 'en-US',
    colorScheme: 'light'
  }
});

A test that needs a different condition can override its context options for that test. Keep separate scenarios separate when they represent meaningfully different states, such as a clean visitor and a signed-in user. See the official Playwright Test configuration documentation for the current configuration shape.

Troubleshoot unexpected results

  • The page still looks like desktop: Check the actual viewport dimensions in the page, and remember that viewport width alone does not set mobile user-agent or touch behavior. Use a relevant device descriptor or the specific context properties your scenario requires.
  • A cookie is missing: Verify its domain, path, expiry, and secure requirements against the page URL. Confirm that the state file was loaded when the context was created and that it represents the origin you are visiting.
  • Storage seems to leak between tests: Reuse can preserve state if you deliberately share a context. Create a fresh context for isolation, or explicitly initialize each run from the intended storage state.
  • Viewport tests vary between runs: Set explicit width and height instead of relying on the host window with viewport: null. Also check that the test is changing the page viewport you intend.
  • An emulation option is ignored or differs by engine: Confirm support for the specific browser and version under test. Playwright covers multiple browsers, but a configuration property does not guarantee identical behavior across engines or versions.
  • A preset does not reproduce a physical device: Treat it as an emulation profile. Validate hardware-, OS-, and browser-specific behavior on the actual target device.

Or skip the browser setup

If the goal is a clean screenshot rather than a repeatable interactive test session, ScreenshotNeo takes a screenshot from one GET request. It can return PNG, JPEG, WebP, or PDF and offers viewport, device, cookie, and other capture options. It is not a substitute for configuring a local Playwright context when you need to interactively inspect or test application behavior.

cURL example:

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

See the ScreenshotNeo API documentation for parameters and response details. Cookie banners are accepted and removed before the shot; newsletter popups and chat widgets are removed too, and each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed; response headers identify the page verdict and billing status. An MCP server exposes screenshot tools to AI agents, including Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up free for 1,000 screenshots a month, no card required.

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

Frequently Asked Questions

Can I customize a regular browser profile with these Playwright settings?

The examples configure automated Playwright contexts. They are not instructions for changing a browser’s everyday profile through its settings interface.

Does a Playwright mobile preset guarantee the same output as a phone?

No. It emulates selected browser and device characteristics; confirm physical-device-specific behavior on the target device.

Can I use the same storage-state file for every browser engine?

Storage state is a Playwright mechanism, but validate the resulting behavior in each target browser and version, especially where cookie handling or site behavior differs.

Quick Recap

SaleBestseller No. 1
Logitech M185 Compact Ambidextrous 2.4 GHz Wireless Mouse - Swift Grey
Logitech M185 Compact Ambidextrous 2.4 GHz Wireless Mouse - Swift Grey
Product carbon footprint: 3.97 kg CO2e; Contoured shape: Gives you more comfort and control
$14.90
SaleBestseller No. 3
Bestseller No. 4
Amazon Basics 3-Button USB Wired Mouse with Responsive Tracking, Plug & Play, Compatible with Windows and Mac, Black
Amazon Basics 3-Button USB Wired Mouse with Responsive Tracking, Plug & Play, Compatible with Windows and Mac, Black
Computer mouse for easily navigating a computer interface; click, scroll, and more; 3 buttons offer effortless fingertip control
$9.70

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.

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

Leave a Reply

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

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

Read next

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
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.