[1.1.1] Using Robotframework with SikuliX (2016-05-25+)

Asked by Ryan

****************** fixed in 1.1.1 2016-05-25+
usage according to
http://sikulix-2014.readthedocs.io/en/latest/scenarios.html#using-robotframework

----------------------------------------------------------------------------------------------------------

Hello,

I am trying to get SikuliX to 'play with' Robot Framework as outlines here: http://www.sikulix.com/support.html

I am running with:
- Win 10 64-bit
- SikuliX 1.1.0 (2015-10-05_(17:07)
   - Installed with option 1 and 2 ticked
- Python 2.7.5
- I downloaded the Robot folder via the link about and placed the files in '%appdata%/SikuliX/Lib/robot/'

What I am trying to do:

Run a simple test case that will output some reporting to test that this is working. Getting a report output at the end of the test is the end goal here.

What I have tried:

1) I have tried making a test script in Sikuli that contains the code found in testRun.py (via the link above), but I get these errors:

[error] JythonSupport: exec: returns: Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named robot

[error] JythonSupport: exec: returns: Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'robot' is not defined

2) I have tried running a Robot Framwork test script for the calculator, outlined here: https://bitbucket.org/robotframework/robotdemo/src/51f472687b6a46e88b7c179423f0f336e19497fc/data_driven.robot?at=master&fileviewer=file-view-default

When I do, I get this error:

[error] script [ Testrobot ] stopped with error in line 33 at column 22
[error] SyntaxError ( "no viable alternative at character '$'", )

^^I have no idea what that means

3) I've tried making sure all single or double or brackets or any sort are all closed or the correct kind - same errors.

I am really lost at this point.

Does anyone know what I am doing wrong? Or, does anyone just have a simple test case I can copy/paste into Sikuli so I can run it and see the HTML report files that are output?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Ryan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

I will try to sort it out within the next 24 hours:

Revision history for this message
Ryan (ryan-g2) said :
#2

Thanks RaiMan - any help is appreciated by you or anyone.

I am really liking Sikuli. The RunServer option worked like a charm!

Revision history for this message
Ryan (ryan-g2) said :
#3

I should add that I am new to coding of any sort, so sorry if I ask questions that are super obvious.

Revision history for this message
Karl (k-d) said :
#4

Should robot be put in %appdata%/Roaming/SikuliX/Lib/site-packages/?

Revision history for this message
Ryan (ryan-g2) said :
#5

Think support page on the Sikuli site says

"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)."

Checking the QuickStart page, it says the 'SikuliAppData' location on windows is where the %AppData% path takes you - which is 'C:\Users\[user]\AppData\Roaming' for me....

I made a 'Lib' folder inside the 'SikuliX' folder and placed the 'robot' folder within the 'Lib' folder.

So, I mistyped above. I have my robot folder in this location: '%appdata%/SikuliX/Lib/robot/'

Fixing OP.....

Revision history for this message
RaiMan (raimund-hocke) said :
#6

I have to admit, that there where offending bugs in the import support of SikuliX.

They are fixed now. Available with the next nightly 1.1.1 (hope tonight).

this works:

- the upper part (multiline comment) contains the Robot script
- the lower part (class LoginLibrary) defines the keywords

... packed together in some testrobot.sikuli

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
""")

from sikuli import *

class LoginLibrary(object):
  def start_firefox_and_goto_testsite(self, page):
    popup("start_firefox_and_goto_testsite")
  def stop_firefox(self):
    popup("stop_firefox")
  def attempt_to_login_with_credentials(self, username, password):
    popup("attempt_to_login_with_credentials")
  def status_should_be(self, expected):
    popup("status_should_be")

Revision history for this message
Ryan (ryan-g2) said :
#7

Oooo, nice to hear it wasn't just me not doing something obvious :) And thanks for looking into this and fixing it.

I didn't see a nightly build that was built on the Night Build page. Before I dive in and try to figure out how to build from the raw bits, I'll see if a build is built tomorrow.

Revision history for this message
Ryan (ryan-g2) said :
#8

Hi RaiMan (or anyone else who is curious,

I thought I would share the steps I needed to take to get robot working now that a new build has been kicked off.

- I had to download the new nightly build of 1.1.1 (2016-05-19)
- I nuked my old SikuliX install and reinstalled the one from 05-19
- I downloaded the Robot zip file from here: http://download.sikuli.de/robot.zip
- I unzipped that zip file into %AppData%/SikuliX/Lib
- I pasted the test robot testcase directly into a new script in SikuliX from here: http://sikulix-2014.readthedocs.io/en/latest/scenarios.html#using-robotframework

The script ran and I see all the expected files - including the report files! WooOOO!

The reason I had to download the robot.zip file was because SikuliX was complaining, when I ran the script, before getting the zip, that a platform.py file was missing. Diffing the zip file against what SikuliX installs by default to the Lib/robot dir - the zip came in at a few K lighter, but contained ~4 extra files.

Now all I need to do is dive into how to tweak the report/script to my liking.

Revision history for this message
Ryan (ryan-g2) said :
#9

I should add that when I ran the script a 2nd time the .robot directory (that was created in the 1st run) was auto-deleted and the script complained it couldn't find any files. Another run of the script created all the files again and outputted everything.

I am not certain if this test script is supposed to do anything (as in actually launching firefox) because right now it is only popping up some messages with an OK button.

Revision history for this message
Ryan (ryan-g2) said :
#10

I think I figured out how to fix the '.robot' directory deleting itself.

I did not have 'from sikuli import *' in my script before the LoginLibrary class section.

I added that and now it seems to run each time.

Revision history for this message
RaiMan (raimund-hocke) said :
#11

with the latest nightly from today (2016-05-20) the RobotFramework support should work according to the docs:
http://sikulix-2014.readthedocs.io/en/latest/scenarios.html#using-robotframework

- no need for the extra steps as mentioned in comment #8 and #10 anymore
- when the script ends, the RFW report is automatically opened in your standard browser.

Revision history for this message
Ryan (ryan-g2) said :
#12

Thanks for the update! can't wait to try it!