From 53b981eff2d168d92de31182b186827aecd88b8b Mon Sep 17 00:00:00 2001 From: Nick Pope Date: Thu, 9 May 2024 18:03:31 +0100 Subject: [PATCH] Added support for using Microsoft Edge with Selenium. --- django/test/selenium.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/django/test/selenium.py b/django/test/selenium.py index 2840afb9ec..db6c78a96b 100644 --- a/django/test/selenium.py +++ b/django/test/selenium.py @@ -83,7 +83,7 @@ class SeleniumTestCaseBase(type(LiveServerTestCase)): options = self.import_options(self.browser)() if self.headless: match self.browser: - case "chrome": + case "chrome" | "edge": options.add_argument("--headless=new") case "firefox": options.add_argument("-headless") @@ -194,10 +194,12 @@ class SeleniumTestCase(LiveServerTestCase, metaclass=SeleniumTestCaseBase): self.selenium.execute_script("localStorage.removeItem('theme');") def set_emulated_media(self, features, media=""): - if self.browser != "chrome": - self.skipTest("Emulated media controls are only supported on Chrome.") - # Chrome Dev Tools Protocol Emulation.setEmulatedMedia - # https://chromedevtools.github.io/devtools-protocol/1-3/Emulation/#method-setEmulatedMedia + if self.browser not in {"chrome", "edge"}: + self.skipTest( + "Emulation.setEmulatedMedia is only supported on Chromium and " + "Chrome-based browsers. See https://chromedevtools.github.io/devtools-" + "protocol/1-3/Emulation/#method-setEmulatedMedia for more details." + ) self.selenium.execute_cdp_cmd( "Emulation.setEmulatedMedia", {"media": media, "features": features} )