Tuesday, 5 July 2011

How to retrieve the cookie from webpage using QTP?

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

No comments:

Post a Comment