Best Practices for Web Recording in Eggplant Performance
For web recording, the following advice applies in most cases. There will be occasions when you will need to make different choices.
See also:
- Create a Custom Web Virtual User
- Generate scripts in Page mode
Correlation and Parameterization
Where possible, favor checking the Automatically correlate forms option on the Web Forms tab of the Web Generation dialog.
It is not always obvious which data needs correlating or parameterizing. Data such as counters, timestamps and some session ids can often be found in query and post data. Keep an eye out for these. You might find the Hints and Tips section useful.
If you are having trouble correlating or parameterizing your script it can sometimes be useful to take a second recording and compare both in order to spot dynamic data. The Generation Rules Assistant aids in finding and replacing values that need to be correlated.
Web Virtual User Script Replay
Use the Web Log Viewer to compare your replayed web virtual (VU) user script with your original recording.
Remember that when extracting text from a web page you need to look at the text of the actual HTML and NOT the rendered view of the page.
Initializing the Browser
When a browser interacts with a website it stores information relating to that website in a local cache. This cached data typically consists of cookies and page resources. The first time a user visits a website they will have no associated cached data. However, on subsequent visits, information related to their last visit might be stored in the PC cache. This is important because recordings of a first time visitor and a returning visitor will differ significantly. It is recommended that you always record as a new visitor to a website by first clearing the browser cache. There are two reasons why you should follow this advice:
- The script can be replayed as both a first time visitor and a returning visitor - Every web VU maintains its own personal cache like a web browser. This results in the first iteration of a VU operating as a new visitor but then all subsequent iterations operating as a returning visitor. Alternatively, the cache can be cleared on each iteration of the script. This ensures that every iteration operates as a new visitor to the website. Recording the script as a returning visitor allows replay only as a returning visitor.
- Persistent (cached) cookies are very difficult to parameterize - Cookies often contain strings of characters originally generated by the web server. Parameterizing such values can be both impractical and undesirable. It is better to record as a first time visitor to a website thus forcing the web server to send a new cookie. During replay, the web server will send a
Set-Cookie
response header to the web VU which it will store in its own cache. On subsequent iterations (assuming you have not chosen to clear the VU cookie cache) any cookies received by the VU will be maintained and exchanged between the VU and the web server.
Clearing the Browser Cache
All browsers allow you to clear their cache settings.
In Internet Explorer, select Tools > Internet Options > General > Browsing History > Delete. Be sure to delete both files and cookie.
In Firefox select the application menu in the top right, then Settings > Privacy & Security > Clear History. Check the boxes to remove Cache and Cookies and then click OK.
In Google Chrome click the application menu in the top right, then History. On the History page, click Clear browsing data and in the dialog which appears, click Clear data
Selecting the Launch in private mode checkbox in the Create a New Recording wizard creates a clean recording without you having to clear the browser cache.
Annotate the Recording with User Transactions
User transactions are employed to measure the length of time a user action or navigation takes to complete. User transactions can be inserted into a recording during the recording process prior to the user navigation you wish to measure. A transaction has a start and an end that bracket a user's navigation.
Annotating a recording with user transactions helps you keep track of what happened during a web recording session. This is because user transactions are easily identified within a web VU script through a pair of matching startTransaction()
and endTransaction()
method calls.
As an example, suppose you are recording the process of visiting a company website, selecting the "contact us" link and then submitting a question online to the company. This process consists of three user actions that translate into three web navigations, namely; "Go to website", "Click contact us" and "Submit question". Prior to each navigation you would insert the appropriate user transaction and then perform the corresponding navigation. When generated the resulting script would look something like the following:
startTransaction("Go to website");
// URL navigation script code
endTransaction("Go to website");
startTransaction("Click contact us");
// URL navigation script code
endTransaction("Click contact us");
startTransaction("Submit question");
// URL navigation script code
endTransaction("Submit question");
User transactions can be later added manually to the web VU script source code by inserting startTransaction()
and endTransaction()
method calls around the action/navigation that you want to measure.