mherrmann / helium

Lighter web automation with Python
MIT License
4.92k stars 374 forks source link

Selenium runs indefinitely when adding add_experimental_option('debuggerAddress',address) #108

Open danepadley opened 1 year ago

danepadley commented 1 year ago

Running selenium == 4.9.1 on windows machine.

The code that I'm running: chrome_options = Options() chrome_options.add_argument(r"--user-data-dir=C:\Users\user.name\AppData\Local\Google\Chrome\User Data") chrome_options.add_argument(r'--profile-directory=Default') chrome_options.add_experimental_option('debuggerAddress', 'localhost:9014') driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),options=chrome_options)

If I run the code above without the experimental options I have no issues, but will have to close any opened Chrome windows. When I run with the experimental option, it will work 50% of the time. The other 50% of the time the script will run indefinitely and doesn't throw any errors.

I have tried adding os.environ["DBUS_SESSION_BUS_ADDRESS"] = "/dev/null" But this didn't change anything.

When I look at the port, I can see that the chromedriver is running, but it doesn't open the chrome tab and keeps running indefinitely.

When I run it with the trace printing to the command prompt, after around 5 minutes it stops at this: --- modulename: client, funcname: begin client.py(312): if self.headers is not None: client.py(317): while True: client.py(318): version, status, reason = self._read_status() --- modulename: client, funcname: _read_status client.py(279): line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") --- modulename: socket, funcname: readinto socket.py(700): self._checkClosed() socket.py(701): self._checkReadable() --- modulename: socket, funcname: readable socket.py(734): if self.closed: socket.py(736): return self._reading socket.py(702): if self._timeout_occurred: socket.py(704): while True: socket.py(705): try: socket.py(706): return self._sock.recv_into(b)

I have included a link to the full trace output if that helps. selenium_issue.txt

Expected behaviour Have selenium open at debugger address everytime with no issues.