Skip to content

unrecognized capability: loggingPrefs #3107

@christian-oreilly

Description

@christian-oreilly

Context

dash                      2.18.2
dash-bootstrap-components 1.6.0
dash-core-components      2.0.0
dash-html-components      2.0.0
dash-table                5.0.0
dash-testing-stub         0.0.2
  • Front-end

    • OS: MacOS
    • Browser: chrome
    • Version: 131

Describe the bug

Trying to execute dash test through pytest I get the following error:

========================================================================= ERRORS ==========================================================================
_________________________________________________________ ERROR at setup of test_001_child_with_0 _________________________________________________________

request = <SubRequest 'dash_duo' for <Function test_001_child_with_0>>
dash_thread_server = <dash.testing.application_runners.ThreadedRunner object at 0x141313da0>
tmpdir = local('/private/var/folders/3k/220tdhsn33709gq9ylr8c6kh0000gp/T/pytest-of-christian/pytest-8/test_001_child_with_00')

    @pytest.fixture
    def dash_duo(request, dash_thread_server, tmpdir) -> DashComposite:
>       with DashComposite(
            dash_thread_server,
            browser=request.config.getoption("webdriver"),
            remote=request.config.getoption("remote"),
            remote_url=request.config.getoption("remote_url"),
            headless=request.config.getoption("headless"),
            options=request.config.hook.pytest_setup_options(),
            download_path=tmpdir.mkdir("download").strpath,
            percy_assets_root=request.config.getoption("percy_assets"),
            percy_finalize=request.config.getoption("nopercyfinalize"),
            pause=request.config.getoption("pause"),
        ) as dc:

../../opt/anaconda3/envs/base12/lib/python3.12/site-packages/dash/testing/plugin.py:179: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../opt/anaconda3/envs/base12/lib/python3.12/site-packages/dash/testing/composite.py:6: in __init__
    super().__init__(**kwargs)
../../opt/anaconda3/envs/base12/lib/python3.12/site-packages/dash/testing/browser.py:68: in __init__
    self._driver = until(self.get_webdriver, timeout=1)
../../opt/anaconda3/envs/base12/lib/python3.12/site-packages/dash/testing/wait.py:17: in until
    res = wait_cond()
../../opt/anaconda3/envs/base12/lib/python3.12/site-packages/dash/testing/browser.py:461: in get_webdriver
    return getattr(self, f"_get_{self._browser}")()
../../opt/anaconda3/envs/base12/lib/python3.12/site-packages/dash/testing/browser.py:502: in _get_chrome
    else webdriver.Chrome(options=options)
../../opt/anaconda3/envs/base12/lib/python3.12/site-packages/selenium/webdriver/chrome/webdriver.py:45: in __init__
    super().__init__(
../../opt/anaconda3/envs/base12/lib/python3.12/site-packages/selenium/webdriver/chromium/webdriver.py:66: in __init__
    super().__init__(command_executor=executor, options=options)
../../opt/anaconda3/envs/base12/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py:241: in __init__
    self.start_session(capabilities)
../../opt/anaconda3/envs/base12/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py:329: in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
../../opt/anaconda3/envs/base12/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py:384: in execute
    self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x1413be450>
response = {'status': 400, 'value': '{"value":{"error":"invalid argument","message":"invalid argument: unrecognized capability: l...ff8192241d3 _pthread_start + 125\\n22  libsystem_pthread.dylib             0x00007ff81921fbd3 thread_start + 15\\n"}}'}

    def check_response(self, response: Dict[str, Any]) -> None:
        """Checks that a JSON response from the WebDriver does not have an
        error.
    
        :Args:
         - response - The JSON response from the WebDriver server as a dictionary
           object.
    
        :Raises: If the response contains an error message.
        """
        status = response.get("status", None)
        if not status or status == ErrorCode.SUCCESS:
            return
        value = None
        message = response.get("message", "")
        screen: str = response.get("screen", "")
        stacktrace = None
        if isinstance(status, int):
            value_json = response.get("value", None)
            if value_json and isinstance(value_json, str):
                import json
    
                try:
                    value = json.loads(value_json)
                    if len(value) == 1:
                        value = value["value"]
                    status = value.get("error", None)
                    if not status:
                        status = value.get("status", ErrorCode.UNKNOWN_ERROR)
                        message = value.get("value") or value.get("message")
                        if not isinstance(message, str):
                            value = message
                            message = message.get("message")
                    else:
                        message = value.get("message", None)
                except ValueError:
                    pass
    
        exception_class: Type[WebDriverException]
        e = ErrorCode()
        error_codes = [item for item in dir(e) if not item.startswith("__")]
        for error_code in error_codes:
            error_info = getattr(ErrorCode, error_code)
            if isinstance(error_info, list) and status in error_info:
                exception_class = getattr(ExceptionMapping, error_code, WebDriverException)
                break
        else:
            exception_class = WebDriverException
    
        if not value:
            value = response["value"]
        if isinstance(value, str):
            raise exception_class(value)
        if message == "" and "message" in value:
            message = value["message"]
    
        screen = None  # type: ignore[assignment]
        if "screen" in value:
            screen = value["screen"]
    
        stacktrace = None
        st_value = value.get("stackTrace") or value.get("stacktrace")
        if st_value:
            if isinstance(st_value, str):
                stacktrace = st_value.split("\n")
            else:
                stacktrace = []
                try:
                    for frame in st_value:
                        line = frame.get("lineNumber", "")
                        file = frame.get("fileName", "<anonymous>")
                        if line:
                            file = f"{file}:{line}"
                        meth = frame.get("methodName", "<anonymous>")
                        if "className" in frame:
                            meth = f"{frame['className']}.{meth}"
                        msg = "    at %s (%s)"
                        msg = msg % (meth, file)
                        stacktrace.append(msg)
                except TypeError:
                    pass
        if exception_class == UnexpectedAlertPresentException:
            alert_text = None
            if "data" in value:
                alert_text = value["data"].get("text")
            elif "alert" in value:
                alert_text = value["alert"].get("text")
            raise exception_class(message, screen, stacktrace, alert_text)  # type: ignore[call-arg]  # mypy is not smart enough here
>       raise exception_class(message, screen, stacktrace)
E       selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: unrecognized capability: loggingPrefs
E       Stacktrace:
E       0   chromedriver                        0x00000001086f6e12 chromedriver + 6696466
E       1   chromedriver                        0x00000001086eec2a chromedriver + 6663210
E       2   chromedriver                        0x00000001080f6e3e chromedriver + 405054
E       3   chromedriver                        0x000000010811f18b chromedriver + 569739
E       4   chromedriver                        0x00000001081771bf chromedriver + 930239
E       5   chromedriver                        0x00000001081769e8 chromedriver + 928232
E       6   chromedriver                        0x000000010817870f chromedriver + 935695
E       7   chromedriver                        0x00000001081785e6 chromedriver + 935398
E       8   chromedriver                        0x000000010816c613 chromedriver + 886291
E       9   chromedriver                        0x0000000108139950 chromedriver + 678224
E       10  chromedriver                        0x000000010813a34e chromedriver + 680782
E       11  chromedriver                        0x00000001086c4700 chromedriver + 6489856
E       12  chromedriver                        0x00000001086c71a9 chromedriver + 6500777
E       13  chromedriver                        0x00000001086c6ccb chromedriver + 6499531
E       14  chromedriver                        0x00000001086c7635 chromedriver + 6501941
E       15  chromedriver                        0x00000001086af4b4 chromedriver + 6403252
E       16  chromedriver                        0x00000001086c791f chromedriver + 6502687
E       17  chromedriver                        0x00000001086a08e4 chromedriver + 6342884
E       18  chromedriver                        0x00000001086df308 chromedriver + 6599432
E       19  chromedriver                        0x00000001086df4c5 chromedriver + 6599877
E       20  chromedriver                        0x00000001086ee7f8 chromedriver + 6662136
E       21  libsystem_pthread.dylib             0x00007ff8192241d3 _pthread_start + 125
E       22  libsystem_pthread.dylib             0x00007ff81921fbd3 thread_start + 15

../../opt/anaconda3/envs/base12/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py:232: InvalidArgumentException
================================================================= short test summary info =================================================================
ERROR pylossless/dash/tests/test_mne_visualizer.py::test_001_child_with_0 - selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: unrecognized capability: loggingPrefs

Removing the following lines solves the issues:

options.set_capability("loggingPrefs", {"browser": "SEVERE"})
options.set_capability("goog:loggingPrefs", {"browser": "SEVERE"})

as proposed in #2590

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2considered for next cyclebugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions