-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Closed as not planned
Closed as not planned
Copy link
Labels
A-needs-triagingA Selenium member will evaluate this soon!A Selenium member will evaluate this soon!I-defectSomething is not working as intendedSomething is not working as intendedJ-staleApplied to issues that become stale, and eventually closed.Applied to issues that become stale, and eventually closed.
Description
What happened?
Trying to use the new BiDi feature to get browser console logs/errors with Firefox. However, with certain types (not sure the exact cause of this) of js error, a stackTrace object is not present in the json passed in callback handler, resulting in a KeyError and ws connection being closed, thus all subsequent logs/errors being lost
After some preliminary analysis, it seems like this line is causing the issue. Monkey patching it to stacktrace=json["stackTrace"] if "stackTrace" in json else {}, solved the issue for me, but I'm not sure what's causing these js errors with no stackTrace and if this issue exist with other browsers etc.
How can we reproduce the issue?
from selenium import webdriver
options = webdriver.FirefoxOptions()
options.enable_bidi = True
# somehow I need this for Firefox to work now, could be a separate issue
options.set_capability("loggingPrefs", None)
options.add_argument("--headless")
service = webdriver.FirefoxService(executable_path="/snap/bin/firefox.geckodriver")
driver = webdriver.Firefox(options=options, service=service)
console_logs = []
driver.script.add_console_message_handler(console_logs.append)
driver.script.add_javascript_error_handler(console_logs.append)
# example website with js error
driver.get('https://www.microsoft.com/en-ca/')
# observer error is not present
console_logs
# and subsequent get to the site result in no logs at all, neither js errors nor console logsRelevant log output
N/AOperating System
Ubuntu 24.04.1 (WSL and native)
Selenium version
Python 4.26.1
What are the browser(s) and version(s) where you see this issue?
Firefox 132.0.1 | 131.0.3
What are the browser driver(s) and version(s) where you see this issue?
geckodriver 0.35.0
Are you using Selenium Grid?
no
Metadata
Metadata
Assignees
Labels
A-needs-triagingA Selenium member will evaluate this soon!A Selenium member will evaluate this soon!I-defectSomething is not working as intendedSomething is not working as intendedJ-staleApplied to issues that become stale, and eventually closed.Applied to issues that become stale, and eventually closed.