Opened 3 years ago

Closed 3 years ago

#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, 3 years ago

Cc: Sarah Boyce added
Component: Uncategorized → Testing framework
Easy pickings: set
Triage Stage: Unreviewed → Accepted
Type: Uncategorized → Cleanup/optimization

Thank you for the report!

comment:2 by Bhuvnesh, 3 years ago

Owner: changed from nobody to Bhuvnesh
Status: new → assigned

comment:3 by Bhuvnesh, 3 years ago

Owner: Bhuvnesh removed
Status: assigned → new

comment:4 by Anthony Kugel, 3 years ago

Owner: set to Anthony Kugel
Status: new → assigned

comment:5 by Mariusz Felisiak, 3 years ago

Has patch: set
Triage Stage: Accepted → Ready for checkin

comment:6 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

Resolution: → fixed
Status: assigned → closed

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