18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Junit xml

tower120tower120 Members
edited April 2011 in Sahi - Open Source
Hi!


I try to use sahi with hudson jenkins. In order to do this I need xml logs in out. I run my tests like this:

java -cp c:\sahi\lib\ant-sahi.jar net.sf.sahi.test.TestRunner -test "c:\sahi\userdata\scripts\oprint\bc_orderflow.sah" -browserType ie -baseURL http://test.optimalprint.com -threads 1 -junitLog true -htmlLog true -junitLogDir c:\www\temp\sahi-test\xml -htmlLogDir c:\www\temp\sahi-test\html

I get .xml on out, BUT hudson cant read it. This lines from hudson console log:
Recording test results
ERROR: Failed to archive test reports
hudson.util.IOException2: Failed to read /var/lib/jenkins/jobs/Sahi_tests_firefox_test/workspace/build/logs/TEST-bc_orderflow__26Apr2011__12_55_24.xml
    at hudson.tasks.junit.TestResult.parse(TestResult.java:215)
    at hudson.tasks.junit.TestResult.parse(TestResult.java:155)
    at hudson.tasks.junit.TestResult.<init>(TestResult.java:118)
    at hudson.tasks.junit.JUnitParser$ParseResultCallable.invoke(JUnitParser.java:114)
    at hudson.tasks.junit.JUnitParser$ParseResultCallable.invoke(JUnitParser.java:87)
    at hudson.FilePath.act(FilePath.java:756)
    at hudson.FilePath.act(FilePath.java:738)
    at hudson.tasks.junit.JUnitParser.parse(JUnitParser.java:83)
    at hudson.tasks.junit.JUnitResultArchiver.parse(JUnitResultArchiver.java:123)
    at hudson.tasks.junit.JUnitResultArchiver.perform(JUnitResultArchiver.java:135)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
    at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:649)
    at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:625)
    at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:603)
    at hudson.model.Build$RunnerImpl.post2(Build.java:161)
    at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:572)
    at hudson.model.Run.run(Run.java:1386)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:145)
Caused by: org.dom4j.DocumentException: Error on line 54 of document file:///var/lib/jenkins/jobs/Sahi_tests_firefox_test/workspace/build/logs/TEST-bc_orderflow__26Apr2011__12_55_24.xml : The value of attribute "name" associated with an element type "null" must not contain the '<' character. Nested exception: The value of attribute "name" associated with an element type "null" must not contain the '<' character.
    at org.dom4j.io.SAXReader.read(SAXReader.java:482)
    at org.dom4j.io.SAXReader.read(SAXReader.java:264)
    at hudson.tasks.junit.SuiteResult.parse(SuiteResult.java:101)
    at hudson.tasks.junit.TestResult.parse(TestResult.java:200)
    ... 19 more
Caused by: org.xml.sax.SAXParseException: The value of attribute "name" associated with an element type "null" must not contain the '<' character.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1414)
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanAttributeValue(XMLScanner.java:932)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanAttribute(XMLNSDocumentScannerImpl.java:460)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:277)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2755)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
    at org.dom4j.io.SAXReader.read(SAXReader.java:465)
    ... 22 more
Finished: FAILURE


And this is generated by sahi xml report:
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite errors="1" failures="0" name="bc_orderflow.sah" tests="44">
<testcase name="_navigateTo(&quot;http://test.optimalprint.net&quot;);"></testcase>
<testcase name="_sahi.setServerVar('___lastValue___1303818863718', _isVisible(_submit(&quot;Authenticate&quot;)));"></testcase>
<testcase name="_navigateTo(&quot;/en-US/&quot;);"></testcase>
<testcase name="_sahi.setServerVar('___lastValue___1303818864591', _exists(_byId(&quot;node_btn_logout&quot;)));"></testcase>
<testcase name="_click( _byId(&quot;signInLink&quot;) );"></testcase>
<testcase name="_click( _byId(&quot;email&quot;) );"></testcase>
<testcase name="_setValue( _byId(&quot;email&quot;), &quot;selenium1@test-mail.com&quot;);"></testcase>
<testcase name="_setValue( _byId(&quot;psw&quot;), &quot;selenium1&quot;);"></testcase>
<testcase name="_click( _link(0, _in( _byClassName(&quot;loginBoxBtn&quot;, &quot;div&quot;, _in( _byId(&quot;loginForm&quot;) ))) ));"></testcase>
<testcase name="_assertNotNull( _byId(&quot;node_btn_logout&quot;) );"></testcase>
<testcase name="_click( _link(&quot;tabCtrlBusiness&quot;) );"></testcase>
<testcase name="_click( _link(&quot;Business Cards[1]&quot;));"></testcase>
<testcase name="_click( _span(&quot;button blue&quot;) );"></testcase>
<testcase name="_click( _link(&quot;nodeSelectDesign0&quot;) );"></testcase>
<testcase name="Designer Text Test begins here."></testcase>
<testcase name="_log(&quot;Designer Text Test begins here.&quot;, &quot;info&quot;);"></testcase>
<testcase name="_wait(1000);"></testcase>
<testcase name="_sahi.setServerVar('___lastValue___1303818896213', _isVisible(_byId(&quot;popupImageLoaderWaiting&quot;)));"></testcase>
<testcase name="_wait(1000);"></testcase>
<testcase name="_sahi.setServerVar('___lastValue___1303818897415', _isVisible(_byId(&quot;preview_loading&quot;)));"></testcase>
<testcase name="_click( _link(0, _in(_byId(&quot;tab2&quot;))) );"></testcase>
<testcase name="_click( _div(&quot;add_text_button&quot;) );"></testcase>
<testcase name="Designer Text Edit begins here."></testcase>
<testcase name="_log(&quot;Designer Text Edit begins here.&quot;, &quot;info&quot;);"></testcase>
<testcase name="_doubleClick(_div(&quot;dd dt editable ui-draggable ui-resizable selected&quot;));"></testcase>
<testcase name="_rteWrite(_rte(&quot;text_editor_area_ifr&quot;), &quot;Selenium test text&quot;);"></testcase>
<testcase name="_click(_link(&quot;text_editor_area_fontsizeselect_text&quot;));"></testcase>
<testcase name="_click(_span(&quot;mceText[28]&quot;));"></testcase>
<testcase name="_click(_span(&quot;mceIcon mce_bold&quot;));"></testcase>
<testcase name="_click(_span(&quot;mceIcon mce_italic&quot;));"></testcase>
<testcase name="_click(_span(&quot;mceIcon mce_underline&quot;));"></testcase>
<testcase name="_click(_span(&quot;mceIcon mce_justifyleft&quot;));"></testcase>
<testcase name="_click(_span(&quot;mceIcon mce_justifycenter&quot;));"></testcase>
<testcase name="_click(_span(&quot;mceIcon mce_justifyright&quot;));"></testcase>
<testcase name="_click(_span(&quot;mceIcon mce_lineheight&quot;));"></testcase>
<testcase name="_click(_link(&quot;90%&quot;));"></testcase>
<testcase name="_click( _byId(&quot;apply_text_editor_changes_button&quot;) );"></testcase>
<testcase name="_dragDropXY(_div(&quot;dd dt editable ui-draggable ui-resizable selected&quot;), 40, 40, true);"></testcase>
<testcase name="Designer Image Test begins here."></testcase>
<testcase name="_log(&quot;Designer Image Test begins here.&quot;, &quot;info&quot;);"></testcase>
<testcase name="_click( _byId(&quot;add_image_button&quot;) );"></testcase>
<testcase name="_doubleClick(_table(&quot;start-InlineEditor start-InlineEditor-txt&quot;));"></testcase>
<testcase name="_click(    _link(0, _in(_byId(&quot;tabUploader&quot;))) );"></testcase>
<testcase name="_setFile(_file(&quot;picture_file_1&quot;), &quot;d:\\Images\\&quot;+&quot;sunrise.jpg&quot;, &quot;upload/file_from_swf?action=upload&quot;);
Error: File not found: d:\Images\sunrise.jpg; Base directory is userdata directory: C:\sahi\userdata
Error(&quot;File not found: d:\\Images\\sunrise.jpg; Base directory is userdata directory: C:\\sahi\\userdata&quot;)@:0
([object HTMLInputElement],&quot;d:\\Images\\sunrise.jpg&quot;,&quot;http://test.optimalprint.net/en-US/upload/file_from_swf&quot;)@http://test.optimalprint.net/_s_/spr/concat.js:987
()@http://test.optimalprint.net/_s_/spr/concat.js:2831
()@http://test.optimalprint.net/_s_/spr/concat.js:2831
@http://test.optimalprint.net/_s_/spr/concat.js:2643

<a href='/_s_/dyn/Log_getBrowserScript?href=C:\sahi\userdata\scripts\oprint\bc_orderflow.sah&n=987'><b>Click for browser script</b></a>
at uploadFile (scripts/oprint/lib/functions.sah:2)
">
<failure message="Assertion Failed"></failure>
</testcase>
</testsuite>

Please advise

Comments

  • And Is this possible that hudson count not test steps but number of tests? E.g. instead of 300 saw 2 in test trend (graph).
  • Hello tower120,

    This is not available in the current version.
    The next version of Sahi will produce XML test reports that can be viewed from Jenkins.

    Regards,
    dkulkarni
  • Ok, thanks.

    Waiting for it :)
  • SPSP Members
    Hi dkulkarni,

    Could you please tell me when we will be able to get the new version of Sahi with the above feature implemented. Will it be available with Sahi pro only or also along with Sahi?

    Regards,
    Sreejit P
  • SumitraSumitra Members
    Hi SP,

    The above features are available in the latest version of Sahi and Sahi pro.

    Regards
    Sumitra
  • Is this problem supposed to be fixed by now? I still see similar errors running the latest versions of Sahi and Hudson.

    Output in Hudsons console:
    ERROR: Failed to archive test reports
    hudson.util.IOException2: Failed to read /home/jenkins/.jenkins/jobs/sahi/workspace/build/logs/sahi/TEST-payment__20Sep2011__15_32_57.xml
        at hudson.tasks.junit.TestResult.parse(TestResult.java:215)
        at hudson.tasks.junit.TestResult.parse(TestResult.java:155)
        at hudson.tasks.junit.TestResult.<init>(TestResult.java:118)
        at hudson.tasks.junit.JUnitParser$ParseResultCallable.invoke(JUnitParser.java:114)
        at hudson.tasks.junit.JUnitParser$ParseResultCallable.invoke(JUnitParser.java:87)
        at hudson.FilePath.act(FilePath.java:756)
        at hudson.FilePath.act(FilePath.java:738)
        at hudson.tasks.junit.JUnitParser.parse(JUnitParser.java:83)
        at hudson.tasks.junit.JUnitResultArchiver.parse(JUnitResultArchiver.java:123)
        at hudson.tasks.junit.JUnitResultArchiver.perform(JUnitResultArchiver.java:135)
        at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
        at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:649)
        at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:625)
        at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:603)
        at hudson.model.Build$RunnerImpl.post2(Build.java:161)
        at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:572)
        at hudson.model.Run.run(Run.java:1386)
        at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
        at hudson.model.ResourceController.execute(ResourceController.java:88)
        at hudson.model.Executor.run(Executor.java:145)
    Caused by: org.dom4j.DocumentException: Error on line 19 of document file:///home/jenkins/.jenkins/jobs/sahi/workspace/build/logs/sahi/TEST-payment__20Sep2011__15_32_57.xml : The value of attribute "name" associated with an element type "testcase" must not contain the '<' character. Nested exception: The value of attribute "name" associated with an element type "testcase" must not contain the '<' character.
        at org.dom4j.io.SAXReader.read(SAXReader.java:482)
        at org.dom4j.io.SAXReader.read(SAXReader.java:264)
        at hudson.tasks.junit.SuiteResult.parse(SuiteResult.java:101)
        at hudson.tasks.junit.TestResult.parse(TestResult.java:200)
        ... 19 more
    Caused by: org.xml.sax.SAXParseException: The value of attribute "name" associated with an element type "testcase" must not contain the '<' character.
        at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
        at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
        at org.apache.xerces.impl.XMLScanner.scanAttributeValue(Unknown Source)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanAttribute(Unknown Source)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
        at org.dom4j.io.SAXReader.read(SAXReader.java:465)
        ... 22 more
    

    And the XML file generated by Sahi:
    <?xml version="1.0" encoding="UTF-8" ?>
    <testsuite errors="1" failures="0" name="payment.sah" tests="10">
    <testcase name="_click(_link('Home'));"></testcase>
    <testcase name="_setValue(_textbox(&quot;UserEmail&quot;), &quot;foo@bar.com&quot;);"></testcase>
    <testcase name="_click(_textbox(1, _near(_textbox(&quot;UserEmail&quot;))));"></testcase>
    <testcase name="_setValue(_password(&quot;UserPassword&quot;), &quot;test1234&quot;);"></testcase>
    <testcase name="_click(_link(&quot;Login&quot;));"></testcase>
    <testcase name="_click(_link(&quot;Account&quot;));"></testcase>
    <testcase name="_sahi.setServerVar('___lastValue___1316525564032', _getText(_strong(0, _in(_byId(&quot;profileBalance&quot;)))));"></testcase>
    <testcase name="_click(_link(&quot;Make payment&quot;));"></testcase>
    <testcase name="_wait(2000);"></testcase>
    <testcase name="_popup(&quot;insertPayment&quot;)._setSelected(_select(&quot;data[Payment][amount]&quot;), &quot;200&quot;);
    TypeError: el is undefined
    ((void 0),&quot;200&quot;)@http://bar.com/_s_/spr/concat.js:1098
    ()@http://bar.com/_s_/spr/concat.js:2822
    ()@http://bar.com/_s_/spr/concat.js:2822
    @http://bar.com/_s_/spr/concat.js:2634
    
    <a href='/_s_/dyn/Log_getBrowserScript?href=/home/jenkins/.jenkins/jobs/sahi/workspace/build/sahi/tests/payment.sah&n=1098'><b>Click for browser script</b></a>
    ">
    <failure message="Assertion Failed"></failure>
    </testcase>
    </testsuite>
    

    I know that I probably could fix the test that's causing the error to be thrown, but I think we should still be able to expect Sahi to produce valid XML.

    Please let me know if there is a way to fix this.

    Thanks in advandce!
  • Hi peterfarsinsen,

    The XML file which you have posted is for the Older version of Sahi.
    Jenkins integration is available since this build- SahiV3.5:2011-03-28

    Kindly try with the latest version of Sahi.

    Regards
    Sumitra
  • shamsham Members
    I have the latest Sahi version available.
    I added the following to testrunner.sh
    [-junitLog true -junitLogDir "/tmp/xmllog" ]

    I can see that the xml log is generated but the output contains only the testsuite name nothing else.

    <?xml version="1.0" encoding="UTF-8" ?>
    <testsuite errors="0" failures="0" name="disks_summary.sah.disks_summary" tests="1" time="83.75">
    <testcase classname="disks_summary.sah.disks_summary" name="disks_summary.sah" time="83.75">
    ....
    .....
    (Blank lines)
    ....
    </testcase></testsuite>

    Am i missing something or is there a bug?
  • shamsham Members
    Any updates on this guys?
    I'm really in need of knowing why even on the new version I'm not able to generate the needed output
Sign In or Register to comment.