You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.
What steps will reproduce the problem?
The following code attempts to use the CSS 3 :nth-child selector but fails with a TestCSSParseException:
--------------------------------------------------------------------------------
public static void main(String[] args) {
WebDriver driver = new HtmlUnitDriver(true);
driver.get("http://www.google.com");
WebElement td;
// CSS 3 selector; currently fails with TestCSSParseException
td = driver.findElement(By.cssSelector("form[name='f'] td:nth-child(2)"));
// Ersatz demonstrating the correct behavior
td = driver.findElements(By.cssSelector("form[name='f'] td")).get(1);
System.out.println("Number of descendant <input> elements: " + td.findElements(
By.tagName("input")).size());
}
--------------------------------------------------------------------------------
What is the expected output? What do you see instead?
The above CSS 3 selector works fine when using, for example, document.querySelectorAll
in Firefox. WebDriver throws the following exception:
Exception in thread "main" com.steadystate.css.sac.TestCSSParseException: Error in
pseudo class or element. Invalid token "2". Was expecting one of: <S>, ")", <IDENT>.
at com.steadystate.css.parser.AbstractSACParser.toCSSParseException(AbstractSACParser.java:283)
at com.steadystate.css.parser.SACParserCSS21.pseudo(SACParserCSS21.java:1458)
at com.steadystate.css.parser.SACParserCSS21.simpleSelector(SACParserCSS21.java:1120)
at com.steadystate.css.parser.SACParserCSS21.selector(SACParserCSS21.java:1059)
at com.steadystate.css.parser.SACParserCSS21.selectorList(SACParserCSS21.java:1009)
at com.steadystate.css.parser.AbstractSACParser.parseSelectors(AbstractSACParser.java:380)
at com.steadystate.css.parser.CSSOMParser.parseSelectors(CSSOMParser.java:186)
at com.gargoylesoftware.htmlunit.html.HtmlPage.querySelectorAll(HtmlPage.java:2307)
at com.gargoylesoftware.htmlunit.html.HtmlPage.querySelector(HtmlPage.java:2332)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElementByCssSelector(HtmlUnitDriver.java:612)
at org.openqa.selenium.By$8.findElement(By.java:280)
at org.openqa.selenium.htmlunit.HtmlUnitDriver$4.call(HtmlUnitDriver.java:1133)
at org.openqa.selenium.htmlunit.HtmlUnitDriver$4.call(HtmlUnitDriver.java:1130)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.implicitlyWaitFor(HtmlUnitDriver.java:869)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:1130)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:330)
at test.HtmlUnitExample.main(HtmlUnitExample.java:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)
What version of the product are you using? On what operating system?
selenium-2.0b1; Windows XP SP3
Reported by beickhoff on 2011-02-14 20:09:40
The text was updated successfully, but these errors were encountered:
Originally reported on Google Code with ID 1298
Reported by
beickhoff
on 2011-02-14 20:09:40The text was updated successfully, but these errors were encountered: