Is there a way for Selenium to connect to an already open instance?

176 views Asked by At

I need to access a browser that is already open. I'm using Python, but if you have another language, I welcome help! I'm trying to access a website and when I break its captcha even manually (the browser is starting with Selenium) it simply reports that it's wrong even though it's right and I can't access the certificate. In anonymous mode it shows the certificate but when clicking it goes wrong anyway.

I tried to access in anonymous mode, as another user, doing different ways so the site wouldn't recognize the robot.

1

There are 1 answers

1
IronSpiderMan On BEST ANSWER

you can run chrome with command:

chrome.exe --remote-debugging-port=9222 --user-data-dir="D:/ChromeProfile"

the user-data-dir is a new dir for user data.

and in selenium, you should create driver like this:

from selenium.webdriver.chrome.options import Options
from selenium import webdriver
chrome_options = Options()
chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
driver = webdriver.Chrome(options=chrome_options)

remember use the same port.