- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
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 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
- Related Articles
- How to get text with selenium web driver in python?
- How to get userAgent information in Selenium Web driver?
- What is selenium web driver?
- What is Web Driver in Selenium?
- Difference between selenium RC and Web Driver?
- What is the Selenium Web Driver Architecture?
- Using Selenium Web Driver to retrieve value of a HTML input.
- How to run selenium (Firefox) web driver without a GUI?
- Which programming language is better for writing Selenium web driver scripts, Python or Java?
- How to use Selenium Web Driver and JavaScript to Login any website?
- How to get innerHTML of whole page in selenium driver?
- How to get the attribute value of a web element in Selenium (using Java or Python)?
- How do I pass options to the Selenium Chrome driver using Python?
- How to extract text from a web page using Selenium and save it as a text file?
- How to get the text from a website using selenium?

Advertisements