Wednesday, May 18, 2016

Sample sikuli script

'''
Created on Jun 24, 2015

@author: vallikkv @ Vallinayagam.K
'''

from sikuli.Sikuli import *
import sys
from robotremoteserver import RobotRemoteServer


class SikuliLib(object):
    ROBOT_CONTINUE_ON_FAILURE = False
    myImagePath = "C:\\sikulix\\Images.sikuli"
    #setBundlePath = "C:\\sikulix\\Images.sikuli"
    addImagePath(myImagePath)
 
    def __init__(self):
        self.appCoordinates = (0, 0, 1024, 768)
        self.screen = Screenshot()
     
 

    def click_window(self, inputfile):
        self.inputfile = inputfile
        if exists(self.inputfile):
            find(self.inputfile)
            click(self.inputfile)
        else:
            self.screen.take_screenshot()
            raise AssertionError("Required screen to click is not available")

    def Type_and_enter(self, inputtotype, inputfile1):
        self.inputtotype = inputtotype
        self.inputfile1 = inputfile1
        if exists(self.inputfile1):
            find(self.inputfile1)
            type(self.inputtotype + Key.ENTER)
        else:
            screen.take_screenshot()
            raise AssertionError("Typing To inputfile is failed")

    def expected_screen(self, expectedfile):
        self.expectedfile = expectedfile
        if not exists(self.expectedfile):
            self.screen.take_screenshot()
            raise AssertionError("Error, Failed")
        else:
            pass

if __name__ == '__main__':
    from robot.libraries.Screenshot import *
    RobotRemoteServer(SikuliLib(), host="192.168.10.104", port=8270, allow_stop=True)


Reference: https://answers.launchpad.net/sikuli/+question/136170







No comments:

Post a Comment