diff --git a/autogpt/commands/web_selenium.py b/autogpt/commands/web_selenium.py index 79a8ffd9463d..0f5764b5343d 100644 --- a/autogpt/commands/web_selenium.py +++ b/autogpt/commands/web_selenium.py @@ -175,4 +175,9 @@ def add_header(driver: WebDriver) -> None: Returns: None """ - driver.execute_script(open(f"{FILE_DIR}/js/overlay.js", "r").read()) + try: + with open(f"{FILE_DIR}/js/overlay.js", "r") as overlay_file: + overlay_script = overlay_file.read() + driver.execute_script(overlay_script) + except Exception as e: + print(f"Error executing overlay.js: {e}")