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

14 Replies, 1187 Views

Pro tip: Avoid relying *only* on text for selenium locators to find particular text. Combine it with other attributes!

Like:
`//button[contains(@class, 'submit') and contains(text(), 'Login')]`

Way more stable than just text matching.

For debugging, Selenium IDE (Firefox/Chrome) can record actions and show what locators it picks. Not perfect, but helps!

Messages In This Thread



Users browsing this thread: 1 Guest(s)