Clear Cache in Chrome

Hi Everyone,

I am trying to prepare a code for clearing history of Chrome but getting error while trying to automate
I tried using hotkeys but I want another way or code for deleting history.
Please suggest

Record a sequence to delete the data.

Thanks,
Prankur

Thanks for the suggestion but I tried with recording also but still I am not able to clear the cache in chrome.

Hi @vidhijain

I think that would be the simplest and pretty straight forward can you share your workflow?

Thanks,
Prankur

would you please share the error and workflow !

Actually I cannot share the workflow without my head’s permission but I can explain you with my problem.

Actually I have automated for a Airlines for getting the flight details, so when the bot hits the website, after it runs for a couple of times I get “Access Denied” error as the website gets crashed, so for this I need to clear the cache everytime before the bot runs.

1 Like

Tell us what are the steps and process you are following ans lets see if we can help identify the issue.

what is the browser you want to clear cash for is it chrome or ie and do you need this action to be run in background or in visible way !

Hi, Can someone share the workflow to clear the Cache?

@Anandhu,

How you manually do to clear cache and same steps record here and run it. If you face any challenge then get back to us. We are ready to help you.

1 Like

Thank you Lakshman,

But my concern was that would fail if the browser interface change because of update.

@Anandhu,

Yes, If interface was change then it will fail.

Once give it a try like this: Use open browser activity to open chrome browser and then pass url as “chrome://settings/clearBrowserData”. Then it will show pop up to clear cache and just click on that.

2 Likes

try using powershell script to clear the cache and cookies rather than going for UIAutomation approach

$Items = @('Archived History',
            'Cache\*',
            'Cookies',
            'History',
            'Login Data',
            'Top Sites',
            'Visited Links',
            'Web Data')
$Folder = "$($env:LOCALAPPDATA)\Google\Chrome\User Data\Default"
$Items | % { 
    if (Test-Path "$Folder\$_") {
        Remove-Item "$Folder\$_" 
    }
}

You can execute the script using Powershell activity in uipath

10 Likes

Hi Vijay,

When i executed the script in my machine it got executed and chrome history was deleted.
when i am executing on the client server got below error.Can you please help me how can we fix this.

error

How do we actually invoke this script?

I triied saving it as a txt, read txt file to variable then use the variable in the powershell invoke but to no avail

Please find below screenshot to execute the script from Uiapth.
Chrome

psscript is the content /output of Read text file activity.

I tried this solution, but an error occured:

RemoteException wrapping System.Management.Automation.CommandNotFoundException: The module '$Items = @(‘Archived History’,
‘Cache’ could not be loaded. For more information,
run 'Import-Module $Items = @(‘Archived History’,
‘Cache’. —> RemoteException wrapping System.Management.Automation.CmdletInvocationException: Illegal characters in path. —> RemoteException wrapping System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path,
Boolean checkAdditional)
at System.IO.Path.IsPathRooted(String path)
at Microsoft.PowerShell.Commands.ModuleCmdletBase.IsRooted(String filePath)
at Microsoft.PowerShell.Commands.ModuleCmdletBase.ResolveRootedFilePath(String filePath,
ExecutionContext context)
at Microsoft.PowerShell.Commands.ImportModuleCommand.ImportModule_LocallyViaName(ImportModuleOptions importModuleOptions,
String name)
at Microsoft.PowerShell.Commands.ImportModuleCommand.ProcessRecord()
at System.Management.Automation.Cmdlet.DoProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
— End of inner exception stack trace —
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs,
Boolean performSyncInvoke)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection1 input, PSDataCollection1 output,
PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection1 input, PSDataCollection1 output,
PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TOutput](IEnumerable input,
PSDataCollection1 output, PSInvocationSettings settings) at System.Management.Automation.PowerShell.Invoke[T](IEnumerable input, IList1 output,
PSInvocationSettings settings)
at System.Management.Automation.PowerShell.InvokeT
at System.Management.Automation.CommandDiscovery.AutoloadSpecifiedModule(String moduleName,
ExecutionContext context,
SessionStateEntryVisibility visibility,
Exception& exception)
— End of inner exception stack trace —
at System.Activities.Statements.Throw.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance,
ActivityExecutor executor,
BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor,
BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor,
BookmarkManager bookmarkManager,
Location resultLocation)

send hot key Ctrl+Shft+Del
send hotkey Enter

2 Likes

I am getting the same error … Is there a potential fix ?

The problem is that you have to have the browser closed and have “IsScript” activated

1 Like