find_element_by_name() method would fit here:
driver.find_element_by_name("quantity")
Answer from alecxe on Stack OverflowSelenium Python
selenium-python.readthedocs.io › locating-elements.html
4. Locating Elements — Selenium Python Bindings 2 documentation
find_element(By.ID, "id") find_element(By.NAME, "name") find_element(By.XPATH, "xpath") find_element(By.LINK_TEXT, "link text") find_element(By.PARTIAL_LINK_TEXT, "partial link text") find_element(By.TAG_NAME, "tag name") find_element(By.CLASS_NAME, "class name") find_element(By.CSS_SELECTOR, ...
Selenium
selenium.dev › documentation › webdriver › elements › finders
Finding web elements | Selenium
September 6, 2025 - In our example HTML above, there are two elements that have a class name of “tomatoes” so this method will return the element in the “vegetables” list. Move Code · Java · Python · CSharp · Ruby · JavaScript · Kotlin · WebElement vegetable = driver.findElement(By.className("tomatoes")); vegetable = driver.find_element(By.CLASS_NAME, "tomatoes") var vegetable = driver.FindElement(By.ClassName("tomatoes")); fruits = driver.find_element(id: 'fruits') fruits.find_element(class: 'tomatoes') View Complete Code View on GitHub ·
Selenium Python 2 find element by name and value? - Stack Overflow
I have been trying to locate an element on a web page, this element has the same name as other elements and no id. It does have a different value, so I would like to find the element by the name AN... More on stackoverflow.com
Finding Element by Name Attribute in Selenium Python - LambdaTest Community
How to find an element by its name attribute using Selenium in Python? Below is my HTML file and code where i am trying to get the attribute name More on community.lambdatest.com
Why does the driver.find_element_by_name() methode not work?
The reason why it's garbled like "YPqjbf" and not "this_readable_name" is because it's a dynamic value not meant to be used as a static reference. You should navigate through relational properties, eg each form segment is inside a role="listitem" div, then the form entry div is that div's only great grandchild with a jsaction property. More on reddit.com
Super new to selenium, Occuring an error while trying to find element by name
It says to use By, not by. More on reddit.com
Videos
01:46
Handling the webdriver object has no attribute find_element_by_name ...
2 | Interacting With Elements | Selenium Python
25:46
Selenium Webdriver with Python | Selenium Webdriver Tutorial | ...
#9 Selenium With Python | How to Find Element by Name ...
10:21
Selenium Python Tutorial #20 - FindElements | How to Find Elements ...
03:44
find_element_by_name() Command (Selenium Python - Session 55) - ...
Top answer 1 of 4
15
find_element_by_name() method would fit here:
driver.find_element_by_name("quantity")
2 of 4
9
In September 2022 with Selenium 4.4.0 the correct answer would be:
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Firefox()
inputElement = driver.find_element(by=By.NAME, value='quantity')
Readthedocs
selenium-python-test.readthedocs.io › en › latest › locating-elements.html
4. Locating Elements — Selenium Python Bindings 2 documentation
from selenium.webdriver.common.by import By driver.find_element(By.XPATH, '//button[text()="Some text"]') driver.find_elements(By.XPATH, '//button') ... ID = "id" XPATH = "xpath" LINK_TEXT = "link text" PARTIAL_LINK_TEXT = "partial link text" NAME = "name" TAG_NAME = "tag name" CLASS_NAME = "class name" CSS_SELECTOR = "css selector"
GitHub
iqss.github.io › dss-webscrape › finding-web-elements.html
4 Finding Web Elements | Web Scraping Using Selenium Python
Similar to XPath, Selenium can leverage and use CSS selectors to find elements on a web page. In our previous example, in which we wanted to get the search button on the example site, we can use the following selector, where the selector is defined as the element tag along with the class name. This will find an <input> element with the "btn-default" class name. We then test it by ...
Python Examples
pythonexamples.org › python-selenium-find-element-by-name
How to Find Element by Name in Selenium Python?
To find an HTML Element by name attribute using Selenium in Python, call find_element() method and pass By.NAME as the first argument, and the name attribute's value (of the HTML Element we need to find) as the second argument.
Top answer 1 of 4
8
Try this
//input[@name='action' and @value=' Search ']
2 of 4
4
Answering your questions,
1 - Yes you can,
driver.find_element_by_name(‘foo’)
http://selenium-python.readthedocs.org/en/latest/api.html#selenium.webdriver.remote.webdriver.WebDriver.find_element_by_name
2 - I always try to avoid xpath because sometimes it doesn't work properly. Instead, you should always try to find by name or id .. I think is the best case.
Selenium
selenium.dev › blog › 2022 › python-locators-se4
Locate your locators - Python bindings changes upcoming | Selenium
August 9, 2022 - If you’re really desperate however you can use strings instead of the By object: driver.find_element('id', "submit_button").click() driver.find_element('css selector', '.myelement child').text · If you have any plans to upgrade your Selenium client for your Python tests to recent versions of Selenium 4, definitely keep these changes in mind.
Python Basics
pythonbasics.org › selenium-find-element
selenium find element by id - Python Tutorial
The Python code below uses selenium to find al the list items, li, on a webpage. Selenium can find an element by name instead of code.
Katalon
katalon.com › blog › insights › find elements in selenium with python: a complete guide
Find Elements in Selenium with Python: A Complete Guide
February 5, 2026 - Mastering element identification in Selenium with Python is foundational for building robust and reliable web automation. By effectively employing a variety of locator strategies and adhering to best practices for stable test execution, teams ensure precise and consistent interactions with web elements, leading to more resilient and efficient automated tests. Employ Diverse Locator Strategies: Utilize `By.ID`, `By.NAME`, `By.CLASS_NAME`, `By.TAG_NAME`, `By.LINK_TEXT`, `By.PARTIAL_LINK_TEXT`, `By.CSS_SELECTOR`, and `By.XPATH` to accurately pinpoint web elements based on their attributes and DOM structure for comprehensive discovery and interaction.
Endtest
endtest.io › blog › a-practical-guide-for-finding-elements-with-selenium
A practical Guide for Finding Elements with Selenium | Finding elements in Selenium can be tricky, here is practical guide to finding them and a comparison with Endtest. | Endtest
username = driver.find_element_by_class_name("form-control") This means that the you won't be able to locate that Username input with the Class Name locator type, since Selenium will throw an error.
LambdaTest
lambdatest.com › blog › how-to-use-name-locator-in-selenium-automation-scripts
How To Use Name Locator In Selenium Automation Scripts? | LambdaTest
April 15, 2024 - A key point to note is when you tend to select an element with a desired name attribute value, it will select the first element it encounters. You may come across another scenario, where you wish to select elements with the same name attribute value, in this case, the By.name locator in Selenium may work using the findElements syntax.
Apify
blog.apify.com › selenium-find-elements
Python guide: Selenium element locators
May 26, 2025 - In this syntax, By.locator_strategy specifies the method for locating the element (such as ID, class name, or XPath). Selenium provides several built-in locator strategies, including: ... Also, the locator strategy requires a locator value to uniquely identify the web element. Now, if you want to use ID as the locator strategy to identify an element, you would write: ... As you can see, ID is the locator strategy, and "elementId" is the locator value, which you can find by inspecting the HTML of the webpage and locating the id attribute of the target element.