← Back to team overview

sikuli-driver team mailing list archive

[Question #276333]: How to modify and get an error output with (XMLTestRunner) using exists()

 

New question #276333 on Sikuli:
https://answers.launchpad.net/sikuli/+question/276333

Hi! :)

First of all, here is a simplified example of the code Im doing.

#import xmltestrunner

class SikuliTest(unittest.TestCase):
    def setUp(self):
        #setUp

    def testSikuliTest(self):
            find("logo.png")
            click("next-button.png")
            find("exit-button.png")
            find("agree-button.png")
            click("next-button.png")

    def tearDown(self):
        #tearDown


I have two problems that I havent been able to solve, Ive read through the Sikuli documentation but I havent been able to find() anything that would explain the following things:

1. Normally, when using find(), the script stops if the image isnt found and XMLTestRunner outputs the error into the XML log. Is it possible to NOT stop the script if find() fails but still report the fact that the find failed to XMLTestRunner log? I managed to do something, where the script kept running even when find() fails by using setFindFailedResponse(SKIP) but then no errors were reported to XMLTestRunner log. Perhaps this could be done with exists() but I have the same problem with it too, no log appears when using exists(). So my question is, how does one continue running the script even when find() fails and still get the error of the failure to the XML log? With exists() the running of the script even when it fails can be done, but getting the error is impossible for me.

This is the XML log when find() fails. How would I get the same errors to the log, while still continuing to run the script? (The second question is related to the log too):

<testsuite errors="1" failures="0" name="unittest.suite.TestSuite" tests="1" time="3.143">
  <testcase classname="__main__.SikuliTest" name="testSikuliTest" time="3.1410">
    <error type="org.sikuli.script.FindFailed">FindFailed: can not find logo.png in R[0,0 1680x945]@S(0)
  Line 2189, in file Region.java

  File "/Sikuli/sikulix.jar/Lib/unittest/case.py", line 332, in run
    testMethod()
  File "/Sikuli/SikuliScript.sikuli/SikuliScript.py", line 8, in testSikuliTest
    find("logo.png")
    </error>
  </testcase>
  <system-out><![CDATA[]]></system-out>
  <system-err><![CDATA[]]></system-err>
</testsuite>

2. So when Ive finally figured out the answer to question one, or someone smarter than me has figured it out then another problem arises. How do I modify the format that the error is in? Right now, it goes into the XML log like this:

FindFailed: can not find logo.png in R[0,0 1680x945]@S(0)
  Line 2189, in file Region.java

  File "/Sikuli/sikulix.jar/Lib/unittest/case.py", line 332, in run
    testMethod()
  File "/Sikuli/SikuliScript.sikuli/SikuliScript.py", line 8, in testSikuliTest
    find("logo.png")

How would I go on about modifying how the error goes into XMLTestRunner? For instance, if I wanted it to be in a more simple form (example here):

FindFailed: Find("logo.png") could not be found at SikuliScript.py in line 8.

So this is what Im aiming to do:

Either use exists() in a way that it outputs an error to the XML log and continues running the script even if whatever picture doesnt exist, or find a way to use find() in a way so that it doesnt stop running the script when a find() fails, yet it would still output the error to the XML log and continue running the script and collecting more errors.

Thank you in advance, I really appreciate the work you guys are doing on this magnificient tool! :)




-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.