Find Elements using CSS Selector throws "Illegal Value" webdriver exception

269 views
Skip to first unread message

webshore

unread,
Apr 4, 2012, 3:01:53 AM4/4/12
to webdriver
Hi all,

I was using selenium webdriver 2.19 (selenium java and selenium remote
driver)

When i am trying to find an element by CSSSelector i get below
exception.


org.openqa.selenium.WebDriverException: Illegal value
Command duration or timeout: 932.83 seconds
Build info: version: '2.19.0', revision: '15848', time: '2012-02-08
16:25:03'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version:
'6.1', java.version: '1.6.0_31'
Driver info: driver.version: RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:
39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:
27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:
170)
at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:
123)
at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:
439)
at
org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:
237)
at
org.openqa.selenium.remote.RemoteWebDriver.findElementsByCssSelector(RemoteWebDriver.java:
295)
at org.openqa.selenium.By$ByCssSelector.findElements(By.java:417)
at
org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:
214)


I can locate the element using selenium ide with the following command
css=.auto-test-searchquery-field

Except Cssselector i can find or manipulate the element with
classname , id etc. The only issue is with CSSSelector.

While debugging i saw "org.apache.http.NoHttpResponseException: The
target server failed to respond" at one of the files named
AbstractHttpMessage.java

I am not sure what this is. Could anyone please tell me how i can find
element with CSSSelector

darrell

unread,
Apr 5, 2012, 11:16:46 AM4/5/12
to webd...@googlegroups.com
It would have helped if you posted your code. Illegal value sounds like the string you are using for a CSS selector is illegal. If Selenium IDE finds the element with "css=.auto-test-searchquery-field" then the input for By.cssSelector() would be ".auto-test-searchquery-field". Full Java code would be:

    WebElement w = driver.findElement(By.cssSelector(".auto-test-searchquery-field"));

If you are passing it "css=.auto-test-searchquery-field" then Illegal value is correct.

Darrell
Reply all
Reply to author
Forward
0 new messages