While it may not be obvious, Eggplant actually has two Helper suite mechanisms that have different strengths. Working with different sets of images is what the “dynamic Helper” mechanism is designed for. The following description of the two types of Helper suites may help you to understand this a bit better.
Static Helper suites – those listed on the Helpers tab of a suite – are especially good for including libraries of utility scripts that may be useful in a number of different suites. Simply list these utility suites on the Helpers tab and all of their scripts and images will be available to every script in your suite.
On the other hand, when your script needs to dynamically determine which “Helpers” to use at runtime, use “dynamic Helpers” – the OpenSuite command – to choose which suites to make available as helpers. One of the best ways to do this may be to create a master controller script that first opens your helper suites and then calls your test script.
Here’s an example controller script that looks at the screen to see what type of SUT it’s connected to and chooses the appropriate suite to open to use images for that platform:
// Master script -- opens appropriate helper suite and then runs test
if imageFound("AppleIcon") then -- (if the apple's there, it must be a Mac)
set platformName to "Mac"
set the currentTextPlatform to "MacOSX_10.4"
set platformName to "Windows"
set the currentTextPlatform to "WindowsClassic"
LaunchApplication "MyApplication" -- launch our application
MyApplicationTest platformName -- pass the platform name to the test script
This hypothetical example would be used for testing a cross-platform application that could be running on either Mac or Windows. The main test script (“MyApplicationTest”) drives the application on either platform, even though some images may be different for the two versions of the application.
There are a few valuable points to note here:
By opening either the MacApplication or WindowsApplication suite, we make the images from one of those suites available to all of our scripts. If the two versions of a given image have the same name in the two platform suites, your script can simply use the image name in a command – Click “OKButton” – and the appropriate “OKButton” image will be used.
Images that are the same for both platforms can be stored in the main suite. For example, if your application has a “PrintReport” button that uses the same icon for both the Mac and Windows versions, you could keep a single copy of that image in the main suite.
In addition to images, the OpenSuite command also makes any scripts in the suite available, allowing you to create scripts to deal with platform-specific behaviors. For example, the process for launching an application may be different on different platforms. In our example, if each platform suite has its own LaunchApplication script, the LaunchApplication command shown in the script above will call the script in whichever suite is open.
The script above also sets the currentTextPlatform global property to the appropriate platform. For generated text images, this allows your script to use a text style that may be defined to use a different font or other characteristics on the the two platforms.
At present (at least up through Eggplant 3.31) any suites opened by the OpenSuite command are automatically closed when the script or handler that opened them exits. This means you’ll need to use the approach shown here of opening a suite and then running your test within that same script. Your test script can’t call out to a utility script that opens the suite and then returns, because the suite will be closed before execution resumes in the test script. We plan to enhance the OpenSuite mechanism in a future release to provide more flexible options, but for now you’ll need to design your scripts to work with the current behavior.
This example used the OpenSuite command to deal with using the images and behaviors needed for the Mac vs. Windows versions of the same application. The same approach can be used, however, for testing a web application running in different browsers, for testing an application localized in different languages, or for testing different versions of your application.
In your case, if you move all of your current images out of the main suite into a dynamic helper suite, then adding an OpenSuite command at the beginning of your test scripts should allow them to continue working as they always have. Then you can make a copy of the helper suite and change any images in the copy as needed for your new project. At that point, to switch your test between the old and new versions, simply change your test script to open the other suite in your test.
I hope this helps!