Code Monkey home page Code Monkey logo

sikuli-framework's Introduction

SikuliFramework - GUI Automation Framework for Sikuli

SikuliFramework provides an object-oriented abstraction on top of Sikuli to assist with interacting GUI elements, such as sets of buttons, checkboxes, radio buttons, windows and dialogue hierarchies for GUI automation and testing.

What is Sikuli?

Sikuli is a visual technology to automate and test graphical user interfaces (GUI) using images (screenshots) of the software under test.

Common problems with traditional "Sikuli scripts"

Most traditional "Sikuli scripts" are created by capturing baseline images around a series of steps required to solve a particular problem. This allows for the quick creation of a script to solve a problem. There are however a few inherent problems with creating scripts in this method, these include:

  • Maintainability issues
    • Baseline images are usually very specific to a test and cannot be reused
    • If the any of the baseline images change, multiple baseline images need be fixed for 1 change in the UI
    • No enforced naming convention for baseline pictures (Everyone has a different way of naming things)
  • Fragile tests
    • "Sikuli script" often devolve into "hacky" code to get the job done, but it is hard to create truly maintainable tests
      • Use of wait(seconds) function depends on computer being fairly fast or increased time is needed, lots of time is wasted waiting around, decreases the readability of tests if there are wait commands everywhere
      • Operations are performed without validating whether the system is actually in sync
        • Clicking a checkbox, is the checkbox actually selected after the operation?
        • Entering text, is the text entered as you expect it?
        • Did clicking a button actually perform the action you expected it to? A regular Sikuli script will only fail after it cannot find an image it is expecting to present on the screen

SikuliFramework was created to solve some of the complexities and also offers the following benefits:

  • Cleaner, more readable code
  • Provides structure to the naming of baseline images
  • Dynamic resolution of image assets (Designate different images based on OS)
  • Encourages baseline reuse (Rather than capturing images to solve your immediate task, capture to solve all tasks)
  • Higher accuracy matching GUI components due to use of Regions
  • Tight integration with RobotFramework - Inspired by Mike's cognition's Blog
  • Encourages code reuse in RobotFramework test libraries
  • Streamlines baseline creation for assertions (baselines are created automatically during the initial run of the script)
  • Solves some of Sikuli's common downfalls (false-positives, context issues)
  • Greatly improved reports for debugging and general-purpose
  • Increases the robustness of test scripts (less dependant on speed of the machine, resolution, other problems)

Code Examples

Work with applications in a more natural object-oriented way

calculator = Calculator()

# Chain together operations on the same window 
calculator[Calculator.BUTTON_2].click()
    [Calculator.BUTTON_PLUS].click()
    [Calculator.BUTTON_2].click() 
    [Calculator.BUTTON_EQUALS].click()
    
# Built-in assertions methods for testing purposes
calculator[Calculator.SCREEN].assertEquals("4")

Integrates with RobotFramework to create extremely readable tests

*Setting*
Library	keywords/CalculatorLib.py	WITH NAME	Calculator

*Test Case*
Add Two Numbers
    Calculator.Launch
    Calculator.Click         Two
    Calculator.Click         Plus
    Calculator.Click         Two
    Calculator.Click         Equals
    ${Screen}=               Calculator.Select   Display
	Calculator.AssertEquals	 ${Display}           4

RobotFramework Results Log

Augments RobotFramework's log.html message statements, adding inline hyperlinking to captured images

RobotFramework Results Log Hyperlinking

Map out special GUI elements such as a TextBox, Radio, Checkbox + more and interact with them as such

calculator[Calculator.SCREEN].type("25")

Map out the resulting actions of clicking a button

# Create initial application context
textedit = TextEdit()

# Result of clicking the TextEdit button is a TextEditMenu
textEditMenu = textedit[TextEdit.MENU_BAR][MenuBar.TEXTEDIT].click()

# Perform actions on the new context created from the result of the previous action
textEditMenu[TextEditMenu.QUIT].click()

Getting Started

Documentation + Tutorials


Created by Joshua Bellamy-Henn

sikuli-framework's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sikuli-framework's Issues

Is this just for Robot Framework integration or more?

This seems to be a nice framework. Curious as to whether it is strictly RF focused or not.

A future thought might be to expand it to provide some sort of WebDriver API interface so that any WebDriver client could call it and work with it. If not to work with generic WebDriver API (and hence any supported WebDriver client), maybe a custom one.

I made effort on a POC but didn't get far, but I mapped out a spec on how Sikuli API/usage could translate to WebDriver API:

https://github.com/daluu/SikuliDriverServer/wiki/WebDriver-API-command-support-and-mapping-to-Sikuli-API

although briefly glancing over this framework, it probably takes a different approach for image location strategy.

Anyways just some food for thought.

Sikuli-framework does not work on Linux

The current version of Sikuli - sikuli-java.jar, seems to be for the mac platform which cause it to fail under other platforms.

There are some platform specific libs which are included in the jar file (eg: files under META-INF/libs/ which contain platform specific shared objects) because of which the same jar file cannot be used across different OS platforms.

It'll probably be best, if we can reference Sikuli from an existing installation on the system rather than ship a platform specific jar.

There's another problem of Env.getOS() returning the wrong string when run on Linux. It returns MAC even on Linux. This is a known bug in the SikuliX jar.

What version of sikuli did you integrate your framework with ?

Hello,

I'm trying to use the framework on Windows/Linux

first, I tried to run the calculator example but it gives me the below error
"TRACE:1432030308240 Changing screenshot logging level
INFO:1432030308255 <class 'launcher.Launcher'> is attempting to run [Calculator] wd=C:\Users
moselhy\Desktop\Sikuli\sikuli-framework-master
TRACE:1432030308255 Calculator:Application created
INFO:1432030308255 <class 'launcher.Launcher'> created [Calculator] from [calc.exe] [WINDOWS
in7 x86]
Traceback (most recent call last):
File "examples\calculator\add.py", line 48, in
calculator = Launcher.run('Calculator')
File "C:\Users\mmoselhy\Desktop\Sikuli\sikuli-framework-master\src\launcher.py", line 65, in run
result = subprocess.Popen(binary, shell=True, cwd=app.getWorkingDir(os, osVersion, arch))
File "C:\Users\mmoselhy\Desktop\Sikuli\sikuli-framework-master\java\sikuli-script.jar\Lib\subproc
ss.py", line 751, in init
File "C:\Users\mmoselhy\Desktop\Sikuli\sikuli-framework-master\java\sikuli-script.jar\Lib\subproc
ss.py", line 1236, in _execute_child
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'"

the launcher isn't working, do u have any idea why ?
also, I want to integrate with the latest sikuli jar, I found that you use sikuli-script.jar
and this is replaced by sikuli-java.jar in the latest release 1.0.1 . but it misses many dependencies.

I know that it's been year since you pushed some work.
I may help to support the latest version of sikuli
but I still need some info as I'm somehow confused :)

Unable to run examples

Hi I'm really having a hard time setting up the framework. I couldn't run the examples. It's frustrating :-( When I run the calculator example I get the following error:

C:\Users\adred\sikuli-framework>python run.py examples\calculator\add.py
Launching Jython [examples\calculator\add.py]...
java -Dsikuli.Debug=0 -cp java/jython.jar;java/*;. -Dpython.path=.;java/sikuli-s
cript.jar/Lib;src;examples -Xmx1024M org.python.util.jython -Dpythonpath=. -Dlog
level=TRACE examples\calculator\add.py
Jun 01, 2015 1:28:07 AM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0
x80000002. Windows RegCreateKeyEx(...) returned error code 5.
[error] ResourceLoaderBasic: loadLib: Fatal Error 110: loading: WinUtil.dll
[error] ResourceLoaderBasic: loadLib: Since native library was found, it might b
e a problem with needed dependent libraries
C:\Users\adred\sikuli-framework\java\libs\WinUtil.dll: Can't find dependent libr
aries
[error] ResourceLoaderBasic: loadLib: Check, wether a valid Sikuli libs folder i
s in system path at runtime!
[error] Terminating SikuliX after a fatal error(110)! Sorry, but it makes no sen
se to continue!
If you do not have any idea about the error cause or solution, run again
with a Debug level of 3. You might paste the output to the Q&A board.
----------------------------
Performing post processing..
----------------------------
Done.

I've added C:\Users\adred\sikuli-framework\java\libs\ and C:\Users\adred\Documents\SikuliX\libs in the system path but still no luck.

Sikuli-framework does not work on windows

For starters, the sikuli-script.jar that's in the repo, seems to be for a Mac/OSX install. This needs to be made dynamic for different platforms.

Even after overwriting it with the correct version of the jar file, it fails in loading some libs. Here's the o/p:

WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0
x80000002. Windows RegCreateKeyEx(...) returned error code 5.
[error] ResourceLoaderBasic: loadLib: Fatal Error 110: loading: WinUtil.dll
[error] ResourceLoaderBasic: loadLib: Since native library was found, it might b
e a problem with needed dependent libraries
C:\Users\mandeep\SikuliX\libs\WinUtil.dll: Can't find dependent libraries
[error] ResourceLoaderBasic: loadLib: Check, wether a valid Sikuli libs folder i
s in system path at runtime!
[error] Terminating SikuliX after a fatal error(110)! Sorry, but it makes no sen
se to continue!
If you do not have any idea about the error cause or solution, run again
with a Debug level of 3. You might paste the output to the Q&A board.
----------------------------
Performing post processing..
----------------------------
Done.

[error] ResourceLoaderBasic: loadLib: Fatal Error 110: loading: WinUtil.dll --Sikuli frame work not working for Java version 1.8.0_261.

Hello Team,

My Sikuli frame work not working for Java version 1.8.0_261. For previous version 1.8.0_202 it was working.

Error message: [error] ResourceLoaderBasic: loadLib: Fatal Error 110: loading: WinUtil.dll

Complete Error message:
[error] ResourceLoaderBasic: loadLib: Fatal Error 110: loading: WinUtil.dll
[error] ResourceLoaderBasic: loadLib: Since native library was found, it might be a problem with needed dependent libraries
C:\BUILD\resources\dependencies\libs\WinUtil.dll: A dynamic link library (DLL) initialization routine failed
[error] ResourceLoaderBasic: loadLib: Check, wether a valid Sikuli libs folder is in system path at runtime!
[error] Terminating SikuliX after a fatal error(110)! Sorry, but it makes no sense to continue!
If you do not have any idea about the error cause or solution, run again
with a Debug level of 3. You might paste the output to the Q&A board.

How to work with new windows

Hi Joshua,
Thank you for your work. Could you, please, explain how to handle multiple windows and dialogs?
Here is my sample scenario:

  1. Run application -> Login splash screen appears
  2. Click to Login button -> splash screen disappears and main window shows up
  3. Click to button in main window

I managed to write steps 1 and 2, but can't click any button at step 3 - test waits for some time then reports 'Unable to regex match on Screen' error. At that time application window is active and visible, so I wonder if there is some method that I need to call in order to redraw the whole screen before calling methods for controls in main window?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.