Using scripts to automate testing



The Automated Testing panel in Device Central allows you to automate testing by playing back test scripts. Test scripts can be recorded in Device Central or written in JavaScript using the Script Editor. Test scripts can be applied to single or multiple devices, allowing you to perform batch testing of your content. A Log window is displayed at the end of each automated test session, that is, after all scripts and devices have been tested. The log file displays snapshots and output from your application.

To see a video tutorial about automating the testing of mobile content, visit the Adobe website at www.adobe.com/go/lrvid4063_dc.

Record a test script

You can record almost any action you would normally perform in Device Central. For example, you can navigate through your content using the keypad and change emulation conditions using the testing panels. You can even use the Take Snapshot command (Ctrl+R/Command+R) and have this instruction included in your script. The test script actions are saved to a script file that can be played back later.

Note: When recording a script, selecting different test devices or content types will cause the script to stop recording.
  1. Open a SWF file in Device Central.

  2. Make sure that no scripts are selected in the Automated Testing panel.

  3. Click Record.

    Recording begins immediately.

  4. Use the emulator to perform the actions you want to record.

  5. Click Stop to finish recording.

  6. Rename the new script by selecting it in the list of scripts and entering a new name.

Play back a single test script

  1. Open a SWF file in Device Central.

  2. In the Automated Testing panel, select the script to run.

  3. In the Device Sets or Local Library panel, select one or more devices on which to run the test.

  4. Click Play.

While the script is running, you can skip a device or cancel the automated test, if desired. When the test completes, the Log window displays the results of the test.

Note: If no device is selected and you click Play, the test runs on the currently emulated device.

Play back multiple test scripts

To play back multiple test scripts, the scripts must all be located in the same folder in the Automated Testing panel.

  1. Open a SWF file in Device Central.

  2. In the Automated Testing panel, select the folder containing the scripts you want to run.

  3. In the Device Sets or Local Library panel, select one or more devices on which to run the test.

  4. Click Play.

    Device Central plays back the scripts in the order they are listed in the folder. Each script is played once on each selected device.

While the script is running, you can skip a device or cancel the automated test, if desired. When the test completes, the Log window displays the results of the test.

Note: If no device is selected and you click Play, the test runs on the currently emulated device.

Overwrite an existing test script

  1. In the Automated Testing panel, select the script to overwrite.

  2. Click Record.

  3. Click OK in the dialog box to confirm that you want to overwrite the script.

Create a folder or subfolder

  1. In the Automated Testing panel, click New folder.

  2. Enter a name for the new folder.

  3. Drag and drop the new folder to the desired position in the list, including within another folder.

Delete a test script

  1. In the Automated Testing panel, select a test script.

  2. Click Delete.

    Important: Deleting a test script cannot be undone.

About the Log window

The Log window displays the output created during an automated test, along with any snapshots taken during the test. The Log window also displays snapshots that have been created manually. The Log window appears automatically at the end of each scripted test session, or it can be displayed by clicking the Show snapshots button. Alternatively, you can use Command+L (Mac OS) or Ctrl+L (Windows). Output is displayed for each device, with the latest test or snapshot displayed at the top of the window.

The Log window is cleared automatically when you Device Central exits. To retain a snapshot between sessions, use the Log window Export Snapshot as HTML option.

About the Script Editor

When you record a test script, Device Central creates a script. You can open the script and edit it manually, if desired, or you can write a script from scratch without using the recording feature.

The left panel of the Script Editor displays the list of scripts, and it reflects any changes made in the Automated Testing panel list. Each script opened in the Script Editor is displayed in a tab, making it easy to cut and paste between scripts. The Actions section of the Script Editor allows you to save scripts, check scripts for syntax errors, and navigate through scripts by function. The View Options section of the Script Editor allows you to colorize the code, display line numbers, and turn on word wrapping.

About test scripts

When you create a script, two empty functions are provided by default: the init() function and the idle() function. The init() function is called once when the script is loaded. The idle() function is called as often as possible while the script is running. An additional function, executeUpdate(), is generated for you when you record a script. The executeUpdate() function is called each time there is an update to the device screen.

You can also access the Device Central JavaScript DOM directly from SWF files, by using the ExecuteJSCommand command of the fscommand() function. For example, the following commands invoke the emulator.snapshot() function and provide access to global script variables, respectively:

fscommand("ExecuteJSCommand" "emulator.snapshot();"); 
fscommand("ExecuteJSCommand", "global_variable = 0;");

The elements of the JavaScript API are documented in the Adobe Device Central Scripted Testing API Reference.

Create a test script to edit manually

  1. In the Automated Testing panel, Click New script.

  2. Enter a name for the new script.

  3. Click Edit script.

Edit a test script

  1. Display the Script Editor by doing one of the following:

    • In the Automated Testing panel, click the Edit script button.

    • In the Automated Testing panel, double-click a script in the list.

    • Choose Window > Script Editor.

    • Press Command+E (Mac OS), Ctrl-E (Windows).

  2. Edit the script based on the information in the Adobe Device Central Scripted Testing API Reference