How to clear cookies in loadrunner 12.50

2019-06-13 19:32发布

问题:

I am quite new to LoadRunner. I am using the 12.50 community edition and am using the protocol TruClient for web.

What should i do in order to delete the cookies that the LoadRunner has accumulated while doing interaction with browser?

回答1:

As suggested by tserg42, you could add a separate step inside your "Develop Script" of TruClient for adding the "Utils.clearCookies()" command inside a Javascript action.

Please find the screenshots below for adding the above

Step 1

Drag the marked step on to the script

Step 2

Step 3

Upon clicking the "JS" icon at the right corner, the arguments editor would be available for providing javascript commands. Key in the required commands - "Utils.clearCookies()".


Additionally, you can also check "Simulate new user on each iteration" checkbox from Runtime Settings --> Replay --> Simulate new user on each iteration



回答2:

I guess you are looking for the function web_cleanup_cookies(). Here is some relevant information I have found about its use:

Return Values

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

General Information

The web_cleanup_cookies function removes all the cookies that are currently stored by the for use by the script.

Note: Scripts do not use (access or modify) the cookies that are stored by your browser. Instead, each Vuser uses the cookies that are sent to the Vuser by the server host at runtime. These cookies are maintained only while the script runs. The web-cookie functions (web_add_cookie, web_remove_cookie and web_cleanup_cookies) manipulate these temporary cookies, and do not affect cookies stored by your browser.

This function is supported for all Web scripts, and for WAP scripts running in HTTP or Wireless Session Protocol (WSP) replay mode.



回答3:

You could try Utils.clearCookies() method. By the way, TruClient API documentation is available online.