HoWTo: Mac: capture menus and popups - deal with images on retina displays

Asked by venkatesh on 2017-02-17

******* capture menus and popups
SikuliX IDE has a capture hotkey defined, that can be used this way:
- have the IDE open and prepared for capturing (e.g. image = )
- drive your app to the situation, where your need to capture something
- (do not go back to the IDE in this moment)
- press the capture hotkey
- back in the IDE you will find the image added
hotkey Mac: shift-cmd-2
Windows/Linux: shift-alt-2
(can be modified in the preferences)

******* images captured with Mac capture feature on Retina displays
internally on Macs with Retina displays, native images have 4 pixels for one normal pixel, leading to double width and height. Without manipulation these images cannot be used with SikuliX. The capture in SikuliX (IDE) works because since Java 1.7/1.8 this is internally handled by Java. The trick is to simply resize the images to 50%. Currently this has to be done manually for images captured outside the IDE.

A workaround from comment #3:
one suggested solution is to use automator to write folder filter action to scale image to 50% when ever an image is created.

Another workaround:
If you know, that you are working with retina images, then you can resize them before use (SikuliX 1.1.1+):
img = Image("your_retina_image_name.png").resize(0.5)
... and now use img instead of "your_retina_image_name.png"

I guess, I will find a way to make this automatically internally in the future ;-)

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

Description of my issue: unable to capture My OSX app options screenshot from Sikulix IDE

More Detailed Description:
I am trying to use sikulix and java to automate our OSX application testing. When I use CMD+Shift+4 to capture the screen on my MAC, and try to click on the image by using s.click(pattern), i am getting region find failed.

There was another question of the same sort having screen capture resolution issues if we are using retina display MAC.

So I am using Sikulix IDE to capture the screen shots and using them in my java program.

Now the problem is that i am unable to capture my osx app options from sikulix ide because as soon as i click on any option in sikulix, My app options disappear on the top and I see sikulix option. so i am unable to capture region of my app options.

Can some one tell me
1. why am i unable to use images which are captured using CMD+Shift+4 . whats the workaround i need to do to make this images work for my sikulix java automation
2. using sikulix ide,, how can i capture other destop app options?

Question information

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

instead of clicking the capture button in the IDE, prepare the application and then press the capture hotkey
shift-cmd-2 on Mac.

TestMechanic (ndinev) said : #2

On such situation wit popum menus that disappear I am using OS native prinscreen option. Then getting my UI elements from the storage image as usual.

BTW: MAC retina display is a problem. For now we are just avoiding capturing images and runing tests on retina display

venkatesh (venkateshvelaga) said : #3

I found that ratina display by default gives double depth images which results in 2x resolution. one suggested solution is to use automator to write folder filter action to scale image to 50% when ever an image is created. the solution works for me.