Locators Strategies in Selenium Python are methods that are used to locate elements from the page and perform an operation on the same. Selenium’s Python Module is built to perform automated testing with Python. Selenium Python bindings provides a simple API to write functional/acceptance tests using Selenium WebDriver. After one has installed selenium and checked out – Navigating links using get method, one might want to play more with Selenium Python. After opening a page using selenium such as geeksforgeeks, one might want to click some buttons automatically or fill a form automatically or any such automated task. This article revolves around two strategies – Locating Single Elements and Location Multiple Elements.

Locator Strategies to locate single first elements
Selenium Python follows different locating strategies for elements. One can locate a element in 8 different ways. Here is a list of locating strategies for Selenium in python –
| Locators | Description |
|---|---|
| find_element_by_id | The first element with the id attribute value matching the location will be returned. |
| find_element_by_name | The first element with the name attribute value matching the location will be returned. |
| find_element_by_xpath | The first element with the xpath syntax matching the location will be returned. |
| find_element_by_link_text | The first element with the link text value matching the location will be returned. |
| find_element_by_partial_link_text | The first element with the partial link text value matching the location will be returned. |
| find_element_by_tag_name | The first element with the given tag name will be returned. |
| find_element_by_class_name | the first element with the matching class attribute name will be returned. |
| find_element_by_css_selector | The first element with the matching CSS selector will be returned. |
Locator Strategies to locate multiple elements
Selenium Python follows different locating strategies for elements. One can locate multiple elements in 8 different ways. Here is a list of locating strategies for Selenium in python –
| Locators | Description |
|---|---|
| find_elements_by_name | All elements with name attribute value matching the location will be returned. |
| find_elements_by_xpath | All elements with xpath syntax matching the location will be returned. |
| find_elements_by_link_text | All elements with link text value matching the location will be returned. |
| find_elements_by_partial_link_text | All elements with partial link text value matching the location will be returned. |
| find_elements_by_tag_name | All elements with given tag name will be returned. |
| find_elements_by_class_name | All elements with matching class attribute name will be returned. |
| find_elements_by_css_selector | All elements with matching CSS selector will be returned. |
Recommended Posts:
- Selenium Python Tricks
- Selenium Base Mini Project Using Python
- Python | SMS Bomber using Selenium
- Non blocking wait in selenium using Python
- Python | Automating Happy Birthday post on Facebook using Selenium
- How to access popup login window in selenium using Python
- Why do people prefer Selenium with Python?
- Like instagram pictures using Selenium | Python
- Python | Automate Google Search using Selenium
- How to install Selenium in Python
- Selenium Python Basics
- Python - Opening links using Selenium
- Flight-price checker using Python and Selenium
- How to take screenshot using Selenium in Python ?
- How to use close() and quit() method in Selenium Python ?
- How to get title of a webpage using Selenium in Python?
- How to get current_url using Selenium in Python?
- Python | page_source method in Selenium
- Python - find_element_by_id() method in Selenium
- Selenium Python Introduction and Installation
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

