Mac OS X Web Automation and Testing Made Simple.

Fake Version 1.9.1    |    5.4 MB

Mac OS X 10.9 or later


MacWorld |  TidBits |  TUAW |  GigaOm

Understanding a few simple concepts will help you get the most out of Fake:

Use Fake to automate tedious web tasks by dragging discrete Actions into a sequence of runnable, repeatable, savable steps called a Workflow.

  • Action - a basic step, or unit of work, to be performed on the current webpage. Fake comes with more than two dozen Actions such as: Load URL, Do JavaScript, Set Value of HTML Element, Submit Form, and many more. Actions come from the Action Library and are combined to form a Workflow.

  • Workflow - each Fake browser window has a Workflow seen in the side panel on the right. Drag Actions from the Action Library into a Workflow to build the sequence of steps you want to perform. Fake Workflows can be saved and reopened using File→Save As… and File→Open…. Workflows are saved with the file extension .fakeworkflow.

  • Action Library - this floating panel is a searchable repository of available Actions which can be dragged into your workflow. If you don't see the Action Library panel, select the Window→Action Library (⌥⌘L) main menu item. To add an Action to a Workflow, click and drag one of the Actions in the Action Library to your Workflow. Or, double-clicking an Action in the Action Library will also append it to the end of your frontmost Workflow.

  • Variable - an advanced feature of Fake, Variables allow you to store a value once which can then be accessed multiple times in a Workflow. Variables can be set in two ways:

    1. Using the Set Value of Variable Action found in the Action Library.

    2. Using JavaScript by calling window.fake.set("myVarName", "some value") in a Do JavaScript Action.

    Once you have set a Variable's value, it may be accessed in one of the following ways:

    1. Typing ${myVarName} into any Action's text field.

    2. Calling window.fake.get("myVarName") in a Do JavaScript Action.

    3. Calling (get system attribute "myVarName") within a Run AppleScript Action.
  • Connecting - many Fake Actions require you to specify an HTML element in the webpage. HTML elements can usually be specified by their id or name attribute, or by XPath or a CSS selector. Discovering these element specifiers can be difficult and tedious. Fake offers a simple way to Connect an Action to an HTML element on the current page by holding the control key while dragging from an Action to an HTML element on the page.

  • Disabled Actions - Any Action in your Workflow can be disabled. Right click on an Action and select Disable Action from the context menu to disable (or Enable Action to re-enable). Alternatively, select the Action and activate Workflow→Toggle Action Disabled (⌥⌘E) in the main menu. When disabled, an Action will appear visually dimmed.

  • Collapsed Actions - Since vertical space is at a premium in the Workflow side panel, any Action can be collapsed. To collapse or expand an Action, click the disclosure triangle in its title bar or just double click the Action. Alternatively, select Workflow→Collapse Action (⌥⌘←) or Workflow→Expand Action (⌥⌘→) from the main menu. When collapsed, Actions show an alternate title with a "hint" as to its current settings.

  • Labeled Actions - For easier identification of Actions in your Workflow, Label them with a color. To Label an Action, right click it and select a color from the context menu that appears.

  • Delays - By default, Fake inserts a half-second delay between running Actions, which makes it easier to visually follow the progress of a Workflow. Sometimes, however, speed is more important. The default delay can be changed by activating the Fake→Preferences (⌘,) main menu item, and selecting the Workflow Preference Pane. There you'll find an option for setting the default delay.

    For more fine-grained control over delays between specific Actions in a Workflow, use the Delay Action found in the Action Library.

  • Looping with Repeat - To execute portions of your Workflow multiple times, surround some Actions in Repeat and End Repeat Actions. The Repeat Action will continue to loop while its specified condition is true.

    For/in loops with Repeat Actions - For/in looping logic in Workflows is possible with the Repeat With Action paired with the End Repeat Action. In the Repeat With Action, specify a variable name in the variable named text field and some collection of items (like HTML Elements on the current webpage or a JavaScript Array of values) using the in specifier. The Repeat With Action will iterate over the collection while assigning the item at the current index to a variable with the variable name specified.

    While a Repeat or Repeat With Action is executing, the JavaScript window.fake object contains a loop property which provides information about the current loop iteration. window.fake.loop.index contains the loop's current index, and window.fake.loop.length contains the loop's total length.

    Breaking out of a Repeat loop early can be done with the Exit Action and skipping to the beginning of the next Repeat loop is accomplished with the Skip action. Note that Repeat loops may be nested, and a Exit Action placed outside of a Repeat loop will halt execution of the entire Workflow.

  • Conditionals with If/Else - Conditional branching is possible with the If, Else If, Else, and End If Actions. Note that Else and Else If Actions are optional, and conditional branches can be nested.

  • Handling Errors - Inevitably, your Workflow will encounter fatal errors. A webpage will fail to load, a specified HTML element won't be found, or any number of other bad things will happen. When an Action encounters an Error, it is highlighted red, the Workflow execution stops, and Fake emits an error beep (you can disable these sounds in the Workflow preference pane of the Preferences window). To handle these errors, add a Push Error Handler Action to the beginning of your Workflow and use it to specify some behavior to respond to the error. Selecting Continue in the Push Error Handler Action will allow Workflow execution to continue after the error is handled. A stack of error handler actions is maintained by the Workflow, so popping the most recent error handler Action using the Pop Error Handler Action will restore any previous Push Error Handler Action as the current handler.

  • Assertions - Web developers can create automated tests for their Web Applications by leveraging Fake's support for Assertions. After adding a Push Assertion Failure Handler to the beginning, sprinkle your Workflow with Assert Condition Actions which assert expected aspects of the current webpage.

    For more complex assertion logic, assertions can be done in JavaScript as well. In a Do JavaScript Action use the window.fake.assert(condition, message) function.

    For more complex assertion failure handling logic, use a Push Assertion Failure Handler Action with the Do JavaScript option selected. In the JavaScript text field which appears, you can add complex JavaScript logic for handling the assertion failure. Run AppleScript and Run Unix Script are two similar options which also allow more complex assertion failure handling.

  • Wildcards and Regular Expressions - Many Actions which specify attributes or HTML elements on the current webpage accept Wildcards and Regular Expressions as their specifiers. Wildcards allow you to match any run of text using a * character. While Regular Expressions can be used by wrapping a specifier in / / characters.

  • Userscripts and Userstyles - allow you to alter any webpage by executing custom JavaScript or evaluating custom CSS when the page loads. Set this up in the Userstyles window by selecting the Window→Userscripts (⌃⌘U) main menu item. From there, add your custom JavaScript or CSS along with a URL pattern for which it should be matched.

  • Web Inspector - If you're a Web Developer, the same Web Inspector you've come to know and love from Safari is available in Fake, too. Activate the Window→Web Inspector (⌥⌘I) main menu item for the Web Inspector or Window→Error Console (⌥⌘C) for the Error Console.

Fake is developed and maintained by Todd Ditchendorf of Celestial Teapot, creator of Fluid, Shapes, and Runway.

Copyright © Todd Ditchendorf. All rights reserved.