Unable to run sikuli script with robo class from main script

Asked by Test App

Hi

I have created some automation scripts with robo class and then i am trying to call theese scripts from the main script . But Sikuli gives an error saying Unable to find keywords

########This is my main script#####

import Script 1

########This is my Sikuli script with robo class#########

from sikuli import*
runScript("""
robot
*** Variables ***
${USERNAME} demo
${PASSWORD} mode
${TESTSITE} http://test.sikuli.de
*** Settings ***
Library ./inline/LoginLibrary
Test Setup launch application
Test Teardown stop application
*** Test Cases ***
TC-18 :Validate tab for a new case
    Create patient

""")

class LoginLibrary(object):
  def launch_application(self):
      #write code to launch app
     doubleClick("1495488947167.png")
     wait(10)
     if exists ("home.png"):
          print("PASS:App launch sucessfull")
     else:
          print("FAIL:App launch unsucessfull")

    def Create_patient(self):
    click("1495488977291.png")
    wait(5)
    if exists("namefield.png"):
        print("PASS:Enter name of new patient")
        type("")
    else:
        print("FAIL:field is not available")

However this test case runs file when i run it as a standalone without caling it from the main script

But i want to run multiple cases one after the other . Hence i want to create a main script and run that main script

Please help

Question information

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

I can not understand the meaning of "main script" you are talking about.
So I will explain how to use RobotFramework generally.

When we use RobotFramework to run multiple cases one after the other,write that cases in "*** Test Cases ***" section.

*** Test Cases ***
Test Case Name 01
    Keyword01
    Keyword02

Test Case Name 02
    Keyword03
    Keyword04

Revision history for this message
Test App (laxmisaketha) said :
#2

Hi Masuo ,

Thank you for the reply .
What i mean by Main script is the script which contains the test names of all the other scripts.
Say i want to run multiple scripts one after the other i use the following code

### Main script code###

import Script1
import Script2
import Script3

###End of main script###

When i run this main script all my test cases should be executed one after the other.This is what is expected . But my code throws an error saying Unable to find keywords .So how do i call multiple robo scripts in my main script without any errors

###Below is my Script 1 code###

from sikuli import*
runScript("""
robot
*** Variables ***
${USERNAME} demo
${PASSWORD} mode
${TESTSITE} http://test.sikuli.de
*** Settings ***
Library ./inline/LoginLibrary
Test Setup launch application
Test Teardown stop application
*** Test Cases ***
TC-18 :Validate tab for a new case
    Create patient

""")

class LoginLibrary(object):
  def launch_application(self):
      #write code to launch app
     doubleClick("1495488947167.png")
     wait(10)
     if exists ("home.png"):
          print("PASS:App launch sucessfull")
     else:
          print("FAIL:App launch unsucessfull")

    def Create_patient(self):
    click("1495488977291.png")
    wait(5)
    if exists("namefield.png"):
        print("PASS:Enter name of new patient")
        type("")
    else:
        print("FAIL:field is not available")

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

import is not recommended, to use for running other scripts.

try runScript instead:
http://sikulix-2014.readthedocs.io/en/latest/scripting.html#running-scripts-and-snippets-from-within-other-scripts-and-run-scripts-one-after-the-other

In your case it might even be necessary (caused by the implementation of this special Robot run), to implement the scriptrun on the commandline according to
http://sikulix-2014.readthedocs.io/en/latest/faq/010-command-line.html#how-to-run-sikulix-from-command-line

Revision history for this message
masuo (masuo-ohara) said :
#4

@Test App

You wrote test case 1 in Script1 and test case 2 in Script2, I understand.

When you write these test cases in "*** Test Cases ***" section, you can run multiple cases one after the other.

If class name are different in each test case, add each library name in "*** Settings ***" section.

Revision history for this message
Test App (laxmisaketha) said :
#5

Hi RaiMain,

Thank you for the reply.

I tried executing the below command from command prompt , But nothing happens. Sikuli is not initalised

Commands execute on Command prompt to run Multiple scripts:

C:\Sikuli\Scripts>sikulix.jar -r Sample1./Sample2

So is this correct to run multiple scripts

When i ran
C:\Sikuli\Scripts>sikulix.jar -r Sample1

My Sample1 executed just fine , but when i try to run Sample 2 after Sample 1
I cannot to do it with C:\Sikuli\Scripts>sikulix.jar -r Sample1./Sample2

I am new to Sikuli and learning how to use it .Please help

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

I do not have the impression, that you read through the docs behind the links from comment #3

Come back when you did.

Revision history for this message
Test App (laxmisaketha) said :
#7

Hi RaiMan,

Thank you so much . I am sorry i was careless earlier :( .

I am able to run scripts one after the other by giving the following command in cmd

runsikulix.cmd -r sikuli.com:scripts/Sample1 ./Sample2

Revision history for this message
Test App (laxmisaketha) said :
#8

Thanks RaiMan, that solved my question.