[1.1.0] Can't open app directly from IDE on OS X

Bug #1556195 reported by Vasyl Romanko on 2016-03-11
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Sikuli
High
RaiMan

Bug Description

Environment:
OS X 10.11.3
SikuliX IDE 1.1.0 Build 2015-10-05_17:07
JDK 8u73

When I run .sikuli script directly from SikuliX IDE opened app immediately exits
For example, script contains:

myApp = App("Firefox")
myApp.open()

When I try to run the script from IDE I can see Firefox app's icon blinks for a second in Dock and then disappears. The same happens with openApp("Firefox") or switchApp("Firefox") commands.

If I run this .sikuli file directly from command line "/Applications/SikuliX.app/run -r ~/Applications/SikuliX/scripts/firefox.sikuli/" - it works correctly.

The issue doesn't reproduce with common OS X apps (I tried Safari, TextEdit, Terminal, Calculator etc.).
But it reproduces with non-common OS X apps (I tried FireFox, TextWrangler, Microsoft Word etc.)

RaiMan (raimund-hocke) on 2016-05-01
Changed in sikuli:
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → RaiMan (raimund-hocke)
milestone: none → 1.1.1
Krzysztof Guć (krzysiek-q) wrote :

Hi

It is problem in new El-Captain version.

Sikuli run Application using osascript:
osascript -e 'tell app "Application" to activate'

It working from terminal, but not from python subprocess

cmd=['osascript','-e','tell app "Firefox" to activate']
subprocess.Popen([cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()

It is becouse it is running not as logged user, and don't have acces to GUI.
It can be fixed adding "sudo"

cmd=['sudo','-u','LoggedUserName','osascript','-e','tell app "Firefox" to activate']
subprocess.Popen([cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()

In next step You can make switchApp
myApp=switchApp("Firefox")

args=['sudo','-u',user,'osascript','-e','tell app "Firefox"\n activate\n end tell']

It is problem with the user who run firefox it is not You, and he don't access to gui components.
You must add "sudo"

user='YourName'
args=['sudo','-u',user,'osascript','-e','tell app "Firefox"\n activate\n end tell']
subprocess.Popen(args,stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()

wait(2)
myApp=switchApp("Firefox")

RaiMan (raimund-hocke) wrote :

@Kristof ;-)
thanks for the evaluation. I will test it as soon as possible.

Changed in sikuli:
importance: Medium → High
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers