Selenium: 8 Ways to Locate Elements

By positioning
Using Selenium’s BY positioning, you first need to import the module

from selenium.webdriver.common.by import By

id attribute locates find_element(By.ID, "id")
name attribute locate find_element(By.NAME, "name")
classname attribute locate find_element(By.CLASS_NAME, "claname")
a tag text attribute locationfind_element(By.LINK_TEXT, "text")
a tag partial text attribute locationfind_element(By.PARTIAL_LINK_TEXT, "partailtext")
tag_name locate-find_elemnt(By.TAG_NAME, "input")
xpath path positioning-find_element(By.XPATH,"//div[@name='name']")
css selector positioningfind_element(By.CSS_SELECTOR, "#id")

Read More: