Mohit,
Please be a little more clear on what you expect and what you actually
get. The statement "above code is not working." is rather vague. I
created a web page with your HTML snippet in it. I used your code and
it output "text In this Price Range (around $17)". Did you get an
error? Did you get no output? Did you get the same output but expected
"text In this Price Range (around $17)"?
If you expected to see the in the output string then your
expectations were wrong. The getText() method never returns the
. It will always return a space.
If you want to see the source for the page, you'll have to use
driver.getPageSource(). When I was using Selenium 0.88 there were a
lot of things still missing. To get around this I would use
driver.getPageSource() then read the string into an HTML parser. I
could then query the tree for all <a> tags and write my own
getElementSource() to see what the source text was.
I can see how you want to be sure the source has certain special
characters (like  , & or "). This might be a good feature
request. Create an alternative to getText(). Call it getSrcText().
Darrell