From 68d0f95262c83adebd9ec3a416d53d8d54ada166 Mon Sep 17 00:00:00 2001 From: anthony kugel Date: Mon, 12 Jun 2023 07:13:19 -0500 Subject: [PATCH] Fixed #34649 -- Fixed headless deprecation warning on Selenium 4.8+. Thanks David Smith for the report and initial patch. --- django/test/selenium.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/django/test/selenium.py b/django/test/selenium.py index aa714ad365e..86ff9e2f4f0 100644 --- a/django/test/selenium.py +++ b/django/test/selenium.py @@ -79,10 +79,11 @@ class SeleniumTestCaseBase(type(LiveServerTestCase)): def create_options(self): options = self.import_options(self.browser)() if self.headless: - try: - options.headless = True - except AttributeError: - pass # Only Chrome and Firefox support the headless mode. + match self.browser: + case "chrome": + options.add_argument("--headless=new") + case "firefox": + options.add_argument("-headless") return options def create_webdriver(self):