What are the best Selenium locators to find particular text on a webpage? or How can I use Selenium l

14 Replies, 1334 Views

Honestly, looping through elements and checking `.text` is underrated.

XPath/CSS can break if the DOM changes even slightly. With Python, something like:

```python
elements = driver.find_elements(By.XPATH, "//*")
target = [el for el in elements if "your_text" in el.text]
```

Slower? Maybe. But way more reliable for tricky cases where selenium locators to find particular text fail.

Messages In This Thread



Users browsing this thread: 1 Guest(s)