Wednesday, June 24, 2015

Sikuli Robotframework general libary + Robot testcase + Open a notepad

General sikuli robotframework library:

'''
Created on Jun 24, 2015

@author: vallikkv @ Vallinayagam.K
'''

from sikuli import *
from Screenshot import *


class SikuliLib(object):
    ROBOT_CONTINUE_ON_FAILURE = True
    myImagePath = "C:\\sikulix\\Images"
    addImagePath(myImagePath)

    def __init__(self):
        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:
            self.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



Robot Testcase using above library:

*** Settings ***
Documentation  Open Notepad using Sikuli and Robotframework

Library  Sikulilibrary.SikuliLib

*** Test Cases ***
Open a Notepad
    click window    windowicon.PNG
    click window    search.png
    Type and enter  notepad.exe    typerun.png
    expected screen  notepad.png

Failed Log:

By Giving wrong File name in the "Type and enter" keyword




Passed Log:







No comments:

Post a Comment