find_elements in selenium python

This method is used to identify the WebElements of specific locators value,We can use all types of locators here. It gives a list object ,By using for loop we can iterate the loop to do required operation on it.

Syntax: ele = driver.find_elements(By.Locator_Type,"Locator_Value")
By Find Elements

Example: In the below example we will launch the webpage and get the list of all menu items using class name.

  


FindElementsBy.py

from selenium import webdriver
import time

from selenium.webdriver.common.by import By

driver = webdriver.Chrome("/Users/admin/Documents/Skill2Lead/drivers/chromedriver")

driver.get("http://www.dummypoint.com/seleniumtemplate.html")
time.sleep(2)

ele = driver.find_elements(By.CLASS_NAME,"breadcrumb-item")

for menu in ele:
    print(menu.text)

time.sleep(5)
driver.quit()