selenium.common.exceptions.WebDriverException: Message: unknown error: unable to discover open pages using ChromeDriver through Selenium

This error message…

selenium.common.exceptions.WebDriverException: Message: unknown error: unable to discover open pages
  (Driver info: chromedriver=2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab),platform=a lotows NT 6.1.7601 SP1 x86_64)

…implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.


Solution

Add the argument --no-sandbox through ChromeOptions() to your existing code as follows:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument('--no-sandbox') # Bypass OS security model
driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\path\to\chromedriver.exe')
driver.get('http://www.python.org')
print(driver.title)
driver.quit()

Additional considerations

  • Upgrade Selenium to current levels Version 3.14.0.
  • Upgrade ChromeDriver to current ChromeDriver v2.41 level.
  • Keep Chrome version between Chrome v66-68 levels. (as per ChromeDriver v2.41 release notes)
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • Execute your @Test.
  • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

Leave a Comment