Kevin's suggestion is correct, you can use XPath to match by text in an
element. I would highly suggest that route because:
WebDriver has deviated from Selenium RC in what you'd expect for CSS
locator support. It now uses native browser CSS support rather than Sizzle
library and falls back to it only on unsupported browsers (old IE8/9?). If
you want Sizzle, you have to inject it manually for use with WebDriver.
What's the issue with that? Native CSS support excludes the contains()
method, which is not an official CSS spec method. And that's the only way
to match by element text in CSS.
Eliza's suggestion of FirePath is also good. Using FirePath, you can test
out official CSS selectors using the CSS dropdown option for
finding/testing elements. Use the Sizzle drop down for testing unofficial +
official CSS selectors (like contains()). You'll see contains works under
Sizzle but fail under CSS in FirePath.
On Monday, November 5, 2012 1:01:12 PM UTC-8, Kevin O. wrote:
> Learning CSS selectors is on my to do list.
> For you second issue I'm fairly certain you can use XPath.
> Try xpath=//p[contains(text(), 'foobar')]