1

Hi I'm kind of new to selenium, so please bear with me if the question is too basic. I wanna access a date picker element and choose a specific date. I am trying to access the span element using both class and text inside. I get an error of invalid string. Is the syntax below correct?

_driver.FindElement(By.CssSelector("span[class='xxx'][contains(text(),'xx')]"))
2
  • I think contains() is deprecated...edit: yes it is, read: w3.org/TR/css3-selectors/#content-selectors Commented Jun 7, 2013 at 19:34
  • If you could post here your HTML element, then we could provide the exact CSS selector. Commented Jun 7, 2013 at 19:57

1 Answer 1

4

Looking at this cheatsheet

https://www.simple-talk.com/dotnet/.net-framework/xpath,-css,-dom-and-selenium-the-rosetta-stone/

I think it might be more like

_driver.FindElement(By.CssSelector("span.CCC:contains('TTT')"));

where CCC is your class name and TTT is the text your looking for.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.