Autosnippet Generation in Eggplant Functional

During an Autoscan session, Eggplant Functional can generate scripts as well as images. The scripts that are generated contain a short section for each image from the session that has an Element Type set. These short sections, called Autosnippets, consist of one or more action handlers. Each handler in the generated script performs an action on or validation for an element that was identified in the Autoscan session.

New Feature: Autosnippets are available in Eggplant Functional 18.1 and later.

Autosnippets are useful for modularizing scripts, and can be imported as snippets in Eggplant AI.

Step by Step: Generate Autosnippets

  1. Complete an Autoscan session.
  2. Select the Element Type. Initially the Element Type is set to None. To generate Autosnippets code for an item, the Element Type must be set to one of the available types defined in the Autosnippet Templates file. The default types, which correspond to UI elements and their behaviors, are Checkpoint, Button, Field, Checkbox, RadioButton, DropDown_Mobile, and DropDown_Desktop.

    When at least one item has an Element Type other than None selected, the Script checkbox is enabled.

  3. Set the Element Name. By default, the Element Name is set to the image name or, if Use OCR was selected at capture, to the text OCR identifies. The Element Name is required and is incorporated in the handler names generated in the script.
  4. Select the Script checkbox, then click Generate. The script name defaults to the name of the Autoscan session. Select the Script and Images checkboxes to generate both scripts and images at the same time. The generated script opens in the Suite window. The script will contain Autosnippet code for each item with an Element Type other than None.
  5. Autosnippets are delineated by headers and dashed lines. This example shows the generated Autosnippet for an image called Sprout that's been assigned the Checkpoint type.

    (* Autosnippets for Checkpoint "sprout" *)

     

    to handle sprout_Validate duration

    if duration is not a number then set duration to 8

    WaitFor duration, imageName:"sprout"

    end sprout_Validate

     

    to handle sprout_IsFound duration

    if duration is not a number then set duration to 8

    return imageFound(imageName:"sprout", waitFor:duration)

    end sprout_IsFound

     

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

Autosnippet Templates

The default templates used to generate action scripts are stored in the AutosnippetTemplates.txt file in Eggplant Functional. If you want to customize the templates, create a local copy of the file, then adjust as needed:

  1. In Eggplant Functional, go to Eggplant > Preferences > Script.
  2. On the General tab, click Customize in the Autosnippet Template File section.
  3. A Save As window opens. Choose where to save a copy of the template file, and what to name that copy. Eggplant Functional saves the customized file and stores its location.
  4. Edit the file as needed. There are instructions in the file to guide you.

To select a different template file, click Browse and select the file to use, or enter its file path directly in the field. To revert to the default templates, delete the file path from the field.

 

This topic was last updated on 2月 01, 2019, at 11:13:23 午前.

Eggplant icon Eggplant.io | Documentation Home | User Forums | Support | Copyright © 2019 Eggplant