To capture a mobile-style screenshot with PhantomJS, set page.viewportSize before opening the URL, optionally set a mobile user-agent string, wait for the page to load successfully, then call page.render(). For an exact output rectangle, also set page.clipRect. PhantomJS development is suspended, so this is best treated as a legacy workflow rather than a choice for a new capture system.
Capture a mobile viewport with PhantomJS
PhantomJS uses WebKit to lay out and render pages. Its official screen-capture guide describes capturing a web page through that rendering engine: PhantomJS screen capture. A mobile-sized viewport makes responsive layouts adapt to the selected CSS width; it does not reproduce a physical phone.
Complete script
Save the following as mobile-screenshot.js:
var page = require('webpage').create();
page.viewportSize = { width: 375, height: 667 };
page.settings.userAgent =
'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2 like Mac OS X) ' +
'AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 ' +
'Mobile/15E148 Safari/604.1';
page.open('https://example.com/', function (status) {
if (status !== 'success') {
console.log('Unable to access network');
phantom.exit(1);
return;
}
page.render('mobile-375x667.png');
phantom.exit();
});
Run it with phantomjs mobile-screenshot.js. The script sets both viewport and user agent before page.open(); PhantomJS settings documentation says those settings apply during the initial open call. The callback checks the load status before rendering, following the documented capture sequence (WebPage API).
What the script changes
page.viewportSizesets the emulated browser window dimensions in CSS pixels. Use dimensions suitable for the responsive layout you want to inspect.page.settings.userAgentsends a mobile-identifying user agent. Set it before navigation if the server or page chooses content based on that value.page.open()navigates to the target. Its callback receives a status; do not create an ordinary success screenshot when it is notsuccess.page.render()writes the rendered result. Its output format is inferred from the filename extension.phantom.exit()ends the PhantomJS process after the callback completes.
Choose viewport dimensions and user agent
The viewport controls responsive CSS behavior: a page may show a compact navigation menu at one width and a desktop navigation bar at another. Examples of useful CSS viewport sizes are 375×667 for a narrow phone and 390×844 for a larger phone. These are example dimensions, not a guarantee that a particular physical handset has an identical browser viewport.
#1 Best Overall
- 【Strong Adsorption】The inspiration of the silicone phone suction case comes from the adhesive force of the octopus. Each suction cup phone mount is 3.15 inches long and 2.17 inches wide, with 24 independent suction cups providing a stronger and more stable suction force, so you don't have to worry about your phone falling during use.
- 【Back of Phone Suction Grip】Remove the adhesive film on the phone suction cup and stick it on the phone case. You can then fix the phone on any smooth surface, which is very convenient. (The phone suction cup cannot be removed and reused after being attached to the phone case. It is recommended to attach it to a regular phone case, not a valuable one.)
- 【Widely Used】Our non-slip silicone phone sticky grip mount attaches to almost any flat phone case and make it compatible with common mobile phones such as iPhone and Android.You can shoot, watch videos or video calls in the kitchen, gym, dance studio, bathroom and other places.
- 【Capture the Wonderful Picture】Whether you are a TikTok creator or just like to share videos and photos, this phone suction cup can help you hands-free capture wonderful videos and photos for sharing with friends.
- 【Note】You can fix the phone suction cup on a smooth surface such as a mirror or glass. If necessary, wipe the suction cup with a damp cloth to obtain stronger suction. Before releasing your hand, make sure the phone is firmly fixed. (Not applicable to rough walls, wooden surfaces, and other uneven surfaces)
Set viewport before navigation
Assign page.viewportSize before page.open(). Otherwise the initial layout can be computed at a different size, and a screenshot may not reflect the intended responsive breakpoint. Change the dimensions and rerun the script to compare layouts.
When to set a mobile user agent
A mobile viewport alone affects client-side responsive layout, but a server can also inspect the user-agent string and return a mobile-specific page. Set page.settings.userAgent before navigation when you need to test that behavior. A user-agent string is only an identification signal: it does not add phone hardware, touch input, a current mobile browser engine, or other physical-device characteristics to PhantomJS.
Viewport and output rectangle are different
page.viewportSize describes the emulated browser window used for page layout. page.clipRect selects a rectangle to capture. To request a fixed 375×667 capture rectangle, add this before opening the page:
Rank #2
- SUPERIOR COMFORT — Unlike traditional circular ear buds, the design of EarPods is defined by the geometry of the ear. Which makes them more comfortable for more people than any other ear bud–style headphones.
- HIGH-QUALITY AUDIO — The speakers inside EarPods have been engineered to maximize sound output and minimize sound loss, which means you get high-quality audio.
- BUILT-IN REMOTE — EarPods with USB-C plug also include a built-in remote that lets you adjust the volume, control the playback of music and video, and answer or end calls with a pinch of the cord.
- COMPATIBILITY — Works with all devices that have a USB-C port.
- INTEGRATED MICROPHONE — A built-in microphone precisely captures your voice while you’re on the phone, taking a FaceTime call, or summoning Siri — so you’re always heard loud and clear.
page.clipRect = { top: 0, left: 0, width: 375, height: 667 };
The official automation reference defines clipRect as the part of the screen taken in the screenshot (WebPage API reference). If the clip rectangle is smaller than the viewport, the output is cropped; if you need a larger rectangle, verify the rendered result against your installed build and page. Without a clip rectangle, page.render() follows PhantomJS’s normal rendered-page capture behavior.
Recommended Free Tools
Capture delayed or asynchronous page content
A successful page.open() callback means the navigation reached its callback status; it does not establish that every application-specific asynchronous task, image, or late-loading component has finished. If the page fills in content after navigation, rendering immediately can capture an incomplete state.
Wait a fixed interval
For a simple page with a predictable delay, schedule rendering after a wait. The callback sequencing below is illustrative; choose a delay based on the page rather than assuming that one duration works everywhere:
Rank #3
- Secure Hold: Our PopSockets adhesive phone grip gives your cell phone a secure, comfortable hold in hand to help prevent drops while texting, taking photos, or scrolling on the go. Designed to stick firmly to most phone cases and devices.
- Hands-Free Made Easy: Easily turn your PopSocket into a phone stand to prop up your phone anywhere — perfect for watching videos, video calls, or following recipes. A must-have phone holder that keeps your device secure and ready for anything.
- Compatibility: Works with all phones, tablets, and Kindles. Sticks best to smooth, hard plastic cases and may not adhere to silicone or textured cases. Easily swap your PopTop to change up your style — just close the grip, press down, twist 90°, and snap on a new top.
- Black PopSockets: Simple, refined, and endlessly versatile — a timeless essential for any phone.
- PopSockets Ecosystem: Mix and match your favorite PopSockets products — from grips and wallets to cases and mounts — all designed to work together seamlessly.
page.open('https://example.com/', function (status) {
if (status !== 'success') {
console.log('Unable to access network');
phantom.exit(1);
return;
}
window.setTimeout(function () {
page.render('mobile-delayed.png');
phantom.exit();
}, 2000);
});
A fixed wait can be wasteful on fast loads and insufficient on slow ones. For more control, use a page-side readiness condition that reflects the specific content you need, and render only after it becomes true. PhantomJS’s documented examples demonstrate callback sequencing but do not promise that arbitrary application work is complete when navigation succeeds.
Keep failure handling explicit
Do not let a delay obscure the navigation result. Check status first, then wait or poll for the condition, then render. When building a batch job, also make the script exit with a failure code for unsuccessful navigation so the calling process can distinguish a missing screenshot from a completed capture.
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 reinstallOutdated 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 matchChoose image format and quality
PhantomJS infers the output format from the filename extension. Its documentation lists PNG, JPEG, BMP, PPM, GIF (depending on the build), and PDF (WebPage API reference).
Rank #4
- [360 ° Flexible Rotation Design] Comes with a rotatable lanyard ring that supports 360 ° free rotation, effectively solving the problem of twisted and tangled lanyards
- [Wide compatibility] The ultra-thin 0.02-inch design does not block the charging port at all, and both wired and wireless charging can be used directly without removing the pad. Compatible with most smartphones such as iPhone, compatible with various wristbands, lanyards, crossbody straps, and keychains
- [Durable and Portable Material] Premium rust-resistant stainless steel material with good flexibility, which not only avoids scratching the phone case, but also has excellent anti rust and anti fading performance
- [Multi scenario Practical] Paired with a lanyard or wristband, hands-free use can be achieved. The phone is within reach and not easily dropped, ideal for daily commuting and outdoor activities. Suitable for full coverage phone cases, does not support half coverage phone cases
- [Quality Service] If you find any damage or other issues with the product upon receipt, please contact us immediately. We will handle it quickly
| Format | Useful when | Considerations |
|---|---|---|
| PNG | You need crisp text, interface details, or visually lossless output. | The quality option controls compression size while remaining visually lossless, according to the API reference. |
| JPEG | A smaller photographic image is more important than pixel-exact edges. | The documented quality value is an integer from 0 to 100; higher values generally retain more image detail. |
| BMP or PPM | A downstream tool specifically expects one of these formats. | They are supported formats in the reference, but may not suit a compact web-delivery workflow. |
| GIF | Your installed build supports it and a downstream workflow requires it. | Support is build-dependent. |
| You want a document output rather than a raster image. | Set a PDF filename extension and check the result in the intended document workflow. |
For PNG or JPEG-specific rendering options, consult the API reference for the installed PhantomJS version rather than assuming options from a newer browser automation library apply unchanged.
Decide whether PhantomJS fits the job
The official PhantomJS homepage states, “Important: PhantomJS development is suspended until further notice” (PhantomJS). That status matters for mobile screenshots: a viewport and user-agent can model selected inputs, but the renderer remains PhantomJS’s WebKit-based engine, not a current iOS or Android browser. Modern web features, TLS behavior, or browser rendering may differ from what users see today.
For an existing pipeline, pin the PhantomJS runtime and record the version alongside its capture settings. That makes changes in the environment easier to identify when output shifts. For a new project requiring current browser behavior, consider a maintained browser automation tool; this recommendation follows from PhantomJS’s suspended development rather than a claim that every PhantomJS capture will fail.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Best Value
- 【PKYAA Double Sided Silicone Suction Phone Case Mount】PKYAA With Double Sided 40 Strong and Reliable individual suction cups, PKYAA provides a thicken and upgraded universal silicon suction mount for your phone.
- 【Friendly to Content Creators】If you are a content creator or an online influencer, you can create videos anywhere with this suction mount completely hands free with this silicone cell phone mount for cases.
- 【HANDS-FREE & Adhere to Mirrors】This Double Sided silicone suction phone case mount allows you to stick your phone to the mirror easily. No longer holding your phone in one hand to watch video tutorials while making up.
- 【Strong Grip on the Smooth Surface】You can easily hang your phone anywhere with a smooth surface. All you do is you clean off your phone and smooth surface. It is STURDY and it not only sticks to mirrors, it also sticks to windows, it sticks to refrigerators, tiles and other clean, flat surfaces.
- 【Press Down Firmly Every 30 Minutes】Use your palm or fingers to press the phone down firmly and check it's secure before letting go. Apply even pressure for a few seconds to allow the suction cup to adhere properly. To maintain the grip and prevent accidental falls, it's a good practice to periodically reapply pressure to the suction cup.
Troubleshoot mobile screenshots
- The page looks like desktop. Confirm that
page.viewportSizeis set beforepage.open(). Check the chosen width against the site’s responsive breakpoints. If the server serves different HTML to phones, set the user agent before navigation as well. - The mobile layout is right but the content differs from a phone. Viewport and user-agent emulation do not make PhantomJS a physical device or a current phone browser. Test on the target browser or a maintained device-emulation workflow when browser-specific behavior is essential.
- The screenshot is blank or missing. Check the callback’s
status, the URL’s accessibility from the machine running PhantomJS, and the process exit status. Render only after a successful navigation. - Parts of the page are missing. The application may populate them asynchronously. Add a page-specific readiness check or a deliberate delay before calling
page.render(). - The output dimensions are unexpected. Review both
page.viewportSizeandpage.clipRect. The former affects layout; the latter selects the captured rectangle. Also check the actual rendered image dimensions rather than inferring them solely from the viewport. - The image format is wrong. Match the filename extension to the required format and verify support in the PhantomJS build, especially for GIF.
- Output differs from a modern browser. The difference may come from PhantomJS’s WebKit renderer or suspended maintenance, not just the mobile viewport. Compare in a maintained browser before treating the capture as a current-device reference.
Or skip the browser setup
For a managed screenshot API, ScreenshotNeo accepts a URL in one GET request and can return PNG, JPEG, WebP, or PDF. The request below saves a WebP response; replace the example URL and use your API key. See the ScreenshotNeo documentation for request options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo accepts cookie and consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of these steps can be turned off. Bot checks or CAPTCHAs, 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 AI agents and MCP clients. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month without a card.
Frequently Asked Questions
Does PhantomJS capture a real iPhone screen?
No. It renders a page with a selected viewport and optional user agent; it is not a physical-device capture.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesWhich setting controls mobile responsive layout?
Set page.viewportSize before navigating. Use page.settings.userAgent as well only when testing server-side or client-side user-agent behavior.
Can PhantomJS capture a page as PDF?
The documented render formats include PDF; use a PDF filename extension and verify the behavior in your installed build.
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.

