type() not working on Mac

Asked by Robert Gormley

Saw a posted reply for Windows with the solution being:
type(Key.BACKSPACE) or type(Key.DELETE)

Neither one of these options works for me. I'm simply trying to write a clean-up script. The script returns the "system under test" back to a default state after the test run. The key for me is that the application is being run on a Mac and the two methods above don't seem to work. I have Sikuli focus the cursor on the field and the value is highlighted but then the methods above don't delete out the existing text. How can I get this to work?

Thanks!

Question information

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

On Mac, other than on Windows, the first click on a GUI element, only acts on the GUI element, if the application window already has the focus. This is generally not the case when running a Sikuli script.

So you first have to focus to your application somehow, before starting any actions in that application.

You might use switchApp() or App.focus() to get the application frontmost and focused.

Or you use a click() on an area of the app window, that has no effect, but brings the window to front and makes it focused.

Can you help with this problem?

Provide an answer of your own, or ask Robert Gormley for more information if necessary.

To post a message you must log in.