Continuous Test Orchestration And Execution Platform Online

Perform automated and live-interactive testing on 3000+ real desktop and mobile devices online.

How can we get text on a web element using Selenium?

To get the text of a web element using Selenium, use the `WebElement` object's text Property. Here’s an example for the same:

from selenium import webdriver

# create a new Chrome browser instance
driver = webdriver.Chrome()

# navigate to a web page

# find an element by its CSS selector
element = driver.find_element_by_css_selector("#some-element")

# get the text of the element
text = element.text

# print the text

# close the browser

In this example, we first create a new Chrome browser instance using `webdriver.Chrome()`.Next, we navigate to a webpage using `driver.get()`. Then, we find an element on the page using `driver.find_element_by_css_selector()`, which takes a CSS selector as an argument. Finally, we get a text from that element by accessing its text property and printing it out before closing the browser with `driver.quit()`.


Test your websites, web-apps, or mobile apps seamlessly with LambdaTest.

Start Free Testing

Earn resume-worthy Selenium certifications that help you land a top job.

Learn More

Test your web or mobile apps

Test orchestration and execution cloud of 3000+ browsers and OS


24/7 support


Enterprise grade security


Fastest test execution cloud