kaliiiiiiiiii / Selenium-Driverless

undetected Selenium without usage of chromedriver
https://kaliiiiiiiiii.github.io/Selenium-Driverless/
Other
545 stars 66 forks source link

[OSX] TimeoutError: driver.quit() #54

Closed srichards2103 closed 1 year ago

srichards2103 commented 1 year ago

TimeoutError on MacOS when quitting driver:

Traceback (most recent call last):
  File "/Users/srichards/.pyenv/versions/3.11.1/lib/python3.11/site-packages/selenium_driverless/webdriver.py", line 434, in quit
    check_timeout(start, timeout)
  File "/Users/srichards/.pyenv/versions/3.11.1/lib/python3.11/site-packages/selenium_driverless/utils/utils.py", line 119, in check_timeout
    raise TimeoutError(f"driver.quit took longer than timeout: {timeout}")
TimeoutError: driver.quit took longer than timeout: 30

with this code:

from selenium_driverless import webdriver

async with webdriver.Chrome() as driver:
    await driver.get('https://www.google.com')
    await driver.sleep(0.5)
    await driver.quit()
kaliiiiiiiiii commented 1 year ago

that's at https://github.com/kaliiiiiiiiii/Selenium-Driverless/blob/93cb59a6590bbe07e5ea727ec8ebed466b791fd6/src/selenium_driverless/webdriver.py#L428-L434 basically tries to kill the chrome by it's PID until there's an OSError (=> nothing running on PID) @srichards2103 Did the Browser-window close?

srichards2103 commented 1 year ago

@kaliiiiiiiiii yeah the browser window closes, then it goes on to timeout after 30 seconds.

kaliiiiiiiiii commented 1 year ago

@srichards2103 Oh that's interesting. So maybe MacOs doesn't trow an OSError lol. https://stackoverflow.com/questions/13595076/why-does-os-killpid-0-return-none-although-process-has-terminated might be related

srichards2103 commented 1 year ago

@kaliiiiiiiiii Just tried by changing os.kill to os.killpg as suggested in that thread. Seems to work no problem.

kaliiiiiiiiii commented 1 year ago

@kaliiiiiiiiii Just tried by changing os.kill to os.killpg as suggested in that thread. Seems to work no problem.

@srichards2103 Thank's a lot for testing! I'll test if that works on Windows and Linux as well as expected & implement it.

kaliiiiiiiiii commented 1 year ago

@srichards2103 This should be resolved with selenium-driverless==1.6 Please close this issue if it's fixed now:)