Use Selenium’s tag-name locator with the HTML tag, without angle brackets. In Python, for example: driver.find_element(By.TAG_NAME, "a") finds one anchor element. Use the plural method, find_elements, when you need all matching elements.
Find an element by tag name
Pass the tag as a string to the tag-name locator. The tag must be the name used in the page’s HTML, such as a, input, button, or tr—not a value in angle brackets.
As an Amazon Associate I earn from qualifying purchases.
Python
from selenium.webdriver.common.by import By
element = driver.find_element(By.TAG_NAME, "a")
The current Selenium Python API reference also demonstrates locating a div with By.TAG_NAME.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC 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 & 11Java
WebElement element = driver.findElement(By.tagName("a"));
C#
driver.FindElement(By.TagName("a"));
Selenium’s locator documentation shows these language-specific forms. A tag-name locator matches the element type; it does not identify an element by its class, ID, text, or other attribute.
#1 Best Overall
Find all elements with a tag
Use the plural finder to collect all matching elements. For example, in Python:
inputs = driver.find_elements(By.TAG_NAME, "input")
for input_element in inputs:
print(input_element.get_attribute("type"))
The singular finder returns one matching element; the plural finder returns a collection. If no elements match, the plural finder returns an empty list rather than reporting a missing-element error. See Selenium’s documentation on finding elements.
Rank #2
Choose a locator that identifies the right element
Tag-name lookup is useful when the element type itself is what you need, or when you intentionally want a collection such as all links or inputs. It can be too broad for selecting one particular control: pages commonly contain many elements with the same tag. Selenium cautions that tag name can be a dangerous locator strategy.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problems- One specific element: Prefer a unique, consistently predictable ID when the page provides one. This is Selenium’s general locator guidance.
- A known section: Find the parent first, then search inside it to narrow the matches.
- Every element of a type: Use the plural finder and inspect the returned elements or apply further criteria.
For example, to find an input within a particular form in Python:
Rank #3
form = driver.find_element(By.ID, "contact-form")
email_input = form.find_element(By.TAG_NAME, "input")
Replace contact-form with the actual unique ID in your page. Selenium documents searching within a parent element as a way to scope a lookup: element finders and scoped searches.
Common problems and fixes
- No element found with the singular finder: Check that the tag exists in the current page and that you used its name without angle brackets. If the element is not present yet, wait for the page or relevant content to load before locating it.
- The plural finder returns an empty list: Selenium found no elements matching that tag at lookup time. Confirm the current page and tag, and account for content that loads dynamically.
- You get the wrong element: A tag-only locator may match several nodes. Use a unique ID or locate a known parent and search within it.
- A collection contains more elements than expected: That is normal when the tag is shared across the page. Inspect attributes or narrow the search context instead of assuming the first match is the intended one.
Or skip the browser setup
If your goal is a visual snapshot rather than interacting with page elements, ScreenshotNeo can return an image or PDF with one GET request. Its API accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and responses report the page verdict and billing status. Its MCP server provides screenshot and PDF tools for AI agents.
Example cURL request (replace YOUR_API_KEY with your key):
Rank #4
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. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Frequently Asked Questions
Does Selenium’s tag-name locator include angle brackets?
No. Pass the tag string, such as `”button”`, not `”
Quick Recap
Best Value
What does Selenium return when `find_elements` has no matches?
It returns an empty list.
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.




