Launch Sikuli Script by Command Line - Error XmlRunner

Asked by yop on 2018-05-23

Hello,

I try to launch my Sikuli Script by Command line (Script edited by Sikulix IDE on Linux CentOs).

I use this commande :
/PathToSikulix/runsikulix -r /PathToScript/SmokeTest.sikuli

And the result is an Error :
SikuliX: -Xmx512M -Dfile.encoding=UTF-8 -Dsikuli.FromCommandLine
-jar
/PathToSikulix/sikulix.jar -r
/PathToScript/SmokeTest.sikuli
[info]
runcmd: lsb_release -i -r -s
[error] script [
/PathToScript/SmokeTest.sikuli ]

stopped with error in line 17
[error] ImportError ( No module named xmlrunner )

--------------------------------------------------------------------------------------
--> Line 17 and next are :
import xmlrunner
reload(xmlrunner)

From xmlrunner import*
---------------------------------------------------------------------------------------

If someone has an idea ?
Thanks in advance !

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
yop
Solved:
2018-05-25
Last query:
2018-05-25
Last reply:
2018-05-23
RaiMan (raimund-hocke) said : #1

can some xmlrunner module (I do not know that) be found on sys.path at script runtime?

read:
http://sikulix-2014.readthedocs.io/en/latest/scenarios.html#access-python-packages-from-sikulix-scripts-run-by-sikulix-gui-or-commandline

yop (fraise) said : #2

My Script works in standalon mode

For testing i had put the xmlrunner in :
The Script
The Folder Sikulix
The Folder Sikulix/lib/site-packages

yop (fraise) said : #3

OKy i find the first problem.
In my script my Syspath is in another folder ...that was the problem ..thanks Rainman.

But now the script start the first step and after ..nothing...
The "utils_XOM_DisplayResolutions.Res1280x800()" is executed but the next Step "def test_TC_02_02_Res1600x900_UI_Elements_ToolsBar_Flag(self):" not.
---> Problem of "Unittest import, "HtmltestRunner" ?

My Script is :

from sikuli import *
import org.sikuli.script.ImagePath
import os
import sys
import time
import shutil
import subprocess

dir = "/opt/TEST_XOM/01_TestReports/"
if not dir in sys.path: sys.path.append(dir)

import xmlrunner
reload(xmlrunner)

from xmlrunner import *

import utils_XOM_Base
reload(utils_XOM_Base)
import utils_XOM_DisplayResolutions
reload(utils_XOM_DisplayResolutions)

# --> Préciser Nom de la suite :
fp = file(os.path.join(dir, "TS_050_XOM_Control_SandBox_Control_UI_Elements.html"), "wb")

import unittest
import HTMLTestRunner
reload(HTMLTestRunner)

Debug.on(0);

import csv
reload(csv)

# --> Préciser Nom de la suite
class TestSuite_XOM_SandBox_Control_UI_Elements(unittest.TestCase):

    def setUp(self):
        utils_XOM_Base.start()
        Debug.info('TestSuite 50 --> START')

    def tearDown(self):
        utils_XOM_Base.stop()
        Debug.info('TestSuite 50 --> STOP')

#-------------------------------------------------------------------------------------------------------------------------------------------------------------------
#Display 1280x800
    utils_XOM_DisplayResolutions.Res1280x800()
    wait(4)

#-------------------------------------------------------------------------------------------------------------------------------------------------------------------

#ToolsBar-Flag ---------------------------------------------
    def test_TC_02_02_Res1600x900_UI_Elements_ToolsBar_Flag(self):
        wait(2)
        Settings.MoveMouseDelay=0
        Sandbox=App('/opt/XeebraOffside/Sandbox /opt/TEST_XOM/05_ConfigsTest/UIControl/UI_Elements/UI_Elements_1/')
        Sandbox.open()
        wait(1)
        click("RunAnalysis.png")
        wait(2)
        Reg=Region(0,800,1600,900)
        if Reg.exists("UI_ToolsBarFlag_Base1600x900.png",5):
            assert True
            Sandbox.close()
            utils_XOM_DisplayResolutions.Res1920x1080()
            wait(0.5)
        else:
            Sandbox.close()
            utils_XOM_DisplayResolutions.Res1920x1080()
            wait(0.5)
            assert False

# --> Préciser Nom de la suite :
suite = unittest.TestLoader().loadTestsFromTestCase(TestSuite_XOM_SandBox_Control_UI_Elements)
# --> Préciser Nom de la suite :
runner = HTMLTestRunner.HTMLTestRunner(stream = fp, title= 'TestReport_TS_050_XOM_SandBox_Control_UI_Elements', description='TestSuite description : Control présence UI éléments ', verbosity=3, dirTestScreenshots = dir)
runner.run(suite)

yop (fraise) said : #4

Sorry ....I would say "Raiman" ! just because I listened yesterday the "Rainman theme music" :-)

RaiMan (raimund-hocke) said : #5

I am on holidays until June 4th - you have to wait ;-)

yop (fraise) said : #6

No problem ! have a nice holidays, that's the most important think !

yop (fraise) said : #7

I understood why my command line Stop at the first step !
I remembered that in my Script i close all the Gnome-terminal if one or severals are open ...so that closed the Sikulix IDE (that we do not see when start Script in command line) :-)
Just i add "nohup" before my command and all is ok know.
"nohup /pathToSikuli/runsikulix -r /pathToSikuliScript/Script"