Status: New
Owner: ----
Labels: Type-Defect Priority-Medium Status-Untriaged
New issue 4572 by
tecdocp...@gmail.com: PatternSyntaxException during
publish of Selenium test results
http://code.google.com/p/selenium/issues/detail?id=4572
During an Jenkins job, Selenium html tests are executed with the Jenkins
SeleniumHQ plugin.
The HTML tests itself run smoothly, but when it comes to the step of
publishing the results to the given html file, an PatternSyntaxException
occurs.
The exception occurs, if the path of the test case, which should be
referenced by the result file contains the pattern \E. In may case, the
path was:
c:\selenium\derby\internal\application\store\E358B9DE5B7B6F19C91F1126B5F42F8CCC6F3AF9\test/DeleteRecordsTestCase.html
So the resulting regexpattern within the java class
org.openqa.selenium.server.htmlrunner.HTMLSuiteResult is:
\Qfile:///c:\selenium\derby\internal\application\store\E358B9DE5B7B6F19C91F1126B5F42F8CCC6F3AF9\test/DeleteRecordsTestCase.html\E
There are two quoting pattrns \E and this results in the following
exception:
09:45:19.893 WARN - POST /selenium-server/postResults HTTP/1.1
java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence
near index 135
\Qfile:///c:\selenium\derby\internal\application\store\E358B9DE5B7B6F19C91F1126B5F42F8CCC6F3AF9\test/DeleteRecordsTestCase.html\E
^
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.escape(Unknown Source)
at java.util.regex.Pattern.atom(Unknown Source)
at java.util.regex.Pattern.sequence(Unknown Source)
at java.util.regex.Pattern.expr(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.<init>(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.lang.String.replaceFirst(Unknown Source)
at
org.openqa.selenium.server.htmlrunner.HTMLSuiteResult.<init>(HTMLSuiteResult.java:60)
at
org.openqa.selenium.server.htmlrunner.HTMLTestResults.<init>(HTMLTestResults.java:124)
at
org.openqa.selenium.server.htmlrunner.SeleniumHTMLRunnerResultsHandler.handle(SeleniumHTMLRunnerResultsHandler.java:88)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1526)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1479)
at org.openqa.jetty.http.HttpServer.service(HttpServer.java:914)
at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
at
org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
at
org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:357)
at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Currently used:
Windows Server 2008 R2
Jenkins CI 1.478
Selenium Server Standalon Jar 2.25.0
To reproduce the problem:
Place the html test file in a location including the pattern \E, for
example C:\selenium\ExtendedOptions\test.html. In my case, the path entry
was generated by java.io.File.getParent() which returns the path as String
with backslashes.
Suggestion to fix the bug:
Either use Pattern#quote, or the more efficient String#indexOf/substring to
replace the pattern.