SikuliXIDE; Mojave; Robot Framework: ArrayIndexOutOfBoundsException: 1

Asked by Melvin Raymond

Using the following Configuration:
- SikulixIDE-1.1.4-SNAPSHOT (updated to latest today)
- Robot Framework

I had previously built a script that worked fine with another application which could do a Suite Setup, Suite Teardown, and a Test Case Teardown. I took that same script and edited down to verify I could adopt it to another one of our applications. The intent is to be able to use a skeleton (or template per se) on different applications. I simply copied the working script, edited it so it would work on one of our other Desktop applications, and created a new Suite for it. This script code appears to work and do everything it is intended to do, but it generates an out of bounds error on an array. See below:

FAIL ArrayIndexOutOfBoundsException: 1

Below is the script.

runScript("""
robot
*** Variables ***
${TESTAPP} "/Applications/GraphicalAnalysis.app"

*** Settings ***
Library ./inline/GA4
Suite Setup Suite Setup Actions
Suite Teardown Suite Teardown Actions
Test Teardown Test Case Tear Down
*** Test Cases ***
Test TestCase1
    [Documentation] This is just a test case to help me verify Test Teardown gets called
    Log TestCase1 has been executed

*** Keywords ***
Suite Setup Actions
    Log Suite Setup Actions done below
    prepare my application ${TESTAPP}

Suite Teardown Actions
    Log Suite Teardown Actions done below
    stop my application ${TESTAPP}

Test Case Tear Down
    Log Test Teardown Actions done below
    prepare test case ${TESTAPP}

""")

class GA4(object):
  def prepare_my_application(self, myApp):
    startedmyapp = App.open(myApp)

  def stop_my_application(self, myApp):
    stoppedmyapp = App.close(myApp)

  def prepare_test_case(self, myApp):
    wait(2)

Question information

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

where exactly do you get the exception?

Revision history for this message
Melvin Raymond (fribian) said :
#2

TEARDOWN Suite Teardown Actions

It appears to have actually closed my app as expected even though it got the array error.

Revision history for this message
Melvin Raymond (fribian) said :
#3

KEYWORD GA4 . Stop My Application ${TESTAPP}
Start / End / Elapsed: 20190311 13:05:21.224 / 20190311 13:05:34.521 / 00:00:13.297
13:05:34.521 FAIL ArrayIndexOutOfBoundsException: 1

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

You should test your

class GA4(object):

outside RFW in an extra script:

class GA4(object):
  def prepare_my_application(self, myApp):
    startedmyapp = App.open(myApp)

  def stop_my_application(self, myApp):
    stoppedmyapp = App.close(myApp)

  def prepare_test_case(self, myApp):
    wait(2)

test = GA4()
myApp = "/Applications/GraphicalAnalysis.app"
test.prepare_my_application(self, myApp)
...

to get a regular exception with a stack trace

Revision history for this message
Melvin Raymond (fribian) said :
#5

OK, that was interesting. Didn't know how to do that, but now I do. I ran the following script and it appears to have opened my app, and closed it. However, on the test.stop_my_application(myApp) I got the following error after running this new script:

class GA4(object):
  def prepare_my_application(self, myApp):
    startedmyapp = App.open(myApp)

  def stop_my_application(self, myApp):
    stoppedmyapp = App.close(myApp)

  def prepare_test_case(self, myApp):
    wait(2)

test = GA4()
myApp = "/Applications/GraphicalAnalysis.app"
test.prepare_my_application(myApp)
test.prepare_test_case(myApp)
test.stop_my_application(myApp)

ERROR WITH TRACEBACK BELOW:

[error] script [ Raiman-test ] stopped with error in line 15
[error] java.lang.ArrayIndexOutOfBoundsException ( java.lang.ArrayIndexOutOfBoundsException: 1 )
[error] --- Traceback --- error source first
line: module ( function ) statement
6: main ( stop_my_application ) stoppedmyapp = App.close(myApp)
[error] --- Traceback --- end --------------

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

I have no idea, where this error comes from.

I made the following test with the latest build of 1.1.4:

class GA4(object):
  def prepare_my_application(self, myApp):
    self.stoppedmyapp = False
    self.startedmyapp = App.open(myApp, 5)

  def stop_my_application(self, myApp):
    self.stoppedmyapp = App.close(myApp)
    if self.stoppedmyapp:
      self.startedmyapp = None

  def prepare_test_case(self, myApp):
    wait(2)

  def status(self):
    print "started:", self.startedmyapp, "\nstopped:", self.stoppedmyapp

test = GA4()
test.prepare_my_application(appName)
test.status()

test.prepare_test_case(appName)

test.stop_my_application(appName)
test.status()

which ran without errors and printed:
started: [33624:Automator ()] Automator.app
stopped: False
started: None
stopped: True

BTW: seems you are using real tabs for indentation. this makes problems, when copying snippets to the outside (like here).
check that you have switched on in the Prefs:
Tab keys insert spaces ...

Revision history for this message
Melvin Raymond (fribian) said :
#7

Thank you Raiman for the reply.

I think there is some kind of bug in the App.close(myApp) class for Jython or Python.
I checked my preferences settings and it is indeed "on" for converting tabs to spaces, and with 4 spaces per tab
I'm still getting the "java.lang.ArrayIndexOutOfBoundsException: 1"

I RAN THE FOLLOWING SCRIPT (Which appears to have opened the app, ran the test, closed the app):

class GA4(object):
  def prepare_my_application(self, myApp):
    self.stoppedmyapp = False
    self.startedmyapp = App.open(myApp, 5)

  def stop_my_application(self, myApp):
    self.stoppedmyapp = App.close(myApp)
    if self.stoppedmyapp:
      self.startedmyapp = None

  def prepare_test_case(self, myApp):
    wait(2)

  def status(self):
    print "started:", self.startedmyapp, "\nstopped:", self.stoppedmyapp

test = GA4()
appName = "/Applications/GraphicalAnalysis.app"
test.prepare_my_application(appName)
test.status()

test.prepare_test_case(appName)

test.stop_my_application(appName)
test.status()

TEST GENERATED THE FOLLOWING ERROR:

started: [1414:Vernier Graphical Analysis (Vernier Graphical Analysis)] /Applications/GraphicalAnalysis.app
stopped: False

[error] script [ Raiman-test-2 ] stopped with error in line 24
[error] java.lang.ArrayIndexOutOfBoundsException ( java.lang.ArrayIndexOutOfBoundsException: 1 )
[error] --- Traceback --- error source first
line: module ( function ) statement
7: main ( stop_my_application ) self.stoppedmyapp = App.close(myApp)
[error] --- Traceback --- end --------------

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

Indeed seems to be a close() problem on Mac:
the process name (Vernier Graphical Analysis) differs from the app name (GraphicalAnalysis)

try wether this works:

instead of
test.stop_my_application(appName)

use
self.startedmyapp.close()

If this works, you have to try that in the RFW context.

I will post the problem you found as a bug.

Revision history for this message
Melvin Raymond (fribian) said :
#9

Interesting. Yes, I had renamed the application to shorten it and so I wouldn't have to worry about spaces in the name. I should probably name it back to the proper name and figure out how to use it properly. It was a shortcut for me to get things running, but we found a bug someone else might run into, so I guess that is a good thing. Thank you Raiman for all the help. By the way, I found a workaround for closing my application by using the keyDown(Key.CMD + Key.ALT + Key.SHIFT + Key.ESC) just before I went home yesterday. One has to be careful with it though or you might close the wrong application, so you'd have to ad something like exist to make sure you're hitting the correct app, and then check it again to make sure it actually close after a certain period of time. Some other projects have hit the deck, so I'll have to postpone anymore fun till later. Thank you sir!

Revision history for this message
Melvin Raymond (fribian) said :
#10

Interesting. Yes, I had renamed the application to shorten it and so I
wouldn't have to worry about spaces in the name. I should probably name it
back to the proper name and figure out how to use it properly. It was a
shortcut for me to get things running, but we found a bug someone else
might run into, so I guess that is a good thing. Thank you Raiman for all
the help. By the way, I found a workaround for closing my application by
using the keyDown(Key.CMD + Key.ALT + Key.SHIFT + Key.ESC) just before I
went home yesterday. One has to be careful with it though or you might
close the wrong application, so you'd have to ad something like exist to
make sure you're hitting the correct app, and then check it again to make
sure it actually close after a certain period of time. Some other projects
have hit the deck, so I'll have to postpone anymore fun till later. Thank
you sir!

On Wed, Mar 13, 2019 at 3:12 AM RaiMan <email address hidden>
wrote:

> Your question #679122 on Sikuli changed:
> https://answers.launchpad.net/sikuli/+question/679122
>
> Linked to bug: #1819878
> https://bugs.launchpad.net/bugs/1819878
> "[1.1.4] Mac: App::close(): has problems when app name differs from
> process name"
>
> --
> You received this question notification because you asked the question.
>

--
Mel Raymond - Quality Assurance Engineer
<email address hidden>

Vernier Software & Technology

13979 SW Millikan Way

Beaverton, OR 97005

www.vernier.com

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

Ok, all the best.

We should close this thread now.
If you come up with new issues, pleas post a new question.

Revision history for this message
Melvin Raymond (fribian) said :
#12

OK, I agree. We should close.