Question #252490 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/252490

    Status: Open => Answered

RaiMan proposed the following answer:
ok, now I got the secret behind all this:

- if you want to use a class inside a module, then the class name has to
be the same as the module name (without the .py and/or the .sikuli) -
and this is case sensitive. If this is not the case (module name !=
class name), then  there are more options to specify the class to be
loaded.

- if you use the library specification in Settings with a folder
structure like folder/folder/folder/module.py, then there MUST be module
name == class name (case sensitive)

Taking this all together, then this is a valid example:

*** Settings ***
Library….stuff/Calculator.sikuli/Calculator.py

*** Test Cases ***
Verify that 2 + 2 = 4
   Start App
   Verify App
   Perform Action….2….+….2
   Verify Result….4

with this Calculator.sikuli:

import org.sikuli.basics.SikuliXforJython 
from sikuli import *

popup("Calculator.sikuli")

class Calculator:

  def __init__(self):
    popup("__init__")
    
  def startApp(self):
    popup("startApp") 
  
  def verifyApp(self):
    popup("verifyApp") 
  
  def performAction(self, *args):
    popup("performAction") 
  
  def verifyResult(self, *args):
    popup("verifyResult") 

  def runAllTests(self):
    self.startApp()
    self.verifyApp()
    self.performAction()    
    self.verifyResult()
    
# ---- this is ignored when imported
# ---- makes this runnable for testing outside RFW
if __name__ == "__main__":
    Calculator().runAllTests()

… and this simply does what it should.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to