which path is used in selenium user dir path in render deployment for chrome session , currently i used this- def get_chrome_profile_path():
“”“Dynamically detects the Chrome profile path based on the user’s operating system.”“”
system = platform.system()
print(system)
# Path for Windows
if system == "Windows":
# Typically, the path is something like this for Windows
user_profile_path = os.path.expanduser(r"~\AppData\Local\Google\Chrome\User Data\Default")
return user_profile_path
# Path for macOS
elif system == "Darwin":
# Typical path for macOS
user_profile_path = os.path.expanduser("~/Library/Application Support/Google/Chrome")
return os.path.join(user_profile_path, "Default")
# Path for Linux
elif system == "Linux":
# Typical path for Linux
user_profile_path = os.path.expanduser("~/.config/google-chrome")
return os.path.join(user_profile_path, "Default")
else:
raise ValueError(f"Unsupported OS: {system}")
chrome_options = Options()
chrome_path= get_chrome_profile_path()
chrome_options.add_argument(f"user-data-dir={chrome_path}") # Using custom profile
# chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-dev-shm-usage")
with webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options) as driver: