🌐
Selenium Python
selenium-python.readthedocs.io › locating-elements.html
4. Locating Elements — Selenium Python Bindings 2 documentation
from selenium.webdriver.common.by import By driver.find_element(By.XPATH, '//button[text()="Some text"]') driver.find_elements(By.XPATH, '//button')
Discussions

How to get text with Selenium WebDriver in Python - Stack Overflow
I'm trying to get text using Selenium WebDriver and here is my code. Please note that I don't want to use XPath, because in my case the ID gets changed on every relaunch of the web page. My code: t... More on stackoverflow.com
🌐 stackoverflow.com
Selenium -Python object identification issue
Instead of targeting the image element, try clicking its parent anchor. For example, using the anchor’s title attribute (which appears to be static) can work better: from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC # Wait until the anchor is clickable invoice_box = WebDriverWait(driver, 10).until( EC.element_to_be_clickable((By.CSS_SELECTOR, "a[title='Selected : Recent']")) ) invoice_box.click() More on reddit.com
🌐 r/learnpython
8
3
November 2, 2024
How to search for text in selenium

You can use XPath (code uses lxml.html)

>>> doc.xpath('//h1[text() = "AS Law"]')
[<Element h1 at 0x1075308f0>]

In selenium the method has a different name:

https://selenium-python.readthedocs.io/locating-elements.html#locating-by-xpath

More on reddit.com
🌐 r/learnpython
3
1
November 11, 2019
Selenium: find element by text

link_text references the href of a link. You are looking for the inner text of a tag:

browser.find_elements_by_xpath("//*[contains(text(), 'TEXTO')]")

More on reddit.com
🌐 r/learnpython
4
1
September 3, 2016
🌐
BrowserStack
browserstack.com › home › guide › how to find elements by text in selenium with python
How to Find Elements by Text in Selenium with Python | BrowserStack
March 20, 2025 - Finding elements by text in Selenium Python using text() and contains() methods is a powerful technique for locating web elements based on their visible content.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-selenium-find-element-by-text
Python Selenium - Find element by text - GeeksforGeeks
July 23, 2025 - # Python Program to find element by text #import webdriver from selenium import webdriver #import time from time import sleep # create webdriver object driver = webdriver.Chrome( executable_path="C:\selenium\chromedriver_win32\chromedriver.exe") # get the website driver.get("https://travelcin.wordpress.com/author/vinayakking/") # sleep for some time sleep(3) # get element through text driver.find_element_by_xpath("// a[contains(text(),\ '5 CHEAP HOLIDAY')]").click() # sleep for some time sleep(4)
🌐
BrowserStack
browserstack.com › home › guide › how to find element by text using xpath selenium: example
How to Find Element by Text using Xpath Selenium: Example | BrowserStack
December 31, 2024 - text(): A built-in method in Selenium WebDriver that is used with XPath locator to locate an element based on its exact text value.
🌐
BrowserStack
browserstack.com › home › guide › how to get text of an element in selenium
How to Get Text of an Element in Selenium: Tutorial | BrowserStack
December 19, 2025 - import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import io.github.bonigarcia.wdm.WebDriverManager; import org.openqa.selenium.chrome.ChromeDriver; import java.time.Duration; public class Test{ public static void main(String[] args) { WebDriverManager.chromedriver().setup(); WebDriver driver = new ChromeDriver(); String url = "https:/browserstack.com”; driver.get(url); driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(20)); // Locating the element WebElement e = driver.findElement(By.id("signupModalButton")); //using getText method the retrieve the text of the element System.out.println(e.getText()); driver.quit(); } } ... This Python snippet shows how to find and assert the text of the Get started free button with Selenium WebDriver.
Find elsewhere
🌐
Proxyway
proxyway.com › knowledge base › how to find element by text using selenium
How to find element by text using Selenium - Proxyway
July 3, 2024 - It finds any element within the page, the text of which contains a stock string. NOTE: We’re using the driver.find_element() function to only get the first element found by the selector.
🌐
Prospera Soft
prosperasoft.com › blog › testing › selenium › selenium-find-text-python
Find Elements by Text in Selenium WebDriver (Python)
Increases test reliability by targeting visible text. Reduces dependency on complex locators. Enhances readability of your test scripts. One of the most efficient ways to find elements containing specific text in Selenium WebDriver using Python is through the `xpath` selector.
🌐
Luasoftware
code.luasoftware.com › tutorials › selenium › find-element-by-text-with-selenium-python
Find Element By Text With Selenium Python
selenium · python · Find element with extact text match. el = driver.find_element_by_xpath("//*[text()='Exact Match']") Fine element with partial text match. el = driver.find_element_by_xpath("//*[contains(text(), 'Partial Match')]") ❤️ Is this article helpful?
🌐
Edureka Community
edureka.co › home › community › categories › selenium › how do i find an element that contains specific...
How do I find an element that contains specific text in Selenium WebDriver Python | Edureka Community
November 27, 2020 - I'm trying to test a complicated JavaScript interface with Selenium (using the Python interface, ... really slow, at least using the Chrome webdriver
🌐
Oxylabs
oxylabs.io › blog › selenium-find-element
How to Find Elements With Selenium in Python
In this article, we’ll try to ... off, Selenium offers us two ways of locating web elements inside of pages: findElement and findElements. Finds and returns the first element by the provided locator....
🌐
GeeksforGeeks
geeksforgeeks.org › python › find-an-element-that-contains-specific-text-in-python-selenium
Find an element that Contains Specific Text in Python Selenium - GeeksforGeeks
July 23, 2025 - XPath, which stands for XML Path Language, is a versatile method that can be used to navigate and find elements in both XML and HTML documents. In Selenium, we can use XPath to search for elements that contain specific text.
🌐
Python Examples
pythonexamples.org › python-selenium-element-text
Get text content of element in Selenium
In the following program, we initialize a driver, then load the URL, find the element with id="child2", and get its text content using text attribute. from selenium import webdriver from selenium.webdriver.chrome.service import Service as ChromeService from webdriver_manager.chrome import ...
🌐
Selenium
selenium.dev › documentation › webdriver › elements › finders
Finding web elements | Selenium
September 6, 2025 - Python · CSharp · Ruby · JavaScript · Kotlin · List<WebElement> elements = driver.findElements(By.tagName("li")); for (WebElement element : elements) { System.out.println("Paragraph text:" + element.getText()); } from selenium import webdriver ...
🌐
WebScraping.AI
webscraping.ai › faq › selenium-webdriver › how-do-i-retrieve-text-from-a-specific-element-using-selenium-webdriver
How do I retrieve text from a specific element using Selenium WebDriver? | WebScraping.AI
from selenium import webdriver from selenium.webdriver.common.by import By driver = webdriver.Chrome() driver.get("https://example.com") # Different ways to locate elements strategies = [ (By.ID, "main-content"), (By.CLASS_NAME, "article-text"), (By.TAG_NAME, "h1"), (By.CSS_SELECTOR, ".content p"), (By.XPATH, "//div[@class='description']"), (By.LINK_TEXT, "Read More"), (By.PARTIAL_LINK_TEXT, "More") ] for locator_type, locator_value in strategies: try: element = driver.find_element(locator_type, locator_value) text = element.text print(f"{locator_type}: {text[:50]}...") except Exception as e: print(f"Element not found with {locator_type}: {locator_value}") driver.quit()
🌐
Software Testing Help
softwaretestinghelp.com › home › selenium automation › selenium find element by text tutorial with examples
Selenium Find Element By Text Tutorial with Examples
April 1, 2025 - Using text method of selenium web driver, find the web element with text – Write and Earn. Validate if the selected element is displayed on the web page. If it is displayed, print the text as Element found using text.
🌐
TutorialsPoint
tutorialspoint.com › selenium-and-python-to-find-elements-and-text
Selenium and Python to find elements and text?
October 26, 2020 - We can find elements and its text with Selenium webdriver. First of all we have to identify the element with the help of any of the locators like id, classname, css and so on. Then to obtain the text we have to take the help of the text method. s = driver.find_element_by_css_selector("h4").text
🌐
TechBeamers
techbeamers.com › locate-elements-selenium-python
Python Selenium Locate Elements - TechBeamers
November 30, 2025 - Here is another coding snippet showcasing the <find_element_by_link_text> method. The below code opens Google in the browser and performs a text search. After that, it opens a Hyperlink with link text as “Python Tutorial.” · from selenium ...