web_dump_cache

Save the Vuser cache to a file.

int web_dump_cache( const char *Name, const char *fileName, [ const char *Replace], LAST );
Argument
Description
Name
The label of the step in the Graphical Vuser script. Also used as the transaction name for automatic transactions.
fileName
The full pathname of the file to store the cache.
Replace
Overwrite existing file: "yes" or "no".
LAST
A marker that indicates the end of the argument list.

Return Values

This function returns LR_PASS (0) on success, and LR_FAIL (1) on failure.

Parameterization

All string arguments (char type) can be parameterized using standard parameterization.

General Information

web_dump_cache saves the browser cache. It is used together with web_load_cache to implement Vuser persistent caching. The script always runs with the same initial cache.

The purpose is to capture the browser cache once, while running the script manually. Then the same cache can be used repeatedly in tests. Using Vuser persistent caching improves CPU usage on the application and database servers.

After recording the script, add web_load_cache at the beginning and web_dump_cache at the end of either the Action or vuser_end section, as appropriate to your test. Run the script once with the web_load_cache call commented out. Then uncomment the web_load_cache call and comment out the web_dump_cache call. The result is that on each run the cache you created is reloaded.

The filename pathcan be absolute (e.g., "FileName=c:\\MyDir\\User1.cache") or relative to the current Virtual User directory (e.g., "FileName=Iteration1.cache"). Note that cache files folder must be created before running the dump command

If you use relative filenames, the files are copied with the script when saving to a new location, or copying to an load generator host. This behavior is platform independent and independent of drive mappings and network locations.

Use absolute path names only if you do not want the cache file to be linked to the script. For example, if you wish to use a different cache on each host, use absolute paths to prevent the cache from the development machine overwriting the host cache each time you enhance the script.

The file extension is ".cache". It is added even if not specified. For example, if you enter "FileName=Iteration2.txt", the cache file is "FileName=Iteration2.txt.cache".

File names can be parameterized, so that different Virtual Users or different iterations use different files. For example, "FileName=Iteration{param}.cache"

Replace specifies whether to replace the file if it exists already ("Replace=yes") or not ("Replace=no"). The default is "Replace=yes".

Note: If the script is not developed on the machine that will be running the tests, ensure that the cache files are accessible to the host at the path given in fileName.

Example

In this example the Vuser logs on to a system and views her paycheck. The script is run once by the test developer with the web_load_cache call commented out, and the web_dump_cache call and the web_add_cookie calls uncommented. This creates the files to be used in the actual testing.

After the files are created, the web_load_cache call is uncommented, and the web_dump_cache call and the web_add_cookie calls are commented. On subsequent runs, the cache files are loaded before running the business process.

Action()
{
/* Initially used to create the Vuser environment:
    web_add_cookie("SignOnDefault=; domain=pbntas05; path=/");
    web_add_cookie("http%3a%2f%2fpbntas05%3a8250%2fpsp%2fps%2femployee%2fhrms%2frefresh=list:|; domain=pbntas05; path=/");
    web_add_cookie("storedCookieCheck=true; domain=pbntas05; path=/");
End setup functions.
*/
// Get the previously created cache

web_load_cache("ActionLoad",
    "FileName=c:\\temp\\{VuserName}paycheck",
    LAST ); 

/* From here down is the business process for which
    we want to use a persistent cache */

web_browser("signon.html", 
    DESCRIPTION, 
    ACTION, 
    "Navigate=http://myserver:8200/ps/signon.html", 
    LAST );

web_edit_field("userid", 
    "Snapshot=t1.inf", 
    DESCRIPTION, 
    "Type=text", 
    "Name=userid", 
    ACTION, 
    "SetValue={VuserName}", 
    LAST );

web_edit_field("pwd", 
    "Snapshot=t2.inf", 
    DESCRIPTION, 
    "Type=password", 
    "Name=pwd", 
    ACTION, 
    "SetValue=HCRUSA_KU0007", 
    LAST );

lr_start_transaction("login");

web_button("Sign In", 
    "Snapshot=t3.inf", 
    DESCRIPTION, 
    "Type=submit", 
    "Tag=INPUT", 
    "Value=Sign In", 
    LAST );

lr_end_transaction("login", LR_AUTO);

web_image_link("CO_EMPLOYEE_SELF_SERVICE", 
    "Snapshot=t4.inf", 
    DESCRIPTION, 
    "Alt=", 
    "Name=CO_EMPLOYEE_SELF_SERVICE", 
    "Ordinal=1", 
    LAST );

web_text_link("Payroll and Compensation", 
    "Snapshot=t5.inf", 
    DESCRIPTION, 
    "Text=Payroll and Compensation", 
    "Ordinal=1", 
    LAST );

web_text_link("View Paycheck", 
    "Snapshot=t6.inf", 
    DESCRIPTION, 
    "Text=View Paycheck", 
    "Ordinal=1", 
    LAST );

web_text_link("Sign out", 
    "Snapshot=t7.inf", 
    DESCRIPTION, 
    "Text=Sign out", 
    "FrameName=UniversalHeader", 
    LAST );

web_browser("browser", 
    "Snapshot=t8.inf", 
    DESCRIPTION, 
    ACTION, 
    "Sync", 
    LAST );

/* This command was used once to create the cache files, then 
    commented out for the actually load testing */

/*    web_dump_cache("paycheckcache",
        "FileName=c:\\temp\\{VuserName}paycheck", 
        "Replace=yes", LAST );		*/

return 0;
}