Experimental
... means
- basic features are implemented and useable in selected environments
- might not be tested with all possible variations
- are usually only poorly documented or not at all
- might have bugs and other oddities
Experimental: Play with Robot Framework
with build 2015-07-05+ you can use Robot features from inside scripting:
A test script that even integrates the usage of Selenium is available here
This is the principal layout of a script that runs as RFW testcase:
- It is planned to have the latest robot Python module bundled with the SikuliX distribution and hence have the Robot features available without any additional actions, but this is currently not working (the HTML data needed for reporting is not accessible from inside a jar). As a workaround, you have to have a copy of the robot module (the folder robot containing the file __init__.py) in the SikulixAppData/Lib folder (about SikulixAppData see tab QuickStart and create it, if it does not exists yet). The folder robot can usually be found after a Robot setup in the Python Lib/site-packages folder. You might also download and unzip from here (Robot version 2.8.7).
- you can setup a Robot testcase (text version preferably blank separated) in the SikuliX IDE
- optionally you can add in the same script file an inline Robot Keyword library
- you can run the Robot testcase from the IDE or from command line (no need for extra batch files or scripts)
- currently no extra Robot specific options are possible - it is just run like with pybot myTest.robot
- say you have the Robot testcase setup in a testRobot.sikuli
- running the testcase will produce a testRobot.sikuli.robot folder in the same folder as testRobot.sikuli
- the testRobot.sikuli.robot folder will contain the Robot log.html and report.html (besides the generated .robot file and the .py module file containing the optional Keyword library)
A test script that even integrates the usage of Selenium is available here
This is the principal layout of a script that runs as RFW testcase:
# the following content of the multiline comment (except the first line containing robot)
# will be given to robot.run as Robot testcase file foobar.robot
runScript("""
robot
*** Variables ***
${USERNAME} demo
${PASSWORD} mode
${TESTSITE} http://test.sikuli.de
*** Settings ***
Library ./inline/LoginLibrary
Test Setup start firefox and goto testsite ${TESTSITE}
Test Teardown stop firefox
*** Test Cases ***
User can log in with correct user and password
Attempt to Login with Credentials ${USERNAME} ${PASSWORD}
Status Should Be Accepted
User cannot log in with invalid user or bad password
Attempt to Login with Credentials betty wrong
Status Should Be Denied
""")
# the following towards end of script will go to a LoginLibrary.py module file
try:
from selenium4sikulix import *
except:
Debug.error("SikuliX environment not ready for Selenium4Sikulix")
from sikuli import *
class LoginLibrary(object):
def start_firefox_and_goto_testsite(self, page):
pass
def stop_firefox(self):
pass
def attempt_to_login_with_credentials(self, username, password):
pass
def status_should_be(self, expected):
pass
Experimental: Play with Selenium
This is about a first step to better support the side-by-side usage of Selenium and SikuliX in scripts.
You might run a showcase with Selenium Firefox (take care you have the latest Firefox installed).
These are the steps (tested only on Mac and Windows):
Since information about usage are not yet in the docs, you have to look into the script, to get an idea.
The solution is based on the Selenium Java package and is currently prepared for Jython scripting. So there is no need to fiddle around with any Python packages, pip installs or Jython problems with the Python stuff.
You might run a showcase with Selenium Firefox (take care you have the latest Firefox installed).
These are the steps (tested only on Mac and Windows):
- have a setup with a build version 2015-07-03+
- on a command line run java -jar setup....jar options extensions which will download and store the supporting jar
- in the IDE run a script containing only: runScript("git*selenium"), which will run a script from the net
Since information about usage are not yet in the docs, you have to look into the script, to get an idea.
The solution is based on the Selenium Java package and is currently prepared for Jython scripting. So there is no need to fiddle around with any Python packages, pip installs or Jython problems with the Python stuff.
Experimental: Play with the RunServer
To start the local RunServer on port 50001 from a command line or terminal-session use either:
runsikulix(.cmd) -s (supports running Python and JavaScript scripts)
java -jar sikulixapi.jar -s (supports running JavaScript scripts only)
If the RunServer start succeeds, you should see something like the following:
runsikulix(.cmd) -s (supports running Python and JavaScript scripts)
java -jar sikulixapi.jar -s (supports running JavaScript scripts only)
If the RunServer start succeeds, you should see something like the following:
[info] RunServer: Starting: trying port: 50001
[info] RunServer: now waiting on port: 50001 at 192.168.2.108
Now the server is ready to accept requests (RESTful HTTP).
Clicking the below links will open a new page displaying the server response.
Just have a look at it, close it and come back to this page.
The display looks like this: PASS or FAIL NNN Specific-Information
PASS signals a successful processing of the request
FAIL means, that at least the request could not be processed successfully to it's end
NNN is a suitable HTTP status code
Specific-Information is what it says, in case of RUN it ends with the string representation of the return value.
Stop the RunServer CLICK ME (issues: http://localhost:50001/stop)
Start a script runner, that subsequently will run scripts instantly (no startup delay):
for JavaScript CLICK ME (issues: http://localhost:50001/start)
for Python/Jython CLICK ME (issues: http://localhost:50001/startp)
Since this playground is a static environment, you have to implement some prerequisites, to run scripts.
To your home folder add a folder sikulixrunserver.
Having done this, you now tell the server to use this folder to find scripts
as folder where scripts are stored CLICK ME (issues: http://localhost:50001/scripts/home/sikulixrunserver)
If you want to use one place, where you put your captured images, you now tell the server to use this folder
as folder where images are stored CLICK ME (issues: http://localhost:50001/images/home/sikulixrunserver)
Of course you can have images in the script folder as well.
To run a Python script:
Add a script named testpy.sikuli (take care, that it contains a testpy.py as well) to the folder sikulixrunserver.
This could easily be accomplished by using the SikuliX IDE using SaveAs with an existing script.
To get a valid return code, use exit() (yields 0) or exit(n). Other script terminations will be reported as FAIL.
Run the script CLICK ME (issues: http://localhost:50001/run/testpy)
To run a JavaScript script:
Add a folder named test to the folder sikulixrunserver. In this folder add a test.js file containing the script.
The needed images might be in sikulixrunserver/test, in sikulixrunserver or in the images folder.
To achieve all this, you have to use some editor, since JavaScript scripts are not yet supported in the SikuliX IDE.
The last evaluated value/object in the script will be returned with it's string representation as return value..
Clicking the below links will open a new page displaying the server response.
Just have a look at it, close it and come back to this page.
The display looks like this: PASS or FAIL NNN Specific-Information
PASS signals a successful processing of the request
FAIL means, that at least the request could not be processed successfully to it's end
NNN is a suitable HTTP status code
Specific-Information is what it says, in case of RUN it ends with the string representation of the return value.
Stop the RunServer CLICK ME (issues: http://localhost:50001/stop)
Start a script runner, that subsequently will run scripts instantly (no startup delay):
for JavaScript CLICK ME (issues: http://localhost:50001/start)
for Python/Jython CLICK ME (issues: http://localhost:50001/startp)
Since this playground is a static environment, you have to implement some prerequisites, to run scripts.
To your home folder add a folder sikulixrunserver.
Having done this, you now tell the server to use this folder to find scripts
as folder where scripts are stored CLICK ME (issues: http://localhost:50001/scripts/home/sikulixrunserver)
If you want to use one place, where you put your captured images, you now tell the server to use this folder
as folder where images are stored CLICK ME (issues: http://localhost:50001/images/home/sikulixrunserver)
Of course you can have images in the script folder as well.
To run a Python script:
Add a script named testpy.sikuli (take care, that it contains a testpy.py as well) to the folder sikulixrunserver.
This could easily be accomplished by using the SikuliX IDE using SaveAs with an existing script.
To get a valid return code, use exit() (yields 0) or exit(n). Other script terminations will be reported as FAIL.
Run the script CLICK ME (issues: http://localhost:50001/run/testpy)
To run a JavaScript script:
Add a folder named test to the folder sikulixrunserver. In this folder add a test.js file containing the script.
The needed images might be in sikulixrunserver/test, in sikulixrunserver or in the images folder.
To achieve all this, you have to use some editor, since JavaScript scripts are not yet supported in the SikuliX IDE.
The last evaluated value/object in the script will be returned with it's string representation as return value..
- n; will show up with n as return value,
- a wait(someImage) will show null or the Match.toString() as return value,
- A someObject; as last statement will show up with someObject.toString() as return value.
Experimental: Use the RunServer - run scripts from anywhere with zero-delay
The intended use of this feature is
After having started the RunServer as mentioned above, you can use it with your individual solution.
Any client, that is able to issue valid HTTP GET requests against the server at localhost:50001 can be used.
the following clients or client solutions as examples:
These are the valid commands currently - to be written RESTful after localhost:50001/
Comments:
Ruby scripts are not yet supported.
* the server must either be started with sikulix.jar or a valid Jython jar must be on the Java class path.
** if the first folder is named home, the subsequent structure is expected in the user's home folder.
Windows: drive letters are not yet supported
For images, the folder really containing the images, might be a .sikuli (so it can be managed with the IDE).
*** the runner to use is evaluated from the ending of the script file (.py or .js) contained in the script folder.
The folder ending .sikuli can be omitted for Python scripts, JS scripts currently should not have a .sikuli at all
With the first run request you get the known startup delay, if a runner has not yet been started using the start command.
- run prepared scripts from environments, that cannot easily use one of the SikuliX APIs, like command line, C#, C++, Python, AppleScript, Java versions before version 6, ...
- run single line JavaScript snippets from any of the above environments to get a tighter integration with the SikuliX features (the return values will be in some JSON format, not yet fully available)
- run prepared scripts on other machines (not yet tested, but should work)
- setup some web based application, that runs scripts from the net on the local machine (not yet fully available), which would e.g. allow to setup some showcase webpage enriched with the features of the annotation tool (the former Guide extension)
After having started the RunServer as mentioned above, you can use it with your individual solution.
Any client, that is able to issue valid HTTP GET requests against the server at localhost:50001 can be used.
the following clients or client solutions as examples:
- of course any browser using it's address line or links in a webpage like here in this showcase.
- any programmatical browser feature like when using Selenium
- the command line tool curl and similar tools
- any programmed client in any language, that issues valid HTTP GET requests
These are the valid commands currently - to be written RESTful after localhost:50001/
- stop - stops the server
- start - initiates a JavaScript runner, so the next run request will start the script without delay
- startp - initiates a Jython runner, so the next run request will start the script without delay *
- scripts/folder/folder/folder/... - sets the folder where the runner finds the scripts **
- images/folder/folder/folder/... - sets the folder where the runner finds the images used in a script (image path) **
- run/script - looks for the script in the given folder and runs it (starts the respective runner if not yet done) ***
Comments:
Ruby scripts are not yet supported.
* the server must either be started with sikulix.jar or a valid Jython jar must be on the Java class path.
** if the first folder is named home, the subsequent structure is expected in the user's home folder.
Windows: drive letters are not yet supported
For images, the folder really containing the images, might be a .sikuli (so it can be managed with the IDE).
*** the runner to use is evaluated from the ending of the script file (.py or .js) contained in the script folder.
The folder ending .sikuli can be omitted for Python scripts, JS scripts currently should not have a .sikuli at all
With the first run request you get the known startup delay, if a runner has not yet been started using the start command.