Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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')]"))
share|improve this question
    
I think contains() is deprecated...edit: yes it is, read: w3.org/TR/css3-selectors/#content-selectors –  stackErr Jun 7 '13 at 19:34
    
If you could post here your HTML element, then we could provide the exact CSS selector. –  LINGS Jun 7 '13 at 19:57

1 Answer 1

up vote 4 down vote accepted

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.

share|improve this answer
    
Thanks for your help. I got it working. –  Charan Jun 7 '13 at 21:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.