Top 10 SenseTalk Commands and Functions for Eggplant Functional Scripting
Eggplant Functional (EPF) provides multiple ways to create your test scripts and code snippets, including Turbo Capture sessions, Autosnippet Generation, and Assisted Scripting. Each of these methods interacts with the SUT Viewer window to help you generate SenseTalk code in the Script Editor.
However, you still need to review and revise your code, and you’ll probably need to manually create more advanced SenseTalk scripts eventually. For those situations, here's a quick top 10 list of useful SenseTalk commands and functions, along with some tips about when and where you might want to use them.
Keep in mind that EPF has three main methods of searching for elements on the screen of your system under test (SUT):
- Find by Description: Search for elements on the SUT screen by providing a description of the element to an AI model (LLM).
- 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.
1. The Click Command
You can use AI searches with this command.
For more information, see Find by Description.
Use the Click command to click a location on your system under test (SUT) just as you would with the mouse button. The Click command is useful for interacting with the SUT in a variety of ways, such as clicking buttons, icons, links, checkboxes, and menu options. You can also use it to click in a field so that you can enter text there, or otherwise click any area of the SUT screen to set the focus of the mouse pointer.
This command can be used with any of EPF's methods of searching for elements on the SUT. Here are examples of the click command being used with each of these different methods:
Example: Using Find by Description with a Click Command:
You can perform a click command by using AI functionality through a Find by Description search:
click description:"the house icon" -- Uses the functionality of an AI model to search the SUT for a home button, which looks like a house, and click it
Example: Using a Captured Image with a Click Command:
You can also use click by providing a captured image reference to interact with:
Click "Launch_Chrome" -- Searches the SUT screen for a match of the "Launch_Crome" image, and performs a click at the location of the hot spot of that image
Example: Using OCR with a Click Command:
You can also use OCR functionality with click:
Click text:"Eggplant" -- Performs a click action at the screen location where OCR finds the indicated text
If you are testing against mobile device SUTs, you might choose to use the Tap command instead of Click because a tap is a more natural way to think of the user action on those devices. However, the Click and Tap commands are functionally the same, and both can be used on either desktop or mobile OSs.
Related
- Mouse Events and Control: Learn about related commands such as
DoubleClick,DoubleTap,RightClick, and so forth. - The Hot Spot: Learn how to move the image hot spot so that your click action takes place somewhere other than the center of the image, including outside of the image.
- Image Property List: Find out about the additional properties you can use with
Click(and any image search) to improve your scripting.
2. The TypeText Command
The TypeText command sends keystrokes to the SUT, so it's useful for entering all types of keyboard input. You can enter text in documents or use it to enter data in form fields, such as when you need to automate entering a username and password on a web page or application.
You can use this command to send keyboard commands that work within applications, such as Ctrl+C for copy and Ctrl+V for paste. You can also send keyboard commands that control aspects of the OS, such as Alt+tab (Windows) or Cmd+tab (Mac) to switch between applications.
Example: Sending Literal Text with a TypeText Command:
To send literal text, enclose the text in quotes:
TypeText "Hello World!" -- Sends the text string to the SUT
Example: Sending Non-Character Keys with a TypeText Command:
You can send non-character keys by using TypeText keywords:
TypeText AltKey,F4 -- Sends the necessary keystrokes to the SUT to close an app on desktop
TypeText PageDown -- Sends a Page Down keyboard action to scroll down the page
Example: Combining Character and Non-Character Keys with a TypeText Command:
You can combine both character and non-character keys as well:
TypeText "Line1", Return, "Line2" -- In a text document, this command would print the two strings on separate lines, with a return character between
The TypeText command can complete successfully even if it appears nothing happens on the SUT. For instance, if you send characters to be typed when the current focus area can't accept text input, the keystrokes get sent but typically nothing changes.
Similarly, if you send a keyboard command, such as Ctrl+V, and there's nothing in the clipboard, the command successfully executes but has no effect on the SUT. Therefore, it's important to know the condition of the SUT and to ensure you have the focus on the desired part of the screen or application when using this command.
Related
- Typing on the SUT: See more detailed information about using
TypeTextand working with text. - TypeText Keywords: See the list of SenseTalk keywords you can use with
TypeTextcommands, including many that are unique to iOS and Android mobile devices. - Keyboard and Clipboard Events: Learn about additional commands and functions for working with keyboard input.
3. The WaitFor Command
You can use AI searches with this command.
For more information, see Find by Description.
The WaitFor command halts the script execution until a specified element (when using Find by Description), image (when using captured images), or text string (when using OCR) is found on the SUT or until a specified amount of time elapses — whichever occurs first. This behavior lets you verify that an element is present or that the SUT is in the correct state before you proceed to the next step. Therefore, the WaitFor command is useful for both timing and verification in your scripts.
At its most basic, you provide the WaitFor command with an image to search for and a time value, which is the longest you want the script to wait for that image to appear. As soon as the image is found, the script continues, regardless of how much time has passed. If the image isn't found within the time specified, an exception is thrown.
Additional variations of WaitFor include WaitforAll, WaitForNotFound, and WaitForColor.
Example: Using Find by Description with a WaitFor Command:
You can perform a WaitFor command by using AI functionality through a Find by Description search:
WaitFor 20, description:"The installation is complete!" -- Waits for an installation to complete by waiting for a completion message to appear
Example: Using a Captured Image with a WaitFor Command:
Wait for an image to be found:
WaitFor 15, "Launch_Chrome.png" -- Proceeds immediately when the image is found or throws an exception if it isn't found within 15 seconds