
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 Text Using Selenium Web Driver in Python
We can get text using Selenium webdriver in Python. This is done with the help of a text method. It fetches the text in an element that can be later validated.
First, we need to identify the element with the help of any locators. Suppose we want to get the text - You are browsing the best resource for Online Education on the page below.
Example
Code Implementation.
from selenium import webdriver driver = webdriver.Chrome (executable_path="C:\chromedriver.exe") # maximize with maximize_window() driver.maximize_window() driver.get("https://www.tutorialspoint.com/index.htm") # identify element l=driver.find_element_by_css_selector("h4") # get text and print print("Text is: " + l.text) driver.close()
Output
Advertisements