update web_selenium.py to use try-with for headers (#2988)

Co-authored-by: Richard Beales <rich@richbeales.net>
This commit is contained in:
non-adjective
2023-05-01 08:45:52 -07:00
committed by GitHub
parent 94ec4a4ea5
commit 7fc6f2abfc

View File

@@ -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}")