Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
Enhance profile copying in BrowserProfile class to include 'Local State' directory
kalil03217a98f78f4ac9
diff --git a/browser_use/browser/profile.py b/browser_use/browser/profile.pyindex 23ddf43fd..b920e7ff5 100644--- a/browser_use/browser/profile.py+++ b/browser_use/browser/profile.py@@ -796,14 +796,20 @@ class BrowserProfile(BrowserConnectArgs, BrowserLaunchPersistentContextArgs, Broreturntemp_dir = tempfile.mkdtemp(prefix='browser-use-user-data-dir-')- path_original_profile = Path(self.user_data_dir) / self.profile_directory+ path_original_user_data = Path(self.user_data_dir)+ path_original_profile = path_original_user_data / self.profile_directorypath_temp_profile = Path(temp_dir) / self.profile_directoryif path_original_profile.exists():import shutilshutil.copytree(path_original_profile, path_temp_profile)- logger.info(f'Copied profile ({self.profile_directory}) to temp directory: {temp_dir}')+ local_state_src = path_original_user_data / 'Local State'+ local_state_dst = Path(temp_dir) / 'Local State'+ if local_state_src.exists():+ shutil.copy(local_state_src, local_state_dst)+ logger.info(f'Copied profile ({self.profile_directory}) and Local State to temp directory: {temp_dir}')+else:Path(temp_dir).mkdir(parents=True, exist_ok=True)path_temp_profile.mkdir(parents=True, exist_ok=True)