Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Selenium Find Element by Name

I am using Python Selenium and am trying to select in input box that does not have an ID

<div class="form-group"><input type="email" class="form-control" name="quantity" placeholder="Type a quantity"></div>

inputElement = driver.find_element_by_id("quantity")

What is the best way to select this element, by name?

like image 528
fightstarr20 Avatar asked Feb 25 '16 16:02

fightstarr20


People also ask

What is find element by name in Selenium?

By.name Selenium locator is used to identify the elements of a webpage. This attribute can be mentioned as part of multiple tags like < input >, < button >, < select > etc. Unlike ID, this may or may not be unique to a page. A webpage may contain multiple tags with the same By.name attribute value.

How do I find element by tag name?

Selenium WebDriver's By class provides a tagName() method to find elements by their HTML tag name. This is similar to the getElementsByTagName() DOM method in JavaScript. This is used when you want to locate elements using their tag name, for example, locating all <tr> tags in a table.

How do I find an element in Python?

Python – find_element() method in Selenium In order to find element by “id” find_element() method is used. Id is basically unique attribute assigned to the elements of the web page such as buttons, image, heading etc. Note: The first element with the “id” attribute value matching the location will be returned.


1 Answers

find_element_by_name() method would fit here:

driver.find_element_by_name("quantity")
like image 143
alecxe Avatar answered Oct 11 '22 19:10

alecxe