TestProject Forum
Powered by leading experts in the test automation community

Selenium find exact text using CSS locator

How would i get an exact match on text using CSS selector ?

For instance if i’d use xPath it would be //p[text()=‘Lorem ipsum’]

Try these:

css=p[text='Lorem ipsum'] p[innertext='Lorem ipsum']

Try also

css=p:contains("^Lorem ipsum$")