'Selenium .close() triggers WebDriverException: chrome not reachable
This is my env:
- Ubuntu 20 LTS
- selenium 3.141.0
- google-chrome-stable 101.0.4951.64-1
- ChromeDriver 101.0.4951.41
I run this simple code in headless mode (I do not need the GUI):
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--ignore-certificate-errors')
browser = webdriver.Chrome(options=chrome_options)
# get a web page
browser.get("myUrl")
# signing in...
username = browser.find_element_by_name("user")
password = browser.find_element_by_name("pass")
submit_button = browser.find_element_by_xpath("...")
username.send_keys("user")
password.send_keys("pass")
submit_button.click()
print('User logged in...')
# Click on the update button in the next page
update_button = browser.find_element_by_id('barbaz')
update_button.click()
browser.close()
This code worked fine with older versions of google-chrome-stable and ChromeDriver. Strangely enough, now browser.close() triggers this error:
WebDriverException: Message: chrome not reachable (Session info: headless chrome=101.0.4951.64)
What is happening?
Edit:
browser.quit() instead of browser.close() seems fixing. I leave this question open, in the case anyone would like to explain the reason behind that.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
