Clear Cache in Chrome

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.

1 Like

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

8 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

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

Hi Vijay,

Start-Sleep -Seconds 5
$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$

}
}

I am using above power shall script to clear chrome cache.
I am able to clear up to some cache files but also getting below error.

Access to the path ‘C:\Users\Machinename\AppData\Local\Google\Chrome\User Data\Default\Cache\data_0’ is denied.
Access to the path ‘C:\Users\Machinename\AppData\Local\Google\Chrome\User Data\Default\Cache\data_1’ is denied.

data files are not able to clear.
Please help me to resolve this issue.

Just a remark from my side:
why are you not using incognito tabs in the first place to not save any cache/cookies from the session?

Why not use Auto-Delete Cache in the browser by default? In an enterprise scenario you can easily handle this by config or policy.

It is not working for c#

you are getting this error because Chrome is open. The powershell script will not work if Chrome is open. I would do a kill chrome before you start the clear cache. Also, in your script you will need a recurse.

Hi,

This works for me:

  • send hotkey Ctrl+Alt+Del
  • click image “Clear data”

Since Google does not let the settings selector to be captured, this is the only solution feasible I can think of at the moment.
good luck!

Hi All

We can clear cache and cookies without send hot key by using delete file activity

Go to program files x86 → Google chrome-> cache/cookies folder

Any doubts ping me again ll help you

Thanks
Ashwin.S