一. document.cookie(ruby与qtp都兼容的方法)
1. 使用方法
Set document=browser(“taobao”).page(“taobao”).object
2. 获取cookies
a= document.cookie
3. 删除cookies
为了删除一个cookie,可以将其过期时间设定为一个过去的时间:
document.cookie="userId=828; expire="+date.toGMTString();
二. Qtp中的WebUtil(最有效推荐在qtp中使用)
1. 使用方法
在QTP中输入 webutil然后打点就可以看到所有对应方法:
webutil
2. 获取cookie
A= WebUtil.GetCookies(url)
3. 删除cookie
WebUtil.DeleteCookie(domain,cookies)
webutil.DeleteCookies
三. 原始方法(解决所有不能解决问题的万能方法)
Browser("Browser").WinToolbar("ToolbarWindow32").Press "&Tools"
Browser("Browser").WinMenu("ContextMenu").Select "Tools;Internet Options..."
Browser("Browser").Dialog("Internet Options").WinButton("Delete Cookies").Click
Browser("Browser").Dialog("Internet Options").Dialog("Delete Cookies").WinButton("OK").Click
Browser("Browser").Dialog("Internet Options").WinButton("OK").Click