I read all the post about this topic:
How to use/attach an existing browser using Selenium?
How can I reconnect to the browser opened by webdriver with...
Maintain and re-use existing webdriver browser instance ...
How to make Selenium Chrome Driver to open on a new tab in a ...
The solution is clear but I am facing an unexpected issue. I get the error message:
"ConnectionRefusedError: [WinError 10061]"
Here is my code:
file_path = 'existing_session.txt'
# check if size of file is 0
if path.exists(file_path) and os.stat(file_path).st_size != 0:
print('File is not empty')
## GET SESSION ID and URL COMMAND FROM FILE
f = open('existing_session.txt', 'r')
fl = f.readlines()
session_id = fl[0]
url_command = fl[1]
print("session_id" + session_id)
print("url_command" + url_command)
f.close()
driver = webdriver(command_executor=url_command, desired_capabilities={})
driver.session_id = session_id
As you can see, I am getting the session_id
and url
from a text file. When my code is running the first session, it saved session id
and url
in a text file in order to reconnect to session later.
So I didn't find any solution for this issue. I add rules in my firewall for letting geckodriver.exe
going in and out. But it didn't fix my problem.
I am thinking about firewall issue. But maybe it is something else? Has anyone already faced this issue and know how to fix it please?