How to control log level in Firefox with arsenic

Viewed 119

I am running an arsenic (Firefox + Geckodriver) script in a Docker container. I am trying to control log levels in the Browser like this:

from arsenic import browsers

browser = browsers.Firefox(
        **{'moz:firefoxOptions': {
            'args': ['-headless'],
            'binary': '/usr/bin/firefox'},
            'log': {'level': 'warning'}
        }
    )

However, when I try running it, I get:

ERROR:asyncio:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f5c93762df0>
ERROR:asyncio:Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x7f5c92dd9940>, 25597.978260712)]']
connector: <aiohttp.connector.TCPConnector object at 0x7f5c937629d0>
ERROR:root:

Got ('log is not the name of a known capability or extension capability', None, '') with https://example.com.

Docker image: python:3.9
Firefox: 94.0b7 (linux-x86_64)
Geckodriver: v0.30.0 (linux-x86_64)

I've checked a bunch of times and the sytnax of the Firefox options seems to ok. If anyone has a clue to solving this, that would be much appreciated.

1 Answers

So, after reading this https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities/firefoxOptions one more time, I realized that the log argument needs to passed as an argument. This works for me:

    browser = browsers.Firefox(
        **{'moz:firefoxOptions': {
            'args': ['-headless', '-log', "{'level': 'warning'}"],
            'binary': '/usr/bin/firefox'}
        }
    )

I'll have to play around a bit more to see if it should be warning or warn, but passing the log argument works.

Related