Prerequisite:- Selenium
Selenium is a powerful tool for controlling web browsers through programs and performing browser automation. It is functional for all browsers, works on all major OS and its scripts are written in various languages i.e Python, Java, C#, etc, we will be working with Python.
In this article, we will learn how to know whether the text is on a web page or not using selenium in python.
Approach:
- First, we will open the chrome driver using the Chrome() method in the Selenium web driver
- Assign the Web URL.
- Then the driver will open the Given Web URL
- Get Web Page Source Code using page_source property.
- Assign the text to be searched.
- After getting the web page text, we will search whether the text is present or not.
Below is the implementation:
Python3
from selenium import webdriver
driver = webdriver.Chrome()
driver.get(url)
get_source = driver.page_source
search_text = "Floor"
print (search_text in get_source)
|
Output:
True
Demonstration:
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!