-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Description
What happened?
When running the attached code, the following happens:
- Firefox is launched
- Browser navigates to a URL
- PDF is displayed in a new tab
- Execution hangs
When opening this URL, a PDF download is automatically triggered. When the download completes, Firefox opens a new tab and displays the PDF. At this point, the Selenium script's execution stops, and no further code is run (driver.quit() is never reached). Execution just hangs indefinitely after opening the PDF. You can see from the debug log that nothing further happens.
On Chrome and Edge, the behavior is different. Instead, the PDF download begins, but then driver.quit() is immediately called... which closes the browser and leaves you with an incomplete download. I think this is expected since it's not explicitly waiting on the download to complete before continuing.
Note: this issue originated from this Reddit post.
How can we reproduce the issue?
import logging
from selenium import webdriver
logging.basicConfig(level=logging.DEBUG)
url = 'https://ioes.dio.es.gov.br/portal/edicoes/download/9965'
driver = webdriver.Firefox()
driver.get(url)
driver.quit() # this line is never reachedRelevant log output
DEBUG:selenium.webdriver.common.selenium_manager:Selenium Manager binary found at: /home/cgoldberg617/code/venv/lib/python3.13/site-packages/selenium/webdriver/common/linux/selenium-manager
DEBUG:selenium.webdriver.common.selenium_manager:Executing process: /home/cgoldberg617/code/venv/lib/python3.13/site-packages/selenium/webdriver/common/linux/selenium-manager --browser firefox --debug --language-binding python --output json
DEBUG:selenium.webdriver.common.selenium_manager:geckodriver not found in PATH
DEBUG:selenium.webdriver.common.selenium_manager:firefox not found in PATH
DEBUG:selenium.webdriver.common.selenium_manager:firefox not found in the system
DEBUG:selenium.webdriver.common.selenium_manager:Required browser: firefox 135.0.1
DEBUG:selenium.webdriver.common.selenium_manager:firefox 135.0.1 already exists
DEBUG:selenium.webdriver.common.selenium_manager:firefox 135.0.1 is available at /home/cgoldberg617/.cache/selenium/firefox/linux64/135.0.1/firefox
DEBUG:selenium.webdriver.common.selenium_manager:Required driver: geckodriver 0.36.0
DEBUG:selenium.webdriver.common.selenium_manager:geckodriver 0.36.0 already in the cache
DEBUG:selenium.webdriver.common.selenium_manager:Driver path: /home/cgoldberg617/.cache/selenium/geckodriver/linux64/0.36.0/geckodriver
DEBUG:selenium.webdriver.common.selenium_manager:Browser path: /home/cgoldberg617/.cache/selenium/firefox/linux64/135.0.1/firefox
DEBUG:selenium.webdriver.common.service:Started executable: `/home/cgoldberg617/.cache/selenium/geckodriver/linux64/0.36.0/geckodriver` in a child process with pid: 22088 using 0 to output -3
DEBUG:selenium.webdriver.remote.remote_connection:POST http://localhost:45461/session {'capabilities': {'firstMatch': [{}], 'alwaysMatch': {'browserName': 'firefox', 'acceptInsecureCerts': True, 'moz:debuggerAddress': True, 'pageLoadStrategy': <PageLoadStrategy.normal: 'normal'>, 'browserVersion': None, 'moz:firefoxOptions': {'binary': '/home/cgoldberg617/.cache/selenium/firefox/linux64/135.0.1/firefox', 'prefs': {'remote.active-protocols': 3}}}}}
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): localhost:45461
DEBUG:urllib3.connectionpool:http://localhost:45461 "POST /session HTTP/1.1" 200 0
DEBUG:selenium.webdriver.remote.remote_connection:Remote response: status=200 | data={"value":{"sessionId":"c58ede4a-49cf-496f-a446-7578af53681b","capabilities":{"acceptInsecureCerts":true,"browserName":"firefox","browserVersion":"135.0.1","moz:accessibilityChecks":false,"moz:buildID":"20250216192613","moz:debuggerAddress":"127.0.0.1:45325","moz:geckodriverVersion":"0.36.0","moz:headless":false,"moz:platformVersion":"6.6.65-06377-gaae6fc9ba7df","moz:processID":22091,"moz:profile":"/tmp/rust_mozprofilerIRWwo","moz:shutdownTimeout":60000,"moz:webdriverClick":true,"moz:windowless":false,"pageLoadStrategy":"normal","platformName":"linux","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0"}}} | headers=HTTPHeaderDict({'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-cache', 'content-length': '816', 'date': 'Mon, 03 Mar 2025 17:18:07 GMT'})
DEBUG:selenium.webdriver.remote.remote_connection:Finished Request
DEBUG:selenium.webdriver.remote.remote_connection:POST http://localhost:45461/session/c58ede4a-49cf-496f-a446-7578af53681b/url {'url': 'https://ioes.dio.es.gov.br/portal/edicoes/download/9965'}Operating System
Linux
Selenium version
Python Selenium 4.29.0
What are the browser(s) and version(s) where you see this issue?
Firefox 135.0.1
What are the browser driver(s) and version(s) where you see this issue?
Geckodriver 0.36.0
Are you using Selenium Grid?
No