Spread the love

How to Delete Cookie in VBScript?

Spread the love

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

From where all the temp files created?

All the applications create temp files during execution. In general, application itself cleans up these files once they finished execution gracefully. But the system crash or hanged program or aborted programs can not clean up the temp files. These files are stored in the temp and occupy the disk space.

READ  How To Bypass SSO in Automation Testing?

A computer program depends on the amount of free space available on the disk. If the drive is beginning to full, it has an adverse effect on the application execution.

It is often advisable to clean up the temp either via code or manually to clear these unnecessary files.

READ  Synchronization in QTP or UFT

The major contributor to the temp folder

Below is the major contributor to the temp folder:

  • Catalog files for content indexer
  • Temporary files
  • Files in the Recycle bin
  • Web client temporary files
  • Temporary Internet files
  • Downloaded program files
  • Publisher’s temporary files

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.

READ  How to Connect Database and Import Data From Database in Excel through VBScript or QTP

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.

READ  Top Ten Strategies to Make Test Automation As a Service

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.

The 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.

READ  Top Ten Strategies to Make Test Automation As a Service

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 comments for a better understanding of what code is doing what. So that we can understand better and maintain better.

Code to delete temp files via disk defragment

Option Explicit
Dim WSHShell
Set WSHShell=WScript.CreateObject("WScript.Shell")
WSHShell.Run "C:\Windows\System32\cleanmgr\sagerun:\"
WSHShell.Run "C:\Windows\System32\debug c:\f"

The debugger takes three arguments

debug <volume> [/a][/f][/v]

  • /a -> provides the analysis of the specified volume
  • /f-> force debugger to run within available space
  • /v-> provides the verbose output
READ  How To Create Test Data for Advanced Test Structure or Test Framework

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

Other references:




Spread the love
Animesh Chatterjeehttps://techtravelhub.com/
I am the founder and owner of the blog - TechTravelHub.com, always love to share knowledge on test automation,tools,techniques and tips.I am a passionate coder of Java and VBScript.I also publish articles on Travel ideas and great honeymoon destinations.Apart from these, I am a gear-head,love to drive across India. I have shared lots of articles here on How to travel several parts of India.Customization of cars aka car modification is my another hobby.Get in touch with me on ani01104@gamil.com

Related Articles

Learn Object Repository in UFT in An Efficient and Fast Manner

Object Repository in UFT The post will cover the following topics Details...

Comments

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Recent Posts

Super Keyword in Java Simplified

Super Keyword Super Keyword in Java Simplified: Java defines a special...

Learn Object Repository in UFT in An Efficient and Fast Manner

Object Repository in UFT The post will cover the following...

Learn What Primary Tools For Test Automation

Primary Tools For Test Automation According to the Gartner report...

EDITOR PICKS


Spread the love