keyerror message when running automation script

Asked by mohammed ahmed on 2019-08-06

from sikuli.Sikuli import *
import os
myPath = os.path.dirname(getBundlePath())
if not myPath in sys.path: sys.path.append(myPath)
from imagerepository import *
from imageclick import *
#from util import *
#from regionDictionary import *

class PSWTest():

            def openpsw():
            #def __init__(self):
#try
                myImages = imagerepository()
                Debug.on(3)
                app=App.open(r"C:\xxxx\Mxxxxxer\System\ftmerfr.exe")
                wait(5)
                click(myImages.getImage("open"))
                #click(myImages.getImage('open'))
            openpsw()

****image repository*****
from sikuli.Sikuli import *
myPath = os.path.dirname(getBundlePath())
getImagePath()
if not myPath in sys.path: sys.path.append(myPath)

class imagerepository():

    imgDict = {}
    def __init__(self):
        self.imgDict = {}
        self.addImage("open","1565006145909.png")
        self.addImage("addserver","1565006209232.png")
        self.addImage("servername","1564497837198.png")
        self.addImage("ok servername","1564497875916.png")
        self.addImage("startservice","1564497937218.png")
        self.addImage("stopservice","1564497991603.png")

    def addImage(self, name, img):
  self.imgDict[name] = img

    def getImage1(self, name):
  return self.imgDict[name]

****error***
[error] script [ PSWTest ] stopped with error at line --unknown--
[error] Error caused by: Traceback (most recent call last): File "C:\Users\mahmed\Documents\sikuli images\PSWTest.sikuli\PSWTest.py", line 11, in <module> class PSWTest(): File "C:\Users\mahmed\Documents\sikuli images\PSWTest.sikuli\PSWTest.py", line 22, in PSWTest openpsw() File "C:\Users\mahmed\Documents\sikuli images\PSWTest.sikuli\PSWTest.py", line 20, in openpsw click(myImages.getImage("open")) File "C:\Users\mahmed\Documents\sikuli images\imagerepository.sikuli\imagerepository.py", line 22, in getImage return self.imgDict[name] KeyError: open

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2019-08-06
Last reply:
2019-08-07
RaiMan (raimund-hocke) said : #1

not a SikuliX problem, since it is self-made Jython code.

Can you help with this problem?

Provide an answer of your own, or ask mohammed ahmed for more information if necessary.

To post a message you must log in.