How to Delete Cookie in VBScript?

0
313
Spread the love
  • 13
  • 15
  • 23
  • 24
  •  
  •  
  •  
  •  
  •  
  •  
    75
    Shares

How to delete Cookie in VBScript?

This post covers How to delete Cookie in VBScript? How to delete Cookie in VBScript? How to delete Cookie in UFT? how to delete cookies using vbscript? how to delete cookies using UFT? how to delete cookies in chrome using vbscript? how to delete cookies in Internet Explorer using vbscript? how to clear cookies using vbscript? code to clear cookies using vbscript.uft code to clear cache and cookie. uft code to clear cache.

HTTP cookies, all the more generally alluded to as Web cookies, following treats or just cookies, are packages of content sent by a server to a Web client (for the most part a program) and afterward sent back unaltered by the customer each time it gets to that server.

HTTP cookies are utilized for confirming, session following (state support), and keeping up explicit data about clients, for example, site inclinations or the substance of their electronic shopping baskets. The expression “cookies” is gotten from “magic cookies,” an outstanding idea in UNIX figuring which enlivened both the thought and the name of HTTP cookies.
source: http://en.wikipedia.org/wiki/HTTP_cookie

How to delete Cookie and cache in VBScript or UFT:

Since they can be utilized for following perusing conduct, cookies have been of worry for Internet protection. Thus, they have been liable to enactment in different nations, for example, the United States, just as the European Union.

Cookies have additionally been censured in light of the fact that the recognizable proof of clients they give isn’t constantly precise and on the grounds that they could conceivably be an objective of system assailants. A few options in contrast to cookies exist, however, everyone has its own uses, points of interest, and downsides.

Cookies are likewise subject to various misguided judgments, generally dependent on the mistaken thought that they are PC programs. Indeed, cookies are straightforward bits of information helpless to play out any activity without anyone else’s input.

Specifically, they are neither spyware nor infections, despite the fact that cookies from specific destinations are portrayed as spyware by numerous enemy of spyware items since they enable clients to be followed when they visit different locales.

Most present-day programs enable clients to choose whether to acknowledge cookies, yet dismissal makes a few sites unusable. For instance, shopping baskets executed utilizing cookies don’t work if cookies are rejected.

This is very important while building a framework on Automation.

The recent Method to delete cookie through QTP/UFT is

webutil.DeleteCookies..

This is an unpublished function of QTP/UFT. However, it is working fine as of right now. But it is highly recommended that before using this command Testers need to cheek its adaptability with the script.

We have some old method too…

WebUtil.DeleteCookies:

We can use this command to those scenarios where we can close the browser completely. Means if we are using this command, we need to make sure not a single IEExplorer in opened in the task manager.

If a single IEExplorer is opened in the task manager this command will not work as it can not kill the session and the temp folder will be in read-only mode. The objective is not fulfilled.
Secondly, it can not handle such cookies which are written in a log file or in a .txt format …what I mean those browsers who handles cookie in a different way like..Opera etc

Imagine a situation where the demo is displayed over the same time meeting-room or WebEx meeting which requires an/two active webpage(s) needs to be opened (i.e. IE-Explorer). The command will fail in those scenarios. Or it will close the sharing window (browsers) which may create noise to the viewer level.

Creation of an object is provided in this post. The main technique used here is the sendkeys. The details of sendkeys can be found here.

The other old method might take a few seconds more but will not arise in such a situation.


Sub netCacheClear()
systemutil.Run "iExplore.exe",sURL
set WshShell = CreateObject("WScript.Shell")
WshShell.Sendkeys "%"+"{T}"
set WshShell = Nothing
set WshShell = CreateObject("WScript.Shell")
WshShell.Sendkeys "{o}"
set WshShell = Nothing
wait(1)
set WshShell = CreateObject("WScript.Shell")
WshShell.Sendkeys "%"+"{i}"
set WshShell = Nothing
wait(1)
set WshShell = CreateObject("WScript.Shell")
WshShell.Sendkeys "{Enter}"
set WshShell = Nothing
set WshShell = CreateObject("WScript.Shell")
WshShell.Sendkeys "%"+"{f}"
set WshShell = Nothing
wait(1)
set WshShell = CreateObject("WScript.Shell")
WshShell.Sendkeys "^"+"{d}"
set WshShell = Nothing
wait(1)
set WshShell = CreateObject("WScript.Shell")
WshShell.Sendkeys "{Enter}"
set WshShell = Nothing
wait(1)
set WshShell = CreateObject("WScript.Shell")
WshShell.Sendkeys "%"+"{h}"
set shShell = Nothing
wait(1)
set WshShell = CreateObject("WScript.Shell")
WshShell.Sendkeys "{Tab}"
set WshShell = Nothing
wait(1)
set WshShell = CreateObject("WScript.Shell")
WshShell.Sendkeys "{Enter}"
set WshShell = Nothing
set WshShell = CreateObject("WScript.Shell")
WshShell.Sendkeys "{Enter}"
set WshShell = Nothing
End sub

A little more compact way in UFT using many variables. It will show show how to clear cookies using vbscript?

Call ClearCookies
Function ClearCookies()
SystemUtil.Run "Control.exe","inetcpl.cpl"
Set objShell = CreateObject("Wscript.Shell")
Do Until done = True
done = objShell.AppActivate("Internet Properties")
Wait(1)
Loop
objShell.Sendkeys "%i"
Wait(1)
objShell.Sendkeys "{ENTER}"
Wait(1)
objShell.Sendkeys "%f"
Wait(1)
objShell.Sendkeys "%d"
Wait(1)
objShell.Sendkeys "{ENTER}"
Wait(4)
objShell.Sendkeys "{ENTER}"
End Function 

how to delete cookies using UFT?

UFT does provide a util class which intern support cookie deletion process:

We can use WebUtil.(Method)

webutil.DeleteCookie--Can delete a single domain's Cookie
webutil.DeleteCookies-Can delete multiple domain's Cookies 

Of course, we need to provide comment for a better understanding of what code is doing what. So that we can understand better and maintain better.

I will update about the delete cookie method for chrome to solve-how to delete cookies in chrome using vbscript? as well.

Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 13
  • 15
  • 23
  • 24
  •  
  •  
  •  
  •  
  •  
  •  
    75
    Shares

LEAVE A REPLY

Please enter your comment!
Please enter your name here