mozilla / geckodriver

WebDriver for Firefox
https://firefox-source-docs.mozilla.org/testing/geckodriver/
Mozilla Public License 2.0
7.03k stars 1.51k forks source link

selenium.common.exceptions.SessionNotCreatedException: Message: Error: NS_ERROR_UNKNOWN_HOST error opening Firefox v103.0.2 with GeckoDriver v0.31.0 #2036

Closed Debanjan-B closed 1 year ago

Debanjan-B commented 1 year ago

System

Testcase

Description:

Firefox v103.0.2 (latest) when initiated with latest GeckoDriver v0.31.0 and Selenium v4.4.0 crashes with NS_ERROR_UNKNOWN_HOST error

Code trials:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Log

import sys
print ("Python Version: " +str(sys.version_info))

import selenium
print("Selenium version: " +selenium.__version__)

log = Log()
log.level = "trace"
options = Options()
options.add_argument(log.level)
s = Service('C:\\BrowserDrivers\\geckodriver.exe')
driver = webdriver.Firefox(service=s, options=options)
driver.get('https://www.google.com/')

Stacktrace

selenium.common.exceptions.SessionNotCreatedException: Message: Error: NS_ERROR_UNKNOWN_HOST
Stacktrace:
#checkLoadingState@chrome://remote/content/shared/Navigate.jsm:239:28
onStateChange@chrome://remote/content/shared/Navigate.jsm:284:28

Trace-level log

Python Version: 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)]
Python Version: sys.version_info(major=3, minor=9, micro=0, releaselevel='final', serial=0)
Python Version: 3.9.0
Selenium version: 4.4.0
Traceback (most recent call last):
  File "C:\Users\debanjan.bhattacharj\Desktop\Python Programs\Selenium_Firefox_tests.py", line 26, in <module>
    driver = webdriver.Firefox(service=s, options=options)
  File "C:\Users\debanjan.bhattacharj\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 177, in __init__
    super().__init__(
  File "C:\Users\debanjan.bhattacharj\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 276, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Users\debanjan.bhattacharj\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 369, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\debanjan.bhattacharj\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 434, in execute
    self.error_handler.check_response(response)
  File "C:\Users\debanjan.bhattacharj\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 243, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: Error: NS_ERROR_UNKNOWN_HOST
Stacktrace:
#checkLoadingState@chrome://remote/content/shared/Navigate.jsm:239:28
onStateChange@chrome://remote/content/shared/Navigate.jsm:284:28
whimboo commented 1 year ago

Note that this issue was also filed as https://bugzilla.mozilla.org/show_bug.cgi?id=1784593. Investigation will happen over there.

whimboo commented 1 year ago

Due to missing feedback from reporter closing the issue.

busedagidir commented 1 year ago

how did you solve it?

iulianduca commented 1 year ago

Hi @whimboo, I'm having the same issue as stated by @Debanjan-B. The geckodriver session crashes at some moment.

in init self.browser = webdriver.Firefox(options=options) File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/firefox/webdriver.py", line 170, in init RemoteWebDriver.init( File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in init self.start_session(capabilities, browser_profile) File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.SessionNotCreatedException: Message: Error: NS_ERROR_UNKNOWN_HOST

geckodriver.log 1680015359113 geckodriver INFO Listening on 127.0.0.1:47875 1680015359118 mozrunner::runner INFO Running command: "/usr/bin/firefox" "--marionette" "-headless" "disable-gpu" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofile3UZ3I5" *** You are running in headless mode. console.warn: services.settings: Ignoring preference override of remote settings server console.warn: services.settings: Allow by setting MOZ_REMOTE_SETTINGS_DEVTOOLS=1 in the environment [GFX1-]: glxtest: libpci missing 1680015359903 Marionette INFO Marionette enabled 1680015359905 Marionette INFO Listening on port 36821 console.error: "Warning: unrecognized command line flag -foreground\n" 1680015359988 RemoteAgent WARN TLS certificate errors will be ignored for this session [GFX1-]: RenderCompositorSWGL failed mapping default framebuffer, no dt console.error: ({})

whimboo commented 1 year ago

@iulianduca which Linux distribution and version is that? Is that local, remote, or in a container? It would be good if you can provide a trace log as well.

y2jhotaru commented 1 year ago

Hi. I'm having the same problem with geckodriver. I reverted firefox to an old version (85) as a workaround.

whimboo commented 1 year ago

@y2jhotaru with which version of Firefox does the problem start for you?

y2jhotaru commented 1 year ago

Hi, I tested with Firefox 112 and GeckoDriver 0.33.0 to reproduce the error.

whimboo commented 1 year ago

@y2jhotaru could you please bisect with other Firefox releases so that we know in which exact version the problem started to happen? Right now we have a kinda broad range from 85 to 112. Maybe you could start with the 91 and 102 ESR releases and then shrink the range further? The downloads of the releases can be found at https://archive.mozilla.org/pub/firefox/releases/. Thanks a lot.

edit: Also how does your testcase exactly look like? How is Firefox started?

SublateSamuel commented 1 year ago

hello everyone, I can contribute with this problem you are facing.

adding a capability setCapability('acceptInsecureCerts', true);

in firefox versions 100.0 to 112.0 throws NS_ERROR_UNKNOWN_HOST exception but this error does not match the truth if you try to reproduce with firefox version 99.0 you will see the real error appear.

Express gratitude for project

whimboo commented 1 year ago

@SublateSamuel what do you mean with the real error? Could you provide a trace log?