This tutorial intends to help you set up SAFS test project, create your first test script, then run the test to see how it works. It is assumed that you have installed SAFS 2009 by running its installer, SetupSAFS.wsf. Refer to SetupSAFS.wsf.README.txt.
Note: We suggest that you have IBM Rational Function Test (RFT) V8 installed on your machine before starting to run SetupSAFS.wsf.
Prerequisites:
Start from helloSAFSRFT
The first test script, helloSAFSRFT, intends to input keyword "SAFS" on a Google search window that has been manually opened, and then press Enter to get the results.
1. Setting up helloSAFSRFT project
Go to:
Top,
Prepare helloSAFSRFT Files,
Use STAF Process Container,
Run helloSAFSRFT.bat,
Appendix
Create a folder as the home of this project. For example: C:\MyProject.
Ensure this folder owns the same directory structure as below.
One simple way to do so is to copy subfolder Datapool under <C:\SAFS\Project> to <C:\MyProject>.
2. Getting Four files prepared
Go to:
Top,
Setup helloSAFSRFT Project,
Use STAF Process Container,
Run helloSAFSRFT.bat,
Appendix
C:\MyProject\helloSAFSRFT.bat | --- start to run | |
C:\MyProject\helloSAFSRFT.ini | --- configuration file used by helloSAFSRFT.bat | |
C:\MyProject\Datapool\helloSAFSRFT.sdd | --- step-level test script (STEP) | |
C:\MyProject\Datapool\helloSAFSRFT.map | --- application map file |
They can be found in C:\SAFS\Samples\Html. You may simply copy them to C:\MyProject. Only one place needs to be changed, item ProjectRoot in helloSAFSRFT.ini should to be changed as follow:
ProjectRoot="C:\safs\samples\Html" | --- before changing it | |
ProjectRoot="C:\MyProject" | --- after changing it |
There is only one command line as below in this file. SAFSDRIVE Command Line takes helloSAFSRFT.ini as its project configuration file, launches SAFS/ROBOTJ engine and runs each step defined in helloSAFSRFT.sdd.
This is a configuration file that contains various information, which tells SAFS where and how to load user's test script like helloSAFSRFT.sdd.
------------------------------------------------------------------
[SAFS_DRIVER]
;SAFS's home
DriverRoot="C:\safs"
[SAFS_PROJECT]
;the root of your SAFS test project, CHANGE it accordingly!
ProjectRoot="C:\MyProject"
[SAFS_TEST]
;start from this SAFS script: helloSAFSRFT.SDD
TestLevel="STEP"
TestName="helloSAFSRFT"
;Step file name, will be suffixed with '.SDD' by default
CycleSeparator=","
CycleLogName="helloSAFSRFT"
CycleLogMode="TEXTLOG"
[SAFS_ENGINES]
; SAFS/RobotJ engine defined to be used
First=org.safs.tools.engines.SAFSROBOTJ
[SAFS_ROBOTJ]
AUTOLAUNCH=TRUE
;for now, use the RFT Datastore provided in SAFS install
DATASTORE="C:\SAFS\DatastoreJ"
;domains to search
TESTDOMAINS="Html"
------------------------------------------------------------------
Note: Item TESTDOMAINS should contain "Html" as Google Home page is an Html application. SAFS is able to support more than one domain like TESTDOMAINS=Html,Net,Java,Win,Flex,SWT.
This is a step-level test file suffixed with ".sdd". It contains various Keyword-Driven test records for doing various jobs.
------------------------------------------------------------------
C , SetApplicationMap , helloSAFSRFT.MAP ;Re: SetApplicationMap
C , SetContext , Google , Google ;Re: SetContext
C , WaitForGUI , Google , Google , 150 ;Re: WaitForGUI
T , Google , keyEdit , InputKeys , "SAFS" ;Re: InputKeys
T , Google , keyEdit , InputKeys , "{ENTER}"
------------------------------------------------------------------
This is an application map file. It contains the Recognition Strings of the GUI components that helloSAFSRFT.sdd needs.
---------------------------------------------------------------------------
[Google]
Google="Type=Window;Caption={Google*}"
keyEdit="Type=EditBox;Name=q"
----------------------------------------------------------------------------
One question: I know the four files can be manually created. As for the application map file, how do I get the standard Recognition Strings for those GUI components performed actions on?
Let's look at the next section on STAF Process Container.
3. Using STAFProcessContainer against the Software Under Test
Go to:
Top,
Setup helloSAFSRFT Project,
Prepare helloSAFSRFT Files,
Run helloSAFSRFT.bat,
Appendix
It is better to have STAF started up before running STAFProcessContainer. Also, make sure the Google Home window is ready.
Click Start Menu item "Programs->SAFS 2009->STAF ProcessContainer",
or double-click the "runSTAFProcessContainer.bat" file likely installed in your <SAFSDir>\Project directory.
STAFProcessContainer starts to look up a HTML window with the caption starting with "Google" when you click button "Click to Run". It takes a while to drill down the whole window. When finished, GoogleAppMap.map should be output to the "C:\MyProject\Datapool" directory you defined. The Recognition Strings of all components can be found in this AppMap file. Window "Component Hierarchy Viewer" should also pops up.
In the Viewer, you may input any class type
you want. You can also find a Recognition String for a class type and its corresponding
GUI component. Once found, these will be highlighted as shown below.
Refer to <SAFSDir>\lib\JavaObjectsMap.dat for extensive class type mappings.)
4. Running helloSAFSRFT.bat to get the result
Go to:
Top,
Setup helloSAFSRFT Project,
Prepare helloSAFSRFT Files,
Use STAF Process Container,
Appendix
When running helloSAFSRFT.bat, the console below appears and SAFS with RFT should locate and activate the Google Home page, input keyword "SAFS", and press the Enter key automatically. The log file helloSAFSRFT.txt should be output into the C:\MyProject\Datapool\Logs directory.
SAFS/RFT supports .Net, Flex, Html, Java, SWT and Win applications. Four kinds of SAFS script samples are provided and shall be installed in directory <SAFSDir>\samples.
Domain | Sample directory | SUT (Software Under Test) | Type of the top window | |
.Net | SafsDevTest.bat | <SAFS>\samples\DotNet | ..\DotNetApp\WinDemo.exe | Window |
Flex | SafsDevTest.bat | <SAFS>\samples\Flex | ..\FlexApp\FlexWebDemo.swf | FlexWindow |
Html | HelloSAFSRFT.bat | <SAFS>\samples\Html | www.google.com | Window |
Java | ?? | <SAFS>\samples\Java | Swingapp.jar | Window |
SWT | Not provided | Not provided | Not provided | Window |
Win | Not provided | Not provided | Not provided | Window |
Four steps used to work with Html Google Home page, can be applied to other SUT. Remember to select the corresponding client type when using STAFProcessContainer against an application.
For every Html, Java, .Net, SWT or Win application the recognition string of its top window is most often formatted as shown below:
For .Net, SWT, and WIN applications it is best to prefix the recognition string with the name of the Process associated with the application, as shown below:
Flex applications are not really associated with any caption when launched in an IE window. Thus, SAFS/RFT uses the Flex SWF file name as the Caption to indentify it. The recognition string for flex sample FlexWebDemo.swf is shown below:
In each sample directory, please refer to the README file which describes how to run each sample.
Back to: Top, Setup helloSAFSRFT Project, Prepare helloSAFSRFT Files, Use STAF Process Container, Run helloSAFSRFT.bat