I am working on a script for a class and I execute this code:
from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom bs4 import BeautifulSoupimport randomimport timex = random.randrange(1, 16)i = f"mntl-recipe-card-meta_{x}-0"url = "https://www.eatingwell.com/recipes/17947/mealtimes/dinner/"driver = webdriver.Chrome()driver.maximize_window()driver.get(url)link = driver.find_element(By.ID, i)link.click()time.sleep(2)current_url = driver.execute_script("return window.location.href;")print("Current URL:", current_url)driver.quit()The code works up until it has to click on the link, then it throws a error that says "WebDriverException: Message: no such execution context". The error seems to be thrown after I click on the link as the program stops working as the new page is loading in. I want to be able to do things after I click on the element so this stops the program from working.