Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsUse Playwright to visit a known list of websites, submit a search query using controls specific to each site, wait for a meaningful result signal, and save a screenshot. The browser workflow can be shared, but search fields and result states cannot safely be assumed to match across sites. This guide shows a configurable pattern for searching and capturing results without treating every website as if it had the same interface.
How the workflow fits together
For each target, your script needs four things: its URL, a way to locate and submit its search control, a condition that tells you results are ready, and a screenshot scope. Playwright handles navigation and browser interaction; your per-site configuration supplies the details that vary.
- Install Playwright and its browser.
- Define the target sites and their search/result locators.
- Open each site, enter the query, and submit it.
- Wait for a site-specific result signal, then capture the viewport, full page, or a particular element.
- Record failures per site so a problem on one target does not prevent the others from running.
Playwright’s official Page API documents the browser-page workflow, including navigation, viewport sizing, and screenshots. Its locator guide recommends user-facing locator strategies and describes locator auto-waiting and retry-ability. The example below is an instructional pattern, not tested code; inspect and adapt selectors and result conditions for each target.
Install Playwright
Use a current Node.js installation, then create a project directory and install Playwright with its Chromium browser:
Free tools Windows power users keep installed
One-click scans. No signup required.
#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.
mkdir multi-site-search
cd multi-site-search
npm init -y
npm install playwright
npx playwright install chromium
The browser installation is separate from the JavaScript package. If your environment already has the required Playwright browser installed, you may not need to download it again. The example uses Chromium; Playwright’s Page API is the relevant reference for the page and screenshot methods shown here.
Build a per-site search configuration
Do not assume that one selector or one submission method works across unrelated websites. A labeled search field and a button are convenient when a site exposes them, but another site may open search from an icon, accept Enter instead of a button, or render results in a different part of the page.
Represent each target’s interaction as data. For a simple shared pattern, configure the accessible label for the input, the accessible button name, and a locator that becomes visible when results are ready:
const targets = [
{
name: 'Example A',
url: 'https://example.com',
searchLabel: 'Search',
submitName: /search/i,
resultsSelector: '[data-testid="search-results"]',
},
{
name: 'Example B',
url: 'https://example.org',
searchLabel: 'Search this site',
submitName: /find/i,
resultsSelector: 'main h1',
},
];
The values above are illustrative: replace them with controls and result markers that actually exist on each target. Prefer accessible roles and names for buttons and labels for form fields when available. Playwright recommends getByRole() and other user-facing locator approaches because they express how a person identifies a control, rather than relying immediately on brittle styling details.
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.
Runnable JavaScript pattern
Save the following as search-sites.js. The two example domains and their selectors are placeholders to replace before use. The script creates one browser context with its viewport set before navigation, then processes targets one at a time. A failure is logged for its site and the loop continues.
const { chromium } = require('playwright');
const targets = [
{
name: 'Example A',
url: 'https://example.com',
searchLabel: 'Search',
submitName: /search/i,
resultsSelector: '[data-testid="search-results"]',
},
{
name: 'Example B',
url: 'https://example.org',
searchLabel: 'Search this site',
submitName: /find/i,
resultsSelector: 'main h1',
},
];
const query = 'the phrase to search';
(async () => {
const browser = await chromium.launch();
const context = await browser.newContext({
viewport: { width: 1440, height: 900 },
});
try {
for (const target of targets) {
const page = await context.newPage();
try {
await page.goto(target.url, { waitUntil: 'domcontentloaded' });
await page.getByLabel(target.searchLabel).fill(query);
await page.getByRole('button', { name: target.submitName }).click();
// Replace this with a result locator or URL condition for the target.
await page.locator(target.resultsSelector).waitFor({
state: 'visible',
timeout: 15000,
});
const filename = `${target.name.replace(/[^a-z0-9_-]/gi, '_')}.png`;
await page.screenshot({ path: filename, fullPage: true });
console.log(`Saved ${filename}`);
} catch (error) {
console.error(`Could not search ${target.name}:`, error.message);
} finally {
await page.close();
}
}
} finally {
await context.close();
await browser.close();
}
})();
Run it with:
node search-sites.js
For the example to work, replace the sample URLs, labels, button names, and result selectors with accurate values. If a particular site submits on Enter, use await page.getByLabel(target.searchLabel).press('Enter') rather than clicking a button. If search opens only after clicking an icon, add that preliminary interaction to the target’s flow.
Choose a reliable result-ready condition
A successful click does not mean a site’s search has finished. Results may arrive asynchronously, the page may navigate, or a site may return an empty-state message. Wait for a condition that reflects the outcome you need, such as a results heading, a results container, or a URL change.
- Results container: wait for a target-specific result list to become visible.
- Heading or status: wait for a result heading or an explicit empty-results message.
- Navigation: if submission changes the URL, wait for the expected navigation or URL pattern rather than guessing with a fixed delay.
Locators auto-wait for actions and retry when appropriate, but they cannot determine what constitutes a completed search on a particular site. A generic element such as main may already be visible before results arrive, so it can be too weak as a readiness check. Avoid using an arbitrary sleep as your only signal.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →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.
If a result list changes while loading, wait for a stable result state before collecting its entries. Playwright warns that locator.all() returns immediately and may be unpredictable when the matching list is dynamic.
Capture the right screenshot scope
Choose scope based on what the screenshot needs to prove. A viewport screenshot records what is visible at the current scroll position; a full-page screenshot captures the scrollable page; an element screenshot isolates a matched component. Playwright documents these screenshot options in its Page API and locator guide.
| Scope | Example | Useful when |
|---|---|---|
| Viewport | await page.screenshot({ path: 'results.png' }); |
You need a consistent view of the visible results at the current scroll position. |
| Full page | await page.screenshot({ path: 'results-full.png', fullPage: true }); |
You need the page’s full scrollable content in one image. |
| Specific element | await page.locator('[data-testid="search-results"]').screenshot({ path: 'results-only.png' }); |
You need just a result list or other individual component. |
For a responsive layout, set the viewport on the browser context before opening pages, as in the sample. That makes the captured viewport explicit and allows the site to render at the intended dimensions.
Adapt the script to different sites
Search field has no accessible label
Inspect the page’s accessible names and markup. If a reliable user-facing locator is unavailable, use a stable site-specific selector as an explicit contract, such as an input name or documented test ID. Avoid selectors tied to incidental layout classes that may change without notice.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →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
Search button is missing or ambiguous
Use the site’s actual submission path: a more specific accessible button name, Enter on the field, or a preliminary click on the search control that reveals the field. Keep this logic isolated to the target rather than weakening every site’s locator.
Results load without a page navigation
Wait for a site-specific results element or status message. For single-page applications, submission can update content without changing the URL; in that case a navigation wait will not establish completion.
Need a custom flow per target
When sites differ substantially, use a small adapter function per site. Each adapter can handle its own search icon, modal, submission method, and ready condition while the outer loop continues to own browser lifecycle, error reporting, and screenshots.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Failures, reliability, and operating costs
Each website is an independent dependency: it can be unavailable, slow, redesigned, or protected by its own access controls. A per-site try/catch lets the rest of the list proceed, but log enough context to diagnose failures—site name, stage, and error message. For recurring jobs, also record whether a screenshot was actually written and keep output names unique if multiple queries or runs are involved.
Best 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.
- Timeouts: distinguish navigation timeout from a missing result locator. Increase a timeout only when the site legitimately needs more time; first verify the selector and readiness condition.
- Changing markup: review selectors when a site’s interface changes. Prefer accessible labels and roles, then use a deliberate site-specific fallback.
- Large captures: full-page images can be much larger than viewport or element images. Capture only the scope required for your evidence or downstream processing.
- Access restrictions: check the target’s terms, applicable robots guidance, rate limits, and any published search API before automating it. Playwright’s documentation does not establish permission to automate a particular site.
- Repeated work: keep the target list explicit so individual sites can be retried and reported independently rather than restarting an opaque batch.
Troubleshooting
| Symptom | Likely cause | What to change |
|---|---|---|
getByLabel() times out |
The field has a different accessible label, or the search UI is not open yet. | Inspect the rendered page and accessible name; open the search control first if necessary, then configure that target’s locator. |
| Button locator finds no match | The button name differs, the site uses a link or icon, or submission is keyboard-driven. | Use the actual role and accessible name, or submit the filled field with Enter if that is the site’s interaction. |
| Screenshot shows the pre-search page | The script waited for an element that was already present before the results loaded. | Wait for a result-specific heading, container, empty-state message, or expected URL condition. |
| Full-page screenshot omits expected content | Content may load only on scroll or the page may still be rendering. | Use the site’s supported behavior to reveal lazy content and wait for its appearance before capturing; verify the chosen full-page scope. |
| One failed site stops the batch | Error handling surrounds the whole loop rather than each site’s work. | Keep navigation, interaction, and capture inside a per-target try/catch, and close each page in finally. |
| Browser launch fails | The Playwright browser binary may not be installed for the environment. | Run npx playwright install chromium in the project environment, then rerun the script. |
Or skip the browser setup
If your goal is to capture a URL rather than interactively search the site’s interface, a screenshot API can avoid managing a browser process. ScreenshotNeo is a website screenshot API and MCP server for developers; its clean-shot flow accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture. Those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status.
For a URL you have already determined—for example, a site’s search-results URL—one GET request returns an image or PDF. This does not replace the Playwright interaction above when the search must be entered into a site-specific form.
curl -G "https://api.screenshotneo.com/v1/shot"
-d access_key=YOUR_API_KEY
--data-urlencode url=https://example.com/search?q=the%20phrase%20to%20search
-o results.webp
See the ScreenshotNeo API documentation for request options. The service also provides an MCP server with take_screenshot, get_page_info, and capture_pdf tools for AI agents. Its Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month with no card.
Frequently asked questions
Can I search any website with the same JavaScript code?
No. The browser loop can be reused, but search controls, submission methods, result states, and access rules vary by site. Configure each target accordingly.
Should I use a site’s search API instead of its web page?
If the site publishes an appropriate search API and your use case fits its terms, evaluate it before automating the interface. Browser automation is useful when the workflow depends on rendered page interactions; the cited Playwright sources do not compare API coverage or recommend a universal method.
Does Playwright’s locator auto-wait prove the search is complete?
No. Auto-waiting helps actions and locator operations wait for their conditions, but your script still needs a meaningful, target-specific signal that results are ready.
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.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.

