I have a notebook that uses a Selenium Web Driver for Chrome and it works the first time I run the notebook. If I run the notebook again, it will not work and gives the error message:
WebDriverException: Message: unknown error: unable to discover open pages Stacktrace: #0 0x560b13ce5e89 <unknown>
Here is the code that results in the error message:
chromedriver_path = '/local_disk0/tmp/chromedriver'
chromebinary_path = '/usr/bin/google-chrome'
s = Service(ChromeDriverManager().install())
options = Options()
options.binary_location = chromebinary_path
options.add_argument('--disable-gpu')
options.add_argument('--no-sandbox')
#options.add_argument('--remote-debugging-port=9222')
options.add_argument("--remote-debugging-port=9230")
options.add_argument('--disable-dev-shm-usage')
options.headless = True
driver = webdriver.Chrome(service=s, options=options)
Also, at the end of my notebook I have the following code which may be part of the problem, not sure:
driver.stop_client()
driver.close()
driver.quit()
s.stop()
What can I change to be able to run the notebook as many times as I would like without having it give that error message.