Problem running SikuliX-1.1.1 with Robot Framework on Ubuntu 16.04

Asked by Joan Muggleton on 2017-01-03

After downloading and installing SikuliX-1.1.1, I was able to run the RF script within the IDE, but the test didn't open the Firefox browser.
Following directions in http://sikulix-2014.readthedocs.io/en/latest/scenarios.html#using-robotframework
downloaded SikuliX Setup 1.1.1 (2016-12-10)
OS: ubuntu 16.04
Python version = 2.7.12
java version "1.8.0_111"

Installed into ~/.SikuliX (empty directory)
Pack1: SikuliX containing the Sikuli IDE and allowing Sikuli scripts from commandline
ran successfully
Started Sikuli on the command line with:
./runsikulix
which brought up the Sikuli IDE
I then cut and pasted in the test_sikuliX inline script
Clicked save and run in the IDE
Got console output:
joan@joan-Latitude-E7250:~/.Sikulix$ ./runsikulix
running SikuliX: -Xmx512M -Dfile.encoding=UTF-8 -Dsikuli.FromCommandLine
-jar ./sikulix.jar
[info] runcmd: lsb_release -i -r -s
[info] HotkeyManager: add Capture Hotkey: CTRL+SHIFT 2 (50, 3)
[info] HotkeyManager: add Abort Hotkey: ALT+SHIFT C (67, 9)
==============================================================================
test sikuliX
==============================================================================
User can log in with correct user and password
-------------------------------------
The script stops at this point, doesn't bring up firefox
issues the first prompt from the RF script
I click through the rest of the prompts and the test runs to conclusion with the report.html all green, no errors
but the test does not close the browser and exit

I am running geckodriver v0-1.11-linux instead of Firefox

running Firefox (geckodriver) browser on

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
2017-01-05
Last query:
2017-01-05
Last reply:
2017-01-04
RaiMan (raimund-hocke) said : #1

Before doing more complex things, you should assure, that Firefox/Geckodriver gets started at all in this scenario.

BTW: Python is not relevant for SikuliX, since it uses the bundled Java based Jython.

Joan Muggleton (jmuggleton) said : #2

Thank you for your speedy reply!

I am able to open Firefox/Geckodriver with Robot Framework 2.8.2 with the pybot command, but not sure how to test in this scenario since I'm not getting any errors in the output.

Joan Muggleton (jmuggleton) said : #3

This is the script I pasted into the IDE, then clicked Run in the Run dropdown.

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

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

-------------------------------------------------------------------------------
This is the output in robot.html:
Test Execution Log

00:00:25.898SUITE test sikuliX
Full Name: test sikuliX
Source: /home/joan/test_sikuliX.sikuli.robot/test_sikuliX.robot
Start / End / Elapsed: 20170103 00:05:59.553 / 20170103 00:06:25.451 / 00:00:25.898
Status: 2 critical test, 2 passed, 0 failed
2 test total, 2 passed, 0 failed
00:00:22.482TEST User can log in with correct user and password
Full Name: test sikuliX.User can log in with correct user and password
Start / End / Elapsed: 20170103 00:05:59.803 / 20170103 00:06:22.285 / 00:00:22.482
Status: PASS (critical)
00:00:06.690SETUP LoginLibrary . Start Firefox And Goto Testsite ${TESTSITE}
Start / End / Elapsed: 20170103 00:05:59.807 / 20170103 00:06:06.497 / 00:00:06.690
00:00:01.174KEYWORD LoginLibrary . Attempt To Login With Credentials ${USERNAME}, ${PASSWORD}
Start / End / Elapsed: 20170103 00:06:06.501 / 20170103 00:06:07.675 / 00:00:01.174
00:00:13.786KEYWORD LoginLibrary . Status Should Be Accepted
Start / End / Elapsed: 20170103 00:06:07.676 / 20170103 00:06:21.462 / 00:00:13.786
00:00:00.818TEARDOWN LoginLibrary . Stop Firefox
Start / End / Elapsed: 20170103 00:06:21.465 / 20170103 00:06:22.283 / 00:00:00.818
00:00:03.154TEST User cannot log in with invalid user or bad password

RaiMan (raimund-hocke) said : #4

Uuups, this is the demo example ;-)

It is only prose and does nothing: the popups are the placeholders for the implementation of what has to be done in a keyword.

This means, you have to setup your environment with SikuliX, so that you have access to the features to start Firefox in a way, as you do it in your Python (pybot) environment.

But be aware:
Since the ecosystem with SikuliX is based on Jython/Java, there might be problems with stuff, that works in your Python environment if it is not pure Python and contains C-based stuff.

Conclusion: It is possible, but depending on your knowledge and insight, it might be hard to get on the road this way.

Joan Muggleton (jmuggleton) said : #5

Okay, I think I see what you mean.

My goal is to embed Sikuli in RF tests, so I run all the Robot Framework
tests from Jenkins, both Python-based and SikuliX tests, so for Sikuli
tests I don't need to use the Python-based environment. Is it possible to
use some kind of RF Sikuli keywords in the jython/java environment?

Should I reinstall SikuliX-1.1.1 with Pack2?

On Tue, Jan 3, 2017 at 4:53 AM, RaiMan <<email address hidden>
> wrote:

> Your question #426645 on Sikuli changed:
> https://answers.launchpad.net/sikuli/+question/426645
>
> Status: Open => Answered
>
> RaiMan proposed the following answer:
> Uuups, this is the demo example ;-)
>
> It is only prose and does nothing: the popups are the placeholders for
> the implementation of what has to be done in a keyword.
>
> This means, you have to setup your environment with SikuliX, so that you
> have access to the features to start Firefox in a way, as you do it in
> your Python (pybot) environment.
>
> But be aware:
> Since the ecosystem with SikuliX is based on Jython/Java, there might be
> problems with stuff, that works in your Python environment if it is not
> pure Python and contains C-based stuff.
>
> Conclusion: It is possible, but depending on your knowledge and insight,
> it might be hard to get on the road this way.
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/sikuli/+question/426645/+confirm?answer_id=3
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/sikuli/+question/426645
>
> You received this question notification because you asked the question.
>

Joan Muggleton (jmuggleton) said : #6

Overall, here's what I'm trying to do.

I have been running a number of Python-based RF tests in virtual (headless) mode on an Ubuntu 16.04 slave, from Jenkins service on a Windows VM, using the Xvfb plugin,. For some of the RF tests I embedded RF AutoIT keywords to handle the non-web elements that could not be reached by Selenium. I can run these tests in the foreground on the Windows VM, but need to find a way to run these tests in headless mode. So I want to re-write those tests in Sikuli, then try to run from the Jenkins Xvfb plugin. I'm not sure it will work, but I've seen enough comments to think it may be possible.

I'm open to any solution or suggestion you might have.

Best RaiMan (raimund-hocke) said : #7

About Jenkins/Xvfb and SikuliX you will not get any help here I guess (I myself do not have any experience with it).
Stackoverflow is a better place to look and ask.

With respect to RFW:
The challenge here is to define the relevant keywords in library (click, find, ....). There are some library packages out there, but most of them use earlier versions of SikuliX and have limitations. But you may take one of them as a good starting point.

I recommend to setup your own RFW/Jython environment and use jybot to run your tests. Nevertheless it is possible to make the first steps and tests on a "real" system using the SikuliX IDE convenience approach with an external library as mentioned in
http://sikulix-2014.readthedocs.io/en/latest/scenarios.html#using-robotframework

Joan Muggleton (jmuggleton) said : #8

Thank you for your help - you have confirmed my suspicion that I would need to put far more effort into this solution, but have pointed me in the right direction!