Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
To copy a CSS selector in Chrome, inspect the element, then right-click its selected node in DevTools and choose Copy > Copy selector. Paste the result into your code and verify that it matches the intended element: a copied selector can match more than one node, and a selector for a node inside Shadow DOM may not work as a document-level query.
Copy a selector from the page
- Open the page and locate the target. If it is easy to right-click, right-click the element on the page and select Inspect. Chrome opens DevTools and selects the corresponding node in the Elements panel. For a button, link, image, or other visible item, right-click the item itself rather than nearby blank space.
- Use Inspect mode if right-clicking is awkward. Open Chrome DevTools’ Inspect mode, then click the target in the page. The documented shortcuts are Ctrl+Shift+C on Windows, Linux, and ChromeOS, and Cmd+Option+C on macOS. The page picker selects the corresponding DOM node in Elements. See Chrome’s Inspect mode guide.
- Copy the CSS selector. In the Elements panel’s DOM tree, right-click the selected node and choose Copy > Copy selector. Paste it into your stylesheet, test code, or automation script. The menu action starts from the selected node in the DOM tree, not from the visible page.
- Verify what it selects. Search for the selector in the Elements panel, or test it in the Console using the steps below. Check the actual matched nodes before relying on it.
The alternative workflows are useful in different situations: right-click Inspect is the shortest route when the target is easy to click, while Inspect mode lets you pick an element without opening its context menu. Chrome’s CSS features reference describes working with selected elements in Elements.
Check whether the selector identifies the right element
A selector is an expression that matches DOM elements; copying one does not prove that it matches only the node you intended. It may match several similar buttons, cards, or repeated items. Confirm the match count and inspect the result in the page state where you plan to use it.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Test it in the Console
Open the Console, replace the example string with the selector you copied, and run:
#1 Best Overall
document.querySelectorAll('PASTE_SELECTOR_HERE')
The result is a collection of all matching elements. If it contains several nodes, inspect them and decide whether the selector needs to be more specific. Chrome also provides $$() as a DevTools Console shortcut equivalent to document.querySelectorAll():
$$('PASTE_SELECTOR_HERE')
For a quick single-match check, use document.querySelector(), which returns the first match or null if none is found. A first match is not necessarily the intended match when several elements satisfy the selector. Chrome documents $$() and related Console helpers in the Console Utilities API reference.
Rank #2
Search in Elements
Click the Elements panel, open its search (typically Ctrl+F on Windows/Linux/ChromeOS or Cmd+F on macOS), and enter the selector. DevTools can search the DOM with selectors as well as text and XPath; inspect the matches rather than assuming the first result is right. See Chrome’s DevTools search guide.
Outdated 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 matchPC 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 & 11Confirm the selected node
When a node is selected in Elements, $0 in the DevTools Console refers to that currently selected node. Use it to check that the page picker selected the correct element before building a query around it:
$0
You can also inspect a property, for example $0.tagName, or check the node’s text with $0.textContent. These are DevTools Console conveniences; they are not selectors to paste into a regular page script. Chrome explains $0 and DOM inspection in Get started with viewing and changing the DOM.
Use the selector in CSS or automation
For a regular DOM node, the copied selector can be used anywhere that accepts a CSS selector, such as document.querySelectorAll() or an automation locator that supports CSS. Test it against the live page before committing it to a script. The selector describes the inspected page’s DOM, not a permanent identity for the element; page redesigns and runtime changes can alter or remove the matching structure.
Rank #4
If it matches too many nodes, narrow it with an appropriate parent or another reliable attribute, then retest. If it matches none, check that the page is in the same state, that the copied text was pasted intact, and that the element is not inside a Shadow DOM boundary. Avoid assuming that a long selector copied from one page state will remain valid after the site changes.
Special case: an element inside Shadow DOM
A node inside a shadow tree is not necessarily reachable with a selector queried from the document. Chrome’s historical explanation of Copy selector notes that, for a Shadow DOM target, the copied selector is a path from within the shadow tree. A normal document.querySelectorAll() query does not cross a shadow root boundary.
Best Value
For diagnosis, select the node and use Copy > Copy JS Path. Chrome’s DOM tutorial describes this as copying a document.querySelector() expression that resolves to the selected node in DevTools. Treat the path as a clue to the node’s location, not as proof that the same expression will work unchanged in your application or automation framework: the consuming code must account for the shadow root. For background on the menu behavior, see Chrome’s historical DevTools 72 notes.
Common problems and fixes
- “Copy selector” is missing or the wrong node is selected: first select the target in the Elements DOM tree, using Inspect mode or right-click > Inspect on the page. Then right-click that selected node in the tree and open Copy.
- The Console returns several elements: the selector is not unique in the current DOM. Inspect the returned nodes and narrow the selector to identify the intended one.
- The Console returns an empty collection: confirm the selector was pasted without changing its characters, and that the relevant content is currently present. If the target is in Shadow DOM, query from the appropriate shadow root rather than assuming a document-level query will reach it.
- The selector works in DevTools but not in the script: DevTools shortcuts such as
$0and$$()are Console utilities, not ordinary page JavaScript. Use standard DOM methods such asdocument.querySelectorAll()for regular DOM content, and handle Shadow DOM explicitly when applicable. - The selector stops working later: re-inspect the current page and retest it. The copied path came from that page’s DOM and is not a guarantee of stability across site updates or changed page states.
Or skip the browser setup
Chrome DevTools is the way to extract and verify a selector. If the next step is capturing a page image or PDF rather than inspecting its DOM, ScreenshotNeo offers a screenshot API and MCP server; it does not extract CSS selectors. Its API can return a screenshot or PDF from one GET request. For example, this cURL request saves a WebP screenshot of Stripe:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed; and an MCP server lets AI agents use screenshot tools. The free plan includes 1,000 screenshots per month with no card, and paid plans start at $5 for 3,000. Learn about ScreenshotNeo or sign up free for 1,000 screenshots a month, with no card.
Frequently Asked Questions
Does Copy selector copy an element’s CSS styles too?
No. It copies a selector path for locating the node; use the Elements panel’s Styles and Computed views to inspect CSS applied to it.
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.

