Browser Recorder And Player (BRAP) - An Introduction
Imagine you would like to have a tool that provides a programmatic way to record what users do in a browser (e.g. clicks, keystrokes, etc.) and later to replay their actions. Imagine this tool wouldn't be worried about the type of browser (e.g. firefox, chrome, IE) used for recording and playing such user activities. Would that not be very useful ?
Browser Recorder And Player (BRAP) is exactly a tool like that. It is an open-source Java package where you can decide what type of user actions you are interested in for recording and playing. BRAP is smart in detecting the page changes due to user interactions and thus is very useful when you want to record and play users interactions in multi-page settings. BRAP uses the Selenium WebDriver and jQuery under the hood. As a result, it is browser independent.
Getting Started
First of all, please create a directory (say BRAP) and make its structure as follows:
BRAP
|-- BRAP.jar
|-- drivers
|--chrome
|-- scripts
|-- BRAP.js
|-- jquery.min.js
|-- output
As you can see, the folder BRAP contains 3 sub-folders (drivers, scripts and output) and a Jar file (BRAP.jar). See below how to generate BRAP.jar. The "driver" sub-folder should contain the selenium driver for browsers. In the example, "chrome" is the driver for the Chrome browser. If you want to use a different browser, please put the corresponding driver in this folder. In the "scripts" directory, you can see BRAP.js and jquery.min.js. You can specify what types of actions you would like to record in BRAP.js. jquery.min.js is injected in the page so that the program (BRAP.jar) can use jQuery to record and play the interactions. The "output" folder holds the result files.
How to generate BRAP.jar ?
You can use build.xml to generate BRAP.jar :
#] ant create_run_jar
Below, you'll see the commands to record and play interactions. But before that, please make sure you have the folder structure as above and you have the right driver (e.g. recent driver) in the "driver" directory.
How to record?
java -jar BRAP.jar -record -browser chrome -browserBin drivers/chrome -oDir op -scriptsDir scripts -file record.int -genInfoFiles -url http://money.msn.com
Output:
If the parameter values are correct, the command launches a browser. Then you can interact with the page (e.g. filling form values, pressing enter, etc.). The interaction file (like record.int) will be generated in the directory specified in oDir (like op).
Parameters:
-url
The URL to be loaded before the interaction recording starts.
-record
Indicates to record interactions
-browser
The type of browser you want to use. Currently, the options are: [chrome|firefox]
Default Value: chrome
-browserBin
The binary driver file for the chosen browser
Default Value: drivers/chrome
-profile
user profile file name for the browser [optional].
-port
Port number for the recorder
Default Value: 4444
-oDir
The output directory
Default Value: output
-scriptsDir
The directory containing the BRAP JavaScripts
Default Value: scripts
-genInfoFiles
If present, generates page information in addition to interaction files
-file
The file where interactions should be recorded
Default Value: null, which means you should provide the file name
A simple example of a command is:
java -jar BRAP.jar -record -file record.int -url http://money.msn.com
How to Replay Recorded Interactions ?
java -jar BRAP.jar -play -browser chrome -browserBin drivers/chrome -file op/record.int
Output:
Given the correct parameters, this command launches the specified browser and plays the interactions present in the supplied interaction file.
Parameters:
-play
Indicates to replay the interactions
-file
The file containing the interactions to play
Other parameters (-profile, -browser, -browserBin) are same as for recording.
A simple example of a command with default assumptions is: java -jar BRAP.jar -play -file output/record.int
Player Server
You can start a player in server mode and execute interactions one-by-one. As the player will be running as a server, you can send the interactions from different computer in the network.
The server mode can be enabled by using -player option as follows:
java -jar BRAP.jar -playerserver -port 8888
Parameters:
Accepted parameters: -player, -profile, -browser, -browserBin and -port (default 8888). They can be specified as before.
Output: You will see a browser window with a blank page. Now you can send interactions (using java program) to the server at: http://localhost:PORT/brap See brap.player.SampleClient.java for more details.
LICENSE
See the license file
ACKNOWLEDGEMENTS
BRAP was developed mostly when the owner of this project was at AT&T Labs Research. Thanks to Dan Melamed, Amanda Stent, Hyuckchul Jung and Giuseppe Di Fabbrizio for the great ideas and suggestions.