Linking Eggplant AI Models to Snippets

Eggplant AI models of systems under test (SUTs) are built out of specific states and actions that take place within those states. SenseTalk code snippets from Eggplant Functional integrate with Eggplant AI to interact with SUTs. Snippets are connected to specific actions or states in your model. You can create snippets quickly in Eggplant Functional using Autosnippet generation.

What Are Snippets in Eggplant AI?

A snippet can be as simple as a single line of SenseTalk code that clicks a button in the UI, or it can be multiple lines of code that perform more complex actions, like reading a username or password from an external data file, then entering that information for a specific action step in a model. These pieces of code can be Eggplant Functional handlers.

As you build models, it’s useful to think about each action as a small, discrete activity that a user would perform while interacting with the application or software that you're testing. Following that method, you should be able to write simple SenseTalk snippets to perform those actions.

You can also look for actions that are the same, or very similar, in different states or areas of the model, so you can reuse the same code snippet to serve multiple purposes. SenseTalk is highly flexible and lends itself to this modularized approach to scripting.

You can find complete information about writing SenseTalk code in Eggplant Functional here:

Using the Snippets Tab

In Eggplant AI, your SenseTalk snippets appear in the Snippets tab in the left pane. Note that, for each model, you need to establish a connection to a specific Eggplant Functional suite through the Settings dialog box. See Connecting an Eggplant Functional Suite for complete instructions.

Additionally, your suite connection identifies a specific agent connection, and that agent must be running for your snippets to be available on the Snippets tab. See Working with the Eggplant AI Agent for complete instructions. When the agent is running and the model has a suite defined, the Snippets tab shows a green light indicator:

The Snippets tab in Eggplant AI with a connected Eggplant Functional suite

The Snippets tab displays all the scripts in the attached Eggplant Functional suite so that you can connect those scripts to actions in the model. You might want to create suites for specific applications or models that you are building within Eggplant AI; those suites should hold the snippets only for those models.

Within Eggplant AI, you can view the code for any snippet that appears in the Snippets tab. Right-click the snippet in the pane, then select View Snippet. The SenseTalk code opens in a new tab in the Console area at the bottom of the Eggplant AI window. You can have multiple snippets open at once, and you can close the tabs individually. Right-click in the Snippets pane, then select Clear Viewed Snippets to close all open snippet tabs in the Console.

To configure snippets to run tests on a SUT as your model runs, associate SenseTalk snippets with Eggplant AI states or actions:

  1. Select a state or action in the Model tab.
  2. In the Snippets tab in the left pane, right-click the script you want to add to the selection.
  3. Select Add to Selected from the context menu to add the chosen script to the state or action.

If necessary, you can connect multiple snippets to a single state or action.

Each action in the workspace has two dots in the upper-left corner. The left dot turns green when a snippet is attached. The right dot indicates if a submodel is attached. If you hover your cursor over a green dot, a tooltip shows what snippet or submodel is attached.

An Eggplant AI action with an attached submodel shows a green dot on the right

You can connect both snippets and submodels to the same action. When both snippets and submodels are attached to an action, snippets run first, followed by submodels.

Using the Properties Tab

You can use the Properties tab in the right sidebar to set or change properties for attached snippets. Select a state or action in the model workspace. Depending on your selection, the Action Properties or State Properties tab appears in the right sidebar. Note the following:

  • If you're looking at action or state properties, the Snippets called by section lists any snippets connected to the selected action or state. Select Disabled for any snippet that you don't want this model to execute.
  • In the Name field of the Snippets called by section, you can enter the name of a snippet that you want to connect to the selected action or state.

The Table view tab in the center pane also shows states and actions with any attached snippets.

You can modify the properties in the Snippets called by section using the Snippet Properties I/O Edit dialog box:

  1. Right-click the Snippets called by state or Snippets called by action pane.
  2. Select Edit Snippet Interface from the context menu.
    Note: The context menu lets you remove and view a snippet as well as opening the Snippet Properties I/O Edit pane.

    View the Snippet Properties I/O Edit dialog box

    The Snippet Properties I/O Edit dialog box

You can choose state or action variables for the script to use as inputs, outputs, or both, when a run encounters that state or action. Select Input, Output, or both in the dialog box.

For information about model states, see Defining States in Eggplant AI.

For information about model actions, see Creating Actions in Eggplant AI.

 

This topic was last updated on August 19, 2021, at 03:30:47 PM.

Eggplant icon Eggplantsoftware.com | Documentation Home | User Forums | Support | Copyright © 2022 Eggplant