- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get the text from multiple elements with the same class in Selenium for Python?
We can get text from multiple elements with the same class in Selenium webdriver. We have to use find_elements_by_xpath(), find_elements_by_class_name() or find_elements_by_css_selector() method which returns a list of all matching elements.
Next we shall get the size of the list with len method. We shall iterate through this list and obtain the text with text method.
from selenium import webdriver driver = webdriver.Chrome (executable_path="C:\chromedriver.exe") # maximize with maximize_window() driver.maximize_window() driver.get("https://www.justdial.com/Bangalore/Bakeries") # identify elements of same classname l=driver.find_elements_by_class_name("store-name") # iterate through list and get text for i in l: print("Store names:"+ i.text) driver.close()
- How to identify multiple elements at the same time in Selenium with python?
- How to print text from a list of all web elements with same class name in Selenium?
- How to get text with selenium web driver in python?
- How to get the text from a website using selenium?
- Get text using selenium web driver in python?
- Selenium and Python to find elements and text?
- How to clear the text entered in Selenium with python?
- Clear text from textarea with selenium.
- How to get entered text from a textbox in selenium?
- How to get text from Selenium element WebElement object?
- Can we define multiple methods in a class with the same name in Java?
- How can I get the href of elements found by partial link text using Selenium?