#34649 closed Cleanup/optimization (fixed)

Modernise selenium --headless support

Reported by: David Smith Owned by: Anthony Kugel
Component: Testing framework Version: 4.2
Severity: Normal Keywords:
Cc: Sarah Boyce Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Django's own test suite supports --headless mode for Selenium tests.

This is currently achieved by setting option.headless=True, source.

However, this approach is "going away", see blog post and release notes. This warning can be seen in recent runs on djangoci, see logs.

Instead we should add an argument to the options.

For Chrome: options.add_argument("--headless=new"), see docs
For Firefox: options.add_argument("-headless"), see docs

There's more more background here on the Chrome change. Eventually the new version will become the default with the current headless mode being removed.

Maybe something like this could work:

    def create_options(self):
        options = self.import_options(self.browser)()
        if self.headless:
            match self.browser:
                case "chrome":
                    options.add_argument("--headless=new")
                case "firefox":
                    options.add_argument("-headless")
        return options

Change History (6)

comment:1 by Sarah Boyce, 18 months ago

Cc: Sarah Boyce added
Component: UncategorizedTesting framework
Easy pickings: set
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

Thank you for the report!

comment:2 by Bhuvnesh, 18 months ago

Owner: changed from nobody to Bhuvnesh
Status: newassigned

comment:3 by Bhuvnesh, 18 months ago

Owner: Bhuvnesh removed
Status: assignednew

comment:4 by Anthony Kugel, 18 months ago

Owner: set to Anthony Kugel
Status: newassigned

comment:5 by Mariusz Felisiak, 18 months ago

Has patch: set
Triage Stage: AcceptedReady for checkin

comment:6 by Mariusz Felisiak <felisiak.mariusz@…>, 18 months ago

Resolution: fixed
Status: assignedclosed

In 68d0f95:

Fixed #34649 -- Fixed headless deprecation warning on Selenium 4.8+.

Thanks David Smith for the report and initial patch.

Note: See TracTickets for help on using tickets.
Back to Top