#34649: Modernise selenium --headless support -----------------------------------------+------------------------ Reporter: David Smith | Owner: nobody Type: Uncategorized | Status: new Component: Uncategorized | Version: 4.2 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | -----------------------------------------+------------------------ Django's own test suite supports `--headless mode` for Selenium tests.
This is currently achieved by setting `option.headless=True`, [https://github.com/django/django/blob/221c27bd6a10155f65c9f93ecc67a61c76befbb7/django/test/selenium.py#L83 source]. However, this approach is "going away", see [https://www.selenium.dev/blog/2023/headless-is-going-away/ blog post] and [https://www.selenium.dev/blog/2023/selenium-4-8-0-released/ release notes]. This warning can be seen in recent runs on djangoci, see [https://djangoci.com/job/django- selenium/1502/database=sqlite3,label=focal,python=python3.11/console logs]. Instead we should add an argument to the options. For Chrome: `options.add_argument("--headless=new")`, see [https://www.selenium.dev/blog/2023/headless-is-going-away/#after docs] For Firefox: `options.add_argument("-headless")`, see [https://www.selenium.dev/documentation/webdriver/browsers/firefox/#arguments docs] There's more more background [https://developer.chrome.com/articles/new- headless/ 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 }}} -- Ticket URL: <https://code.djangoproject.com/ticket/34649> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/01070188a9ba341c-b6e0f080-e2b9-4a34-a443-a81b49097d23-000000%40eu-central-1.amazonses.com.