I started a Docker container with:
docker run -d --shm-size="4g" --hostname selenium_firefox selenium/standalone-firefox
In another container with Python:
...
>>> driver = webdriver.Remote(command_executor="http://" +selenium_host+":4444/w
d/hub", desired_capabilities=DesiredCapabilities.FIREFOX, keep_alive=True)
>>> driver.title
''
>>> driver.title
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/webdri
ver.py", line 447, in title
resp = self.execute(Command.GET_TITLE)
File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/webdri
ver.py", line 424, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/errorh
andler.py", line 247, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Unable to execute reques
t for an existing session: Unable to find session with ID: 5c619451-8361-4ec9-9b
7e-58b7afac15ff
Build info: version: '4.1.1', revision: 'e8fcc2cecf'
System info: host: 'selenium_firefox', ip: '172.17.0.3', os.name: 'Linux', os.ar
ch: 'amd64', os.version: '5.4.0-89-generic', java.version: '11.0.13'
Driver info: driver.version: unknown
The first driver.title I ran it immediately after creating the remote webdriver.
Then I waited for some time (around 15 minutes) and ran driver.title again, and it seem that the Python console has lost connection to the corresponding browser.
Why does this happen and how do I avoid it? It doesn't happen if I don't use a remote webdriver.