Page Tools:
Wiki Relationships:
Admin Tools:
Projects:TestGen4WebDocs
Home | News | Requirements | Documentation | Screenshots | Download | Forum | FAQ | TODO
Contents |
Usage
- This set provides some usage guidelines for the tools.
Recorder
- The tool records all the actions that are performed on the webpage, when the tool is in record mode.
Start recording
- Press the
button to start recording,
- If there was a recording already present, you might be prompted by the following,
Some recording already exists
OK will continue recording
Reset will reset, and start recording afresh
Cancel will cancel the 'record' operation
[OK] [Reset] [Cancel]
- This prompt would mean that the recorder already has some recording in memory, and does not know what to do with that,
- pressing 'OK' will just start inserting events after the current recording in memory, this is as if you had paused the recording, and started recording again.
- pressing 'Reset' will discard all the recording in memory, and start recording fresh. This is equivalent to pressing the 'Reset' button, and then press 'Record'
- pressing 'Cancel' will just cancel the operation. If you press 'Record' again, you will be prompted with the same dialog again.
- After the recording command is accepted, you must see a 'Recording' in the 'Status line', after this, all the actions on the current page are recorded.
Stop/Save recording
- Press the
button to stop recording
- Note that this does not persist the recording, you will have to press the
button to save it on the file system.
Custom Actions - Wait for x milliseconds and Looping (ver >= 0.40)
Custom actions like "wait-for-ms" and "goto" step can be added by using the "step editor"
Detailed help here.
Replay recording
- You can replay recording immediately after you stop recording, by pressing the
button.
- Also, you could load a previous recording by pressing the
, and then press
button.
Using CSV Datasets
CSV Datasets can be imported for a TestGen4Web script via the built in editor for playback. Here are the basic steps you need to follow.
- Outside of the tool, create a blank file .csv file to populate data with later or select an existing .csv file WITH column headers.
- Access the editor by clicking on [Review/Edit Steps] in the TestGen4Web tool.
- Click on the "Datasets" tab.
- Back in the editor under "file" entry box use the "pick" button to select a file.
- Enter a reference name under "ID".
- Put the comma delimited list of the column headings in the field "XPath/CSV Headers".
- Choose .csv as a file type in the File type drop down.
- Click the save button.
- Create or Edit a recorded script.
- On the left, select the statement that should use a data item from the .csv file.
- On the right, replace the typed in value used during recording with ${ID.header} where ID is the name you entered under "ID" and header is one of the headers in the "XPath/CSV Headers" list.
- On the right, click the save button.
Now when the script is executed the data will be retrieved from the .csv file.
Tutorials
Using CSV Datasets
This video tutorial demonstrates the usage of csv files to do repetitive tasks.
Using CSV Files With TestGen4Web
Creating conditions
This video tutorial demonstrates creation of conditional statements in testgen4web
Creating Conditions With TestGen4Web
Simple looping with variable
This video tutorial demonstrates creating of loops based on a variable
Using HTMLUnit-Interpreter
Using the command line browser emulator. The tool htmlunit-interpreter runs testgen4web recordings on the command line.
Translator
- Translator is the tool which translates the recording from the Firefox extension to automated testing scripts.
- Automated testing scripts are the ones which run on the command line, which is helpful to do regression testing on the website, without the use of the browser.
- Although, Look and feel testing like (color, stylesheet) can be done, the importance is given to functionality testing with automated testing tools.
- Any number of translators can be written, currently, work for 2 translators are in progress, viz., http-unit and php-simpletest.
Installation and running translators
Installation
- Download the latest translator from the 'Download' section, and unzip it to any location on the file system.
Run HtmlUnit Interpreter (translator)
- This one is called the interpreter because it does not generate any standalone tests, but runs the xml files as-is.
- Download the tar ball from the download section of the project, and unzip it
tar zxf htmlunit-interpreter-1.1-lib-1.3.tar.gz cd tg4w-htmlunit-interpreter
- Run the "runner"
./runner --help
Usage ./runner [options] command[s]
Options:
--input-dir=<dir> Directory to find input files
* Mandatory for --run and --report,
unless --input-files is specified
--pattern=<pattern> Pattern of files to find [default:*.xml]
--input-files=<files> Comma seperated test files list
* Mandatory for --run and --report,
unless --input-dir is specified
--output-dir=<dir> Directory to output reports
* Mandatory for --run and --report
--java-home=<dir> Java Home [default: env.JAVA_HOME]
--no-easy-https Don't use fake https
--enable-caching Enable caching of js files between requests
--think-time=<x> time interval between clicks in milliseconds
--debug-level=<level> Debug level
* One of: 'ERROR', 'WARNING', 'INFO', 'DEBUG',
'CONSOLE', 'CRAZY'
* Console by default gets WARNING and ERROR,
unless level is 'CONSOLE' or 'CRAZY'
* CRAZY as the name suggests spews out too much
log to the console. dare to try ? ;-)
* Default log is [DEBUG]
* Log name is case-*insensitive* ie., DEBUG=deBuG
* invalid log names are ignored.
--no-compile If you are sure that everything is compiled
--start-unittest-server Starts the unittest java server
--stop-unittest-server Stops the unittest server
--version Display version and quit
Commands:
--unittest -t Run Unit-tests
--run -r Run tests
--clean -c Clean (deletes build, and test/report dirs)
--report Generates html report
--help -h This help text
Run SimpleTest translator
The SimpleTest translator is a PHP tool which reads the recording file, and generates SimpleTest tests. The generated tests are self-contained and can be run standalone. The requirements for using SimpleTest generator are:
- PHP 5.0.x or newer
- PEAR XML_Parser 1.7 or newer.
pear install XML_Parser
- SimpleTest 1.0.1Alpha2 or newer for running the generated tests. SimpleTest is not needed for generating the tests.
To generate SimpleTest tests using the SimpleTest translator
ant simpletest-gen -Dinput.file=path-to-input-recording-XML-file [-Dgen.dir=output-directory]
Or, without using Ant:
php php/src/PHPGenerator.php --input-file=path-to-input-recording-XML-file [--output-dir=output-directory]
The optional output directory will be created, if necessary. The default output directory is "./gendir".
To run the tests, you can use the 'test-simpletest' goal. You will need a SimpleTest 1.0.1Alpha2 or newer installation locally.
ant test-simpletest -Dphp.simpletest.home=simpletest-dir -Dsimpletest.file=generated simpletest file
Or, without using Ant:
php generated-simpletest-file PHP_SIMPLETEST_HOME=simpletest-dir
- Note that, the "simpletest-dir" is the path of SimpleTest installation upto but no including the "simpletest" directory that comes with the SimpleTest installation.
- This command does not generate the tests automatically before running them. That must be done as a separate step.
(DEPRECATED) Run HttpUnit translator
- The HttpUnit translator is a java tool that reads in the recording file, and generates HttpUnit tests. The HttpUnit tests generated are self-contained, and can be run separately.
ant httpunit-gen -Dinput.file=path to input
- The 'path to input' can be a directory, which contains all the recordings; the files are filtered from the extension "*.xml"
- To run the tests, you can use the 'test-httpunit' goal,
ant test-httpunit -Dinput.file=path to input -lib lib/junit
- Note that this command needs a '-lib lib/junit' argument, since the httpunit tests are wrapped around junit, and Junit needs to be in ant's CLASSPATH.
- This commands also runs 'gen-httpunit' before it runs the test. So, running gen-httpunit separately is not needed.
Hacking
For translator developers
confirm
Except a confirmation box -
- verify message in xpath tag
- click OK if value is true
- click Cancel if value is false
alert
Except a alert box (I suppose you mean "Accept"?)
- verify message in value tag
goto
Jump to url in value tag
click
Click on the element pointed by xpath tag
fill
Fill the value in value tag into the element specified in xpath tag
select
Select the option in the select box with value, in the element specified in xpath tag
check
Check on uncheck based on value for element in xpath tag
goto-label
Jump to the lable specified in value
assert-text-exists
Verify that the text specified in value tag exists on the page
assert-text-does-not-exist
Verify that the text specified in value tag does not exist on page
verify-title
Verify the title of the document is the same as the one in value tag
wait-for-ms
Wait for x milliseconds specified in value
goto-*
This is deprecated - is around for backward compatibility eg.
- goto-fill-loop_on_dataset-datasetcsv
- while looping on dataset "datasetcsv" goto label fill
- goto-fill-bool-eq
- if the xpath's value boolean equals to value, goto "fill" label
- the xpath could be javascript
- goto-fill-str-eq
- if the xpath's value string equals to value, goto "fill" label
- the xpath could be javascript
setvar-var name
eg.
- setvar-loopcount-num
- set the variable "loopcount" of type "num" with value from xpath
- the xpath could be javascript
loop-*
- The action will have a end action, and the contents of it is one block
- Analogus to a "while" loop
eg:
- loop-condition-le
- Condition is true if xpath is less than or equal to value
- condition could be lt, gt, le, ge, eq, ne
- loop-dataset-ds1-count
- Loop on a dataset "ds1" and have the loop count in "count"
- The loop count is not implemented yet
condition-*
The action will have a end action, and the contents of it is one block
end
Ends a "loop" or a "condition"
TestGen4Web from SVN
Writeup: Helder Ribeiro
Yes, this is "from svn", *but first we need to install the _current_ release and _then_ replace it by the code from svn* (there must be a better way of doing this, but this works). Go to
http://developer.spikesource.com/frs/?group_id=14&release_id=71
download and install the latest version (0.41.1-beta). This will create a directory `{3c20433a-61bc-42fe-831d-415860e17283}` under `~/.mozilla/firefox/vllrmpro.default/extensions` (or wherever else your firefox extensions are kept).
Now we have to replace this directory by the !TestGen4Web code from SVN.
Choose a directory where you want to keep that code and check it out from SVN (mine is `~work/`):
cd ~/work svn co http://scm.spikesource.com/testgen4web
This will create a "testgen4web" directory in the chosen directory. Now we *replace* the old directory by a link to our checked out code:
cd ~/.mozilla/firefox/vllrmpro.default/extensions
rm \{3c20433a-61bc-42fe-831d-415860e17283\} -f
ln -s ~/work/testgen4web/extension \{3c20433a-61bc-42fe-831d-415860e17283\}
[If you're on Windows, emptying out the original directory and copying the contents of testgen4web/extension/ into it should work]
Well, that's it, basically. Now you go around coding and changing things and, after you're done, save your files and restart Firefox. It comes up again with your new code loaded automatically.
Happy Hacking ;-)

Testing
