How to get the test reports after running the sikuli scripts

Asked by naveen

How to get the test reports after running the sikuli scripts

I need the test tesults after ruuning the sikuli scripts like true or false

Can u tell me the answer pls

Thanks in advance
Naveen

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
naveen
Solved:
Last query:
Last reply:
Revision history for this message
nupur (nupur) said :
#1

Hi Naveen,

If you are using unittest method then u can implement HTMLTest Runner to get the reports.

or

You can implement robot framework. This one provides better reporting.

Regards
Nupur

Revision history for this message
naveen (mopuramnaveen) said :
#2

I am written below unit test code by using sikuli,can u tell me how to use the HTML Test runner
def setUp(self):

    find("1349761887724.png")
    type("1349762096056.png", "guest")

    type("1349761905053.png", "guest")

    click("1349761920585.png")
    sleep(5)
    click("DeviceManaqe.png")
    sleep(1)

    click("1349778804849.png")

    sleep(2)
def testA(self):

    click("1349778804849.png")

   click("iii.png")

    if exists("1349763413310.png"):
        popup("Fail:Device is not deleted")
    else:
        popup("Pass:Device is deleted")
def tearDown(self):
    popup("test case excuted")

If u dont mine can u tell me how to use the HTML Test Runner

Revision history for this message
nupur (nupur) said :
#3

first of all, download HTMLTestRunner.py file and placed it in your Sikuli script folder.

--script--

from sikuli import *
import unittest
import HTMLTestRunner

Class ClassName(unittest.TestCase):
# paste your script

suite = unittest.TestLoader().loadTestsFromTestCase(ClassName)
outfile = open("C:\\Sikuli\\Reports\\report.html", "w") # path to report folder
runner = HTMLTestRunner.HTMLTestRunner(stream=outfile, title=' Report Title', description='desc..' )
runner.run(suite)

Revision history for this message
naveen (mopuramnaveen) said :
#4

I written below like this ,but my script was not running

from sikuli import *
import unittest
import HTMLTestRunner
class channel(unittest.Testcase):
def setUp(self):
    doubleClick("wu.png")
    sleep(2)

    find("1349761887724.png")
    type("1349762096056.png", "guest")

    type("1349761905053.png", "guest")

    click("1349761920585.png")
    sleep(9)
def testA(self):
    click("DeviceManage.png")
    sleep(1)
    click("1349860580669.png")
    hover("NetworkIscRe.png")
    m=find("1349860624068.png")

    for i in range(2):
             m.highlight(2)
             wait(1)
    popup("RPM available")
    assert exists("1351242204129.png")
def tearDown(self):
    #assert exists("1351242204129.png")
    popup("test case excuted")
    click("1349774954074.png")
suite = unittest.TestLoader().loadTestsFromTestCase(channel)
outfile = open("C:\\Sikuli\\Reports\\report.html", "wb") # path to report folder
runner = HTMLTestRunner.HTMLTestRunner(stream=outfile, title=' Report Title', description='desc..' )
runner.run(suite)
outfile.close()

Revision history for this message
nupur (nupur) said :
#5

class channel(unittest.Testcase):

replace 'Testcase' with 'TestCase' :P

and please focus on these small issues.

Revision history for this message
naveen (mopuramnaveen) said :
#6

I am still getting below error

Please help me

I am getting below error

error] Stopped
[error] An error occurs at line 5
[error] Error message: SyntaxError: ("mismatched input 'def' expecting INDENT", ('C:\\Users\\TEL\\AppData\\Local\\Temp\\sikuli-tmp7141759619717385922.py', 5, 0, 'def setUp(self):\n'))

Revision history for this message
naveen (mopuramnaveen) said :
#7

I solved above error

I am getting below error

[error] Stopped
[error] An error occurs at line 33
[error] Error message: Traceback (most recent call last):
 File "C:\Users\TEL\AppData\Local\Temp\sikuli-tmp8837339089479327950.py", line 33, in
 outfile = open("C:\Sikuli\Reports\report.html", "wb") # path to report folder
IOError: (13, 'Permission denied', 'C:\\Sikuli\\Reports\report.html')

Revision history for this message
HAL-9000 (coldlogic) said :
#8

It looks like you're trying to make your report.html in a write-protected location. Try moving the location of the report from C:\Sikuli\Reports\ to a location where permissions are open for any user to make a file. Hope that helps.

Revision history for this message
naveen (mopuramnaveen) said :
#9

Thank u very much for u r support

I solved the problem

Revision history for this message
Hardik (hardikchotaliya26) said :
#10

Can we do this for multiple class in a single script.

Revision history for this message
RaiMan (raimund-hocke) said :
#11

@Hardik
-- 1. please do not post new questions as comments to solved questions, because only few people will see this. Use a new question (may be with a reference to other questions), so it is visible to everyone.

-- 2. your question:
all this is according to the rules of Python scripting, nothing special with SikuliX. Here the challenge would be to create the respective suite.

... and see your other question

Revision history for this message
Hardik (hardikchotaliya26) said :
#12

okay.
Since i am new user and new for all this things, I wasnt know.
Thanks for your reply.