Recommended Free Tools
Selenium WebDriver offers eight traditional locator strategies: ID, name, class name, CSS selector, XPath, link text, partial link text, and tag name. Start with a unique, predictable ID; if there is no suitable ID, Selenium recommends a well-written CSS selector. Use XPath when its flexibility is useful, and check for ambiguous matches because find_element returns the first match rather than confirming that the match is unique.
The eight traditional Selenium locator strategies
Each locator strategy tells WebDriver how to identify elements in the current search context. Selenium’s official locator strategies reference describes these eight:
| Strategy | What it matches | When to use it |
|---|---|---|
id |
An element whose ID attribute matches the supplied value. | Use a unique, stable ID when the page provides one. |
name |
An element whose name attribute matches the supplied value. |
Useful for form controls or other elements with an appropriate name. |
class name |
An element with the specified class. | Supply one class name only; a compound class string is not permitted. |
css selector |
Elements matching a CSS selector. | Use a compact, readable selector, especially when there is no suitable unique ID. |
xpath |
Elements matching an XPath expression. | Useful when the relationship or matching rule is awkward to express in CSS; its syntax may be harder to debug. |
link text |
An anchor whose visible text exactly matches the supplied text. | Use for a link with stable, distinctive copy. |
partial link text |
An anchor whose visible text contains the supplied text. | Use only when a partial match is intentional and sufficiently specific. |
tag name |
Elements with the specified tag. | Often broad; more useful when retrieving a collection than when identifying one particular element. |
How to choose a locator
- Check for a stable, unique ID. Selenium recommends IDs that are available, unique, and consistently predictable. They tend to avoid more complicated DOM traversal.
- If there is no suitable ID, try a readable CSS selector. Selenium recommends a well-written CSS selector in this case.
- Use XPath when its flexibility helps. XPath can express relationships and conditions that suit a particular page, but Selenium notes that it is more complicated and often harder to debug.
- For links, decide whether exact text is stable enough. Exact link text is more specific; partial link text can tolerate some copy changes but may match unintended links. Both strategies apply only to anchor links.
- Be cautious with common classes and tags. If many elements share the class or tag, narrow the selector or retrieve and inspect multiple matches.
Selenium’s guidance puts the ID preference plainly: “In general, if HTML IDs are available, unique, and consistently predictable, they are the preferred method for locating an element on a page.” See Tips on working with locators.
CSS selector or XPath?
Neither is universally best. Selenium recommends a well-written CSS selector when a suitable unique ID is unavailable, and describes XPath as more flexible but harder to debug. Choose the shortest selector that clearly expresses the element you intend to find.
#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.
| Consideration | CSS selector | XPath |
|---|---|---|
| Good fit | Clear matches based on tags, classes, IDs, attributes, and CSS relationships. | Cases where XPath’s expression of relationships or conditions is useful. |
| Readability | Often compact for straightforward matches. | Can become harder to read as expressions grow more complex. |
| Debugging | Selenium recommends well-written CSS when a unique ID is unavailable. | Selenium cautions that XPath syntax is more complicated and frequently harder to debug. |
| Performance claim | No universal speed advantage is established by the cited guidance. | No universal speed advantage is established by the cited guidance. |
What happens when a locator matches more than one element?
A singular find_element lookup returns the first matching element in the current search context. It does not check that only one element matched. A broad selector can therefore succeed while pointing at the wrong element. Make the locator more specific when one target is intended. If the task is to inspect all matches, use a multiple-element lookup and examine the results. Selenium documents finder behavior in Finding web elements.
Relative locators and shadow roots
Relative locators in Selenium 4
Selenium 4 documents relative locators that find an element above, below, to the left or right of another element, or near it. They can help when the target is easier to identify by its position relative to a known element. Selenium determines element size and position for this feature using getBoundingClientRect(). See the official locator strategies reference.
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.
Searching inside a shadow root
For a shadow-DOM element, first locate the shadow host, obtain its shadow root, then search within that root. Selenium’s finder reference says shadow-root finder methods require Selenium 4 or greater. A search within a shadow root is scoped to that root rather than the whole document.
Nested searches and locator performance
Finding a child by first locating its parent and then searching within that parent may require two browser commands. In some cases, a CSS or XPath selector can express the search in one command and improve performance slightly. Prefer that only when the resulting selector remains clear: Selenium advises against needlessly long DOM traversals. Avoid assuming CSS or XPath is always faster; the cited documentation does not establish a universal speed ranking.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteRank #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.
Common locator problems and fixes
- Class-name lookup rejects a value with spaces: class-name strategy accepts one class name, not a compound class string. Use one class or a CSS selector for the combination.
- Link-text lookup does not find a button: link text and partial link text apply to anchors, not arbitrary buttons. Use an appropriate ID, name, CSS selector, or XPath instead.
- A lookup succeeds but acts on the wrong element: the selector may match several elements and the singular lookup returns the first. Narrow it or retrieve all matches and inspect them.
- A tag or common class returns too many candidates: add a stable attribute or relationship to the selector, or use a collection lookup if multiple results are expected.
- An XPath is difficult to maintain: simplify it, or use a suitable unique ID or readable CSS selector if it expresses the same intent clearly.
- A shadow-DOM element is not found from the document: locate its host, get the shadow root, and search within that root; use Selenium 4 or greater for shadow-root finder methods.
- A nested lookup adds command overhead: where readability permits, express the relationship in one CSS or XPath locator rather than chaining searches.
Or skip the browser setup
If what you need is a screenshot rather than an automated interaction, ScreenshotNeo is a website screenshot API and MCP server for developers. Its API can return a screenshot or PDF from one GET request; it is not a replacement for Selenium locators or browser automation.
Example using cURL (replace the URL with the page you want to capture):
Quick Recap
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.
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
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 documentation for the API details. Cookie banners are accepted before capture and more than 60 known consent platforms, newsletter popups, and chat widgets can be removed; each step can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits cost nothing, and response headers report the page verdict and whether the shot was billed. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo free.
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.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →

