メインコンテンツまでスキップ
バージョン:26.2

Basic SenseTalk Scripting

SenseTalk is the English-like scripting language that is used to develop Eggplant Functional (EPF) scripts. This page discusses the most common SenseTalk functionality used by Eggplant Functional for testing purposes. Further learning resources are provided below. For an introductory description of the SenseTalk language and the philosophy behind it, see About SenseTalk.

ノート

You might notice that the SenseTalk language is displayed using colors, with individual elements shown in different colors. This is to aid in writing the scripts. Lines of code written in correct syntax are colored, while invalid syntax is not colorized. Colors can be modified in the Eggplant Functional Script Preferences.

Command and Function Basics

Commands and functions are used similarly, but there are some significant differences:

  • Functions always have return values; commands might have return values.
  • Functions are typically used as parameters to commands.
  • Commands must be written alone, not as part of a statement; functions must be part of a statement.

Syntax Guidelines

  1. Separate command and function parameters with commas:

    Example:

    Click "SomeImage", "SomeOtherImage"
  2. Enclose function parameters in parentheses:

    Example:

    ImageLocation("ThisImage", "ThatImage")

Methods for Identifying Elements

There are three primary methods EPF uses to work with elements on the screen of your SUT. Find by Description provides the most intuitive scripting experience, while image-based testing and optical character recognition (OCR) enable you to verify the exact visual display of elements, and work specifically with text, respectively:

  • Find by Description: Search for elements on the SUT screen by providing a description of the element to an LLM (Large Language Model).
  • Image-Based Testing: Capture images of elements on the SUT screen, which are then referenced from SenseTalk scripts in order to search for and interact with those elements.
  • OCR: Use optical character recognition to search for or read text on the screen of the SUT.

Each of these methods can be used in conjunction with any SenseTalk command or function, using the appropriate parameter.

Examples Using Different Search Types:

Each of the examples below searches for and clicks on the same "Login" button on the SUT using the click command, but with each of the different search methods.

To use Find by Description to click the "Login" button, you must first set up Find by Description. Once that is set up, simply script using natural language to describe the element you want to click:

click description: "Login button"

To use a captured image to click the "Login" button, you must first capture the image and save it in your suite. Then, reference that image in a SenseTalk script like this:

click image: "LoginButton"

To use OCR to find the word "Login" that is displayed on the button you want to click, provide the text string as a text parameter:

click text: "Login"
先端
Find by DescriptionFind by Description


If you are able to utilize its features, we recommend that you start your automation journey using Find by Description, as it provides the most intuitive scripting experience. Please note that use of this feature may incur additional costs in the form of tokens through your AI provider. For more information on tokens, see AI Model (LLM) Token Usage.

Data Types Used in Eggplant Functional Commands and Functions

Commands and functions in Eggplant Functionaluse a variety of data types: numbers, coordinates, strings, and property lists.

Numbers

Single numbers passed as parameters are not enclosed in quotation marks or parentheses.

Example:

ScrollWheelUp 10

Time

Time parameters are measured in seconds, unless you indicate otherwise. SenseTalk understands the terms weeks, days, hours, minutes, seconds, and milliseconds.

Examples:

Wait 75
Wait 1 minute 15 seconds

Coordinates

When numbers are given as coordinates, they are enclosed in parentheses.

Example:

Click (40,65)

Adjusted Coordinates

Eggplant Functional also allows vector arithmetic to generate a location relative to a known position.

Examples:

Click ((30,35) + (100,5))
Click (ImageLocation("SomeButton")+ (100,5))

Strings

Strings, such as file names and text literals, are enclosed in quotation marks.

Examples:

Click "CancelButton"
TypeText "Here is some text."

Note: Double angle-brackets << >> can enclose text that contains quotation marks and large blocks of text with return characters.

Property Lists

Property lists define or identify objects by listing certain properties. Each property comprises a key, which identifies what the property represents, and a value, which defines the property for the object.

Example:

Click (ImageName: "MenuButton", HotSpot: (10, 23))

The example above describes an image that is the same as the saved image called MenuButton, but with a different hot spot location: (10,23). The key ImageName represents the saved image that this property list is based on. The value of ImageName is MenuButton, the actual name of the image.

Property lists are always enclosed in parentheses, with a colon between each key and its value. Quick Reference: Property Lists contains tables of the types of property lists used in Eggplant Functional. For more information, see Property Lists.

Further Learning about SenseTalk

See the SenseTalk Reference for information to help you gain a thorough understanding of SenseTalk and how to use it.

Topics covered in the SenseTalk Reference include:

  • About SenseTalk: An overview of SenseTalk and how it works.
  • Key Elements: A one-hour introduction to SenseTalk for experienced programmers and inquiring minds.
  • The Basics: To use SenseTalk effectively, you'll need to understand values, containers, expressions, and control structures.
  • Objects and Messages: Gain a thorough understanding of messages and handlers, and objects and their helpers.
  • Working with Databases: Read the following information to better understand how you can use SenseTalk scripting to work with databases.
  • Commands and Functions: Learn how to manipulate text, perform calculations, and more.
  • GUI Automation Commands and Functions: SenseTalk methods for interacting with systems under test (SUTs). You can provide mouse or keyboard commands, search for images, or control connected mobile devices.
  • Local and Global Properties: In SenseTalk, local and global properties are system-wide values that determine behaviors of the run environment.

For reference tables of Eggplant Functional commands and functions, see Quick Reference: Eggplant Functional Commands and Quick Reference: Eggplant Functional Functions respectively.