| Recipe 37 | Drive a Mac GUI Using AppleScript and System Events |
Problem
You want to write Cucumber tests that exercise a Mac application through its user interface.
Ingredients
-
System Events,[244] an Apple-provided API for simulating GUI events
-
rb-appscript,[245] a bridge between Ruby and AppleScript
-
Command-Line Tools for Xcode[246] to compile rb-appscript
Solution
Since the 1980s, Mac users have customized and automated their systems using the built-in AppleScript environment. Initially, this technology relied on software vendors to make their apps’ features available in AppleScript. Now, users can perform basic GUI automation of just about any program through an AppleScript API known as System Events.
In this recipe, we’re going to write ...