Re: Selenium SafariDriver can't detect specified css selectors

520 views
Skip to first unread message

David

unread,
Jul 5, 2012, 1:31:14 PM7/5/12
to seleniu...@googlegroups.com
Interesting topic. I wonder if there are still, in WebDriver, browser differences in detecting elements (by CSS, XPath, ID, name) as there were in Selenium RC (one CSS/XPath expression may work in one browser but not another, etc.).

Also, in Selenium RC, all the browsers used the Sizzle library for CSS. With WebDriver, browsers natively use its own engine for CSS selectors, except where there is no such support (e.g. IE) where it falls back to Sizzle. So I assume SafariDriver is using Safari's native CSS selector implementation?

Would be interesting to see if you inject Sizzle and then use that to find the CSS selector whether that would work or not.

http://selenium.polteq.com/en/injecting-the-sizzle-css-selector-library/ 

On Thursday, July 5, 2012 5:07:09 AM UTC-7, Pereter wrote:
I'm using 2.24 WebDriver to navigate trough Safari Browser.
I use FindElement(By.CssSelector....) 
It's all right whe I use  "#lzero-personal-form"  but when i'm trying to access element like "#lzero-personal-form .form-inner", I receiving  an error like: 
Could not find element: {"id":":wdc:1341489759957","using":"id","value":"#lzero-personal-form .form-inner"}

It fully works in FireFox. 
What can be a problem?
Do I need to use special css selectors for Safari?

ankit

unread,
Jul 5, 2012, 1:49:45 PM7/5/12
to seleniu...@googlegroups.com
Yeah I've had some run ins with this problem too. Like David said, this happens because WebDriver uses native CSS selectors for browsers that support them, and Sizzle as a fallback for those that don't. So when you're working across different browsers that support CSS natively, you'll be subject to their idiosyncrasies in how they handle CSS selectors. For consistency, I've found the best option is to include jQuery and use executeScript() to find elements using jQuery selectors.

I initally thought this was a bug and opened this issue for it, you can see the devs feedback over there.
Reply all
Reply to author
Forward
0 new messages