- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 the text from a website using selenium?
- How to check if multiple elements with same class exist using jQuery?
- How to get text with selenium web driver in python?
- Clear text from textarea with selenium.
- How to clear the text entered in Selenium with python?
- Can we define multiple methods in a class with the same name in Java?
- Get text using selenium web driver in python?
- Selenium and Python to find elements and text?
- How to get text from Selenium element WebElement object?
- How to get entered text from a textbox in selenium?
- Python – Elements with same index