QTP10.com is a new and completely free website that offers help in all the versions of HP QTP (including latest version 10). More importantly, it offers free code for users of HP QuickTest Professioal. This site helps you in learning the basics of QTP and descriptive/advanced programming in (QTP) on various environments like - .Net, Infragistics, Web, Windows, etc.

Note -
This blog is NOT affiliated with HP / Hewlett-Packard in any way. The data/questions come from various sources and we have our own testing questions. I am just another Software Tester like you.

Retrieves the value of the cookie for a specified Web page with QTP

Share This Post -

A cookie is a small piece of information stored by the browser that applies to a Web page. Each cookie can store up to 20 name=value; pairs called crumbs, and the cookie is always returned as a string of all the cookies that apply to the page.

This means that you must parse the string returned to find the values of individual cookies.



You can retrieve cookies for a specific URL with two methods:



Method 1:GetCookies

msgbox Browser("Google").GetCookies("http://www.google.com")

Retrieve value of cookies for a web page with HP QTP

Method 2: Object.cookie

strCookie = Browser("Google").Page("Google").Object.cookie

msgbox strCookie

Retrieve value of cookies for a web page with HP QTP