HtmlUnitDriver ScriptException: No group 2

466 views
Skip to first unread message

Jeff

unread,
Jan 5, 2011, 2:28:39 PM1/5/11
to webd...@googlegroups.com
I'm running Selenium-2.0b1 and getting the exception below on my first open() call after instantiating the HtmlUnitDriver.  This specific error does not return any results in a Google Search.  Any idea what the problem/workaround might be?
 
Jan 5, 2011 12:14:57 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'text/javascript'.
[SmokeTestWD.testSignIn] Exception: org.openqa.selenium.WebDriverException: com.gargoylesoftware.htmlunit.ScriptException: No group 2
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_23'
Driver info: driver.version: HtmlUnitDriver
 
Here is the stack trace:
 
Driver info: driver.version: HtmlUnitDriver
        at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:294)
        at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:275)
        at org.openqa.selenium.internal.seleniumemulation.Open.handleSeleneseCommand(Open.java:36)
        at org.openqa.selenium.internal.seleniumemulation.Open.handleSeleneseCommand(Open.java:22)
        at org.openqa.selenium.internal.seleniumemulation.SeleneseCommand.apply(SeleneseCommand.java:30)
        at org.openqa.selenium.internal.seleniumemulation.Timer.run(Timer.java:61)
        at org.openqa.selenium.WebDriverCommandProcessor.execute(WebDriverCommandProcessor.java:272)
        at org.openqa.selenium.WebDriverCommandProcessor.doCommand(WebDriverCommandProcessor.java:202)
        at com.thoughtworks.selenium.DefaultSelenium.open(DefaultSelenium.java:353)
        at org.familysearch.seleniumtestmaven.SmokeTestWD.testSignIn(SmokeTestWD.java:142)
        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 org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:640)
  ...
Caused by: com.gargoylesoftware.htmlunit.ScriptException: No group 2
        at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:601)
        at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:537)
        at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:538)
        at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.compile(JavaScriptEngine.java:456)
        at com.gargoylesoftware.htmlunit.html.HtmlPage.loadJavaScriptFromUrl(HtmlPage.java:1047)
        at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:959)
        at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:363)
        at com.gargoylesoftware.htmlunit.html.HtmlScript$1.execute(HtmlScript.java:225)
        at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:245)
        at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:578)
      ...
Caused by: java.lang.IndexOutOfBoundsException: No group 2
        at java.util.regex.Matcher.group(Matcher.java:470)
        at java.util.regex.Matcher.appendReplacement(Matcher.java:737)
        at com.gargoylesoftware.htmlunit.javascript.IEConditionalCompilationScriptPreProcessor.replaceCompilationVariables(IEConditionalCompilationScriptPreProcessor.java:161)
        at com.gargoylesoftware.htmlunit.javascript.IEConditionalCompilationScriptPreProcessor.processConditionalCompilation(IEConditionalCompilationScriptPreProcessor.java:100)
        at com.gargoylesoftware.htmlunit.javascript.IEConditionalCompilationScriptPreProcessor.preProcess(IEConditionalCompilationScriptPreProcessor.java:72)
        at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory$TimeoutContext.compileString(HtmlUnitContextFactory.java:170)
        at net.sourceforge.htmlunit.corejs.javascript.Context.compileString(Context.java:1372)
        at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$2.doRun(JavaScriptEngine.java:447)
        at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:595)
        ... 62 more

--
Jeff Vincent
preda...@gmail.com
See my LinkedIn profile at:
http://www.linkedin.com/in/rjeffreyvincent

Simon Stewart

unread,
Jan 6, 2011, 5:42:16 AM1/6/11
to webd...@googlegroups.com
So there appears to be an HtmlUnit issue, caused in the IE emulation
(that root cause of an IndexOutOfBoundsException) A quick delve into
the htmlunit source[1] suggests that it's doing some variable
interpolation at this point. I'd say that it's choking on something
that it's mistaking for IE-specific JS. There are two ways round this:
either find the offending code and fix that, or try using the
HtmlUnitDriver emulating Firefox. That is done like so:

DesiredCapabilities caps = DesiredCapabilities.firefox();
caps.setJavascriptEnabled(true);
WebDriver driver = new HtmlUnitDriver(caps);

I'd also suggest finding a reduced test case and emailing the HtmlUnit
dev team. They're always very quick at responding to comments and
bugs.

Regards,

Simon

http://www.google.com/codesearch/p?hl=en#4NGKQmSIPgg/trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/IEConditionalCompilationScriptPreProcessor.java&q=IEConditionalCompilationScriptPreProcessor&exact_package=http://htmlunit.svn.sourceforge.net/svnroot/htmlunit&sa=N&cd=1&ct=rc

> --
> You received this message because you are subscribed to the Google Groups
> "webdriver" group.
> To post to this group, send email to webd...@googlegroups.com.
> To unsubscribe from this group, send email to
> webdriver+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/webdriver?hl=en.
>

Reply all
Reply to author
Forward
0 new messages