Skip to main content

Improving Script Execution Speed

When you begin writing longer SenseTalk scripts and using advanced scripting techniques in Eggplant Functional, you might soon need to address the overall execution speed of your tests. Adjusting your runtime by even a few seconds here and there can make a huge difference when you’re running a large number of complex scripts.

SenseTalk provides many methods for speeding script execution. The methods described here should all help your scripts run faster, but you will need to determine which ones best suit your specific testing scenarios.

Lowering the SUT Interaction Time

One of the best things you can do to improve script execution time is to adjust the RemoteWorkInterval global property. This property controls the amount of time between events before Eggplant Functional sends the next event to the system under test (SUT). By lowering the RemoteWorkInterval global property value in your scripts, your scripts should run quicker.

The default value for this global property is .7 seconds. To reduce the RemoteWorkInterval to, for example, .3 seconds, add the following SenseTalk command to your scripts:

set the remoteWorkInterval to .3

With this adjustment, the time that the SenseTalk script pauses between events decreases to .3 seconds.


The optimal value for the RemoteWorkInterval global property depends on environmental factors, such as server resources and network speed. After testing your scripts, you might need to further adjust the RemoteWorkInterval value to suit your environment.

Setting the RemoteWorkInterval global property within your script makes it easy to increase and decrease this property value during runtime. You can use this method if you have sections of a script that require different delay times between actions. Additionally, putting the timing adjustment within the script makes the adjustment portable if you are sharing scripts or suites across a team.

Remote Work Interval Preference Setting

If runtime adjustments are not important to your scripting, you can adjust the RemoteWorkInterval global property through Eggplant Functional Preferences:

  1. Select eggPlant > Preferences
  2. Select the Run tab, then the System tab.
  3. Set your preferred value for the Remote Work Interval.

Setting a Remote Work Interval value in Preferences is a local user value only and does not affect the timing of scripts you might share with other users. Like all Preference settings, however, it applies to all scripts and suites for this user account.

If you change the Remote Work Interval preference, you can still adjust the remoteWorkInterval global property within a script to affect that runtime. Changing the global property during runtime does not change the user preference value.

Lowering Image Search Times

Although Eggplant Functional is intended to be an image-based tool, image searching can be a time-consuming part of your script execution. By default, Eggplant Functional searches for each image up to six times, then performs a full screen refresh and one more search before it reports that the image was not found. Between each image search in this process, there is a delay equal to the ImageSearchDelay global property value.

Lowering the ImageSearchDelay value increases the frequency of the scans, and therefore speeds your script execution. To adjust this property, add the following SenseTalk command to your script:

Set the imageSearchDelay to 0.1

The SenseTalk script attempts to search the area at this frequency, but if the area is large or you are searching for an image collection (which can take longer because there are multiple images to search for), it automatically adjusts the frequency to allow each scan to complete.

Your overall search time is also affected by the ImageSearchCount and the ImageSearchTime global properties. See the ImageSearchCount, the ImageSearchDelay, and the ImageSearchTime for more information about the way these properties interact to affect image search times.

Using the WaitFor Property

You can speed script execution by using the WaitFor property value with image search commands. Similar to the WaitFor command, the WaitFor property sets the maximum amount of time Eggplant Functional waits for a given image to appear on the SUT. You can shorten this wait time by using the WaitFor property with a short time value as shown in the following example.


Click (ImageName:"Done_button", waitFor: 2) // Wait for a maximum of two seconds for the image to appear on the SUT
put "The test is complete."

The script executes the next command as soon as the image appears; it does not wait for the WaitFor time to pass before continuing execution.

If you know at a certain point in your script that an image is already there, or it is not going to be there, you don't need to wait for a long search. To speed script execution time, set the WaitFor time to a zero value, which tells Eggplant Functional to scan for the image only once instead of the default of seven times. This technique is particularly useful within repeat loops and other iteration methods, as shown in the following example:


repeat 1 minute
If imagefound (imageName:"Notification", waitFor: 0) then
Logwarning "The warning is still present."
wait 2
Log "The warning is gone."
Exit Repeat
End If
end repeat

Using Image Functions

Use the following image functions to speed script execution, save search time, and gather information about your script execution.


The FoundImageLocation() function returns the screen coordinates of the last image that was found. When your next action refers to the same image as the previous search, you can save time by using this function to call it directly from its coordinates, which is much faster than searching the screen again.


WaitFor 8, "Save Button", "OK Button","Retry Button" -- Waits up to 8 seconds for one of the button images to be found
Click FoundImageLocation() -- Clicks the hot spot of whichever image was found.

In the example shown above, Eggplant Functional finds one of the buttons during the WaitFor command. Then, already knowing the location of that button, it clicks it immediately, reducing the script execution time.

If you use the image names in the script instead of the FoundImageLocation() function, Eggplant Functional performs the search again for the Click command, which adds time to the script execution.


Sometimes you need to know if an image appears on the screen, and take different actions depending on the result. The ImageFound() function returns a true or false value indicating whether or not an image (or one of several images) is found. The following example combines the ImageFound() and FoundImageLocation() functions to reduce the script execution time by eliminating the need for additional image searches.


If ImageFound (10,"Save Button") then -- If "SaveButton" is found, then...
Click FoundImageLocation() -- Clicks the location of the found image.
else -- Otherwise...
LogError "Save Button not found" -- Logs an Error.
end if


If you want to know the location of an image, you can call the ImageLocation() function to return the coordinates of its hot spot relative to the upper-left corner of the screen. The following example uses ImageLocation() to store the location of the scroll bar down button, then uses a repeat loop to click the stored location ten times. This use of ImageLocation() improves the script execution time because Eggplant Functional searches for the image only once instead of ten times.


set ScrollDownButtonLocation to ImageLocation("ScrollDownButton")
repeat 10 times
click ScrollDownButtonLocation
end repeat

The ImageLocation() function raises an exception if the given image is not found.

Searching Less of the Screen

You can make optical character recognition (OCR) and image searches faster by telling Eggplant Functional where to perform searches.

The SearchRectangle

Use the SearchRectangle to define a portion of the SUT screen to search for images.


setoption SearchRectangle, ("DialogUpperLeft",imageLocation("DialogLowerRight") + (50,10)) // Sets the searchRectangle based on the hot spot location of DialogUpperLeft, and an adjustment of 50 pixels to the right and 10 pixels down from the hot spot location of DialogLowerRight

You can also use the SearchRectangle to limit the search area when you are searching the same small area repeatedly. For example, if you are scrolling through a drop-down list, you could send the SearchRectangle to limit the search area to where the drop-down list appears. This enables a faster scroll through the list for a particular entry, as there is a smaller area for Eggplant Functional to search.


You can create a reusable custom function handler to define the portion of the screen to search. See Using the ScreenPart Function for examples of this function handler.