Want to run multiple test script

Asked by hakim johari

I have multiple test script and i want to run it sequentially and automatically.
How do i do this?
I'm new user in sikuli ide and in python language

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

This question was reopened

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

easiest way, if all scripts are able to run standalone:

- put all scripts in one folder

- make a main script

# main.sikuli
import script1
import script2
...

in this example the scripts are named:
script1.sikuli
script2.sikuli

IMPORTANT:
each imported script MUST have this line at the beginning:
from sikuli import *

Revision history for this message
hakim johari (hakim-johari) said :
#2

after I import my test script, do I need to have some coding as to where are the files located or some sort?

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

once again:

# script1.sikuli
# a script to be imported
from sikuli import *
popup("Hello, I am script1")

# main.sikuli
popup("Hello, I am the main script")
import script1

- both scripts in one folder

- open main.sikuli in IDE and run it
- to run it again, you have to close and reopen IDE (an import is always only done once)

alternatively you can run main.sikuli from command line using
<path-to->runIDE -r <path-to->main.sikuli
(with version 1.0.1)

Revision history for this message
Eugene S (shragovich) said :
#4

One more option is to run the sequence from command line (cmd). For example:

@echo off
cls
echo +++ Testing Scripts Launcher ver 0.0.1
echo +++ START

call C:\Sikuli\runScript.cmd -r C:\Sikuli\Tests\testFlows\Test1.sikuli
call C:\Sikuli\runScript.cmd -r C:\Sikuli\Tests\testFlows\Test2.sikuli
.
.
.

You might also include some environment configuration commands. For example, check that all Internet Explorer(or any other application) windows are closed before starting the next scenario.

call:closeIE

:closeIE
echo Checking if Internet Explorer is running
tasklist /FI "IMAGENAME eq iexplore.exe" 2>NUL | find /I /N "iexplore.exe">NUL
if "%ERRORLEVEL%"=="0" echo iexplore.exe is running. Killing... & taskkill /F /IM iexplore.exe
) else (
echo iexplore.exe is NOT running
goto:eof

Revision history for this message
hakim johari (hakim-johari) said :
#5

i got this kinda error

Exception in thread "Thread-22" java.lang.IllegalStateException: No match found
at java.util.regex.Matcher.group(Unknown Source)
at org.sikuli.ide.SikuliIDE$ButtonRun.findErrorSourceWalkTrace(Unknown Source)
at org.sikuli.ide.SikuliIDE$ButtonRun.findErrorSource(Unknown Source)
at org.sikuli.ide.SikuliIDE$ButtonRun.access$1500(Unknown Source)
at org.sikuli.ide.SikuliIDE$ButtonRun$1.run(Unknown Source)

[error] script [ test ] stopped with error in line 8
[error] ImportError ( No module named LoginSuccess )

Revision history for this message
Eugene S (shragovich) said :
#6

Have you imported your module into your code?

import LoginSuccess

Revision history for this message
hakim johari (hakim-johari) said :
#7

Thanks RaiMan, that solved my question.

Revision history for this message
hakim johari (hakim-johari) said :
#8

turns out that my .py is not the same name as my .sikuli
so i change it to be the same and its running good now.
Thanks RaiMan and Eugene S

Revision history for this message
hakim johari (hakim-johari) said :
#9

I use this script

main.sikuli
import script1
import script2

to run multiple test script

but now, how to run these testscript at a specific time? : lets say script1 at 1pm and script2 at 4pm

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

there are date and time modules in Python, that can be used.

the principal approach:

supposing script1 finishes before 4pm.

while True:
    if <time is > 1pm>:
        import script1
        break
    wait(60) # check every minute

while True:
    if <time is > 4pm>:
        import script2 # will only run once
        break # to terminate the loop
    wait(60) # check every minute

to implement the <...> expressions is your job ;-)

Revision history for this message
Harry (iam-harishetty) said :
#11

Hi Raiman

1.I wanted to run 8 scripts at once.So i included "from sikuli import *" in all the 7 scripts and in last script i used "import (name of all the scripts separated by comma)" OR individually i imported seven scripts in the last one

2.I created one new script called as "main.sikuli" and in that i imported all 8 scripts one by one.

In both the cases i m getting "SyntaxError ( "mismatched input '-' expecting NEWLINE", )"
Please let me if i m doing something wrong.

Can you help with this problem?

Provide an answer of your own, or ask hakim johari for more information if necessary.

To post a message you must log in.