Forum Discussion
- shankar_rCommunity Hero
- nwalimbeOccasional Contributor
Thanks a lot shankar_r. However this seems to be in a language I do not understand. Could you pls. convert it into python or give me some pointers. I tried googling it, but looks like I am making mistakes here and there.
Thanks,
- nwalimbeOccasional Contributor
This is the code, I am trying to use:
def ClearAllChromeStoredInfo():
objFSO = CreateObject("Scripting.FileSystemObject")
strAppDataFolder = aqEnvironment.GetEnvironmentVariable(("LocalAppData") & "\Google\Chrome\User Data\Default")
FilesInFolder = objFSO.GetFolder(strAppDataFolder).Files
Log.Message(FilesInFolder)
FoldersInFolder = objFSO.GetFolder(strAppDataFolder).SubFolders
for Folder in FoldersInFolder:
if UCase(Folder.Name) = "EXTENSIONS" and LCase(Folder.Name) = "EXTENSION STATE"
Folder.Delete True
break
For File In range (FilesInFolder)
If Not UCase(File.Name) = "PREFERENCES"
File.Delete
breakThe error I am getting is attached.
- AlexKarasChampion Level 3
Hi,
Besides the fantastic reply from shankar_r (Shankar, thank you a lot for bringing this ages-old thread to the light!), there are recommended settings for web browsers (https://support.smartbear.com/testcomplete/docs/app-testing/web/general/preparing-browsers/index.html) and it is a good idea to have them been done on the test machines.
- mike_duckVisitor
Hi!
There is a workaround using Keys() method of browser Page object. Sorry, I'm not familiar with Python but in JScript it looks like following:
var browser = Sys.Find('ProcessName', 'chrome');
var page = browser.Page('http://yourpage.url/');
page.Keys("!^[Del]"); // Ctrl + Shift + Delete keys combination opens clear browser data dialog
SleepSeconds(2);browser.Page('chrome://settings/clearBrowserData').Keys("[Enter]"); // hit Enter in clear browser data dialog
SleepSeconds(2);
browser.Page('chrome://settings/').Close(); // close settings page after clearing browsing datapage.Keys('[F5]');
- ucuberOccasional Contributor
Aside the fact, that the question is a little bit older, here a solution in python for chrome I made for my tests. If you have some ideas to make it more elegant or effective or if you see errors, feel free to refactor it
Remark: on my system all the chrome stuff is in Roaming, so I use AppData instead of LocalAppData
def clear_stored_info_chrome(): excluded_items = [item.upper() for item in [ r"Preferences", r"Origin Bound", r"Extension" ] ] found_items = [item.upper() for item in glob.glob( os.path.join( aqEnvironment.GetEnvironmentVariable("AppData"), r"Google\Chrome\User Data\Default\*" ) ) ] for item in found_items: is_excluded = [True for tag in excluded_items if tag in item] if not is_excluded: try: if os.path.isdir(item): shutil.rmtree(item, ignore_errors=True) else: os.remove(item) except BaseException as e: # I ignore errors of any kind, just a remark to Log Log.Message("clear chrome stored info: {} - {}".format(item, e))
Related Content
- 2 years ago
Recent Discussions
- 18 hours ago
- 18 hours ago
- 5 days ago