2
0
Эх сурвалжийг харах

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

Thanks David Smith for the report and initial patch.
anthony kugel 1 жил өмнө
parent
commit
68d0f95262

+ 5 - 4
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):