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):