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.
* cc: Sarah Boyce (added)
* type: Uncategorized => Cleanup/optimization
* component: Uncategorized => Testing framework
* easy: 0 => 1
* stage: Unreviewed => Accepted
Comment:
Thank you for the report!
--
Ticket URL: <https://code.djangoproject.com/ticket/34649#comment:1>
* owner: nobody => Bhuvnesh
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/34649#comment:2>
* owner: Bhuvnesh => (none)
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/34649#comment:3>
* owner: (none) => aokugel
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/34649#comment:4>
* has_patch: 0 => 1
* stage: Accepted => Ready for checkin
Comment:
[https://github.com/django/django/pull/16965 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/34649#comment:5>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"68d0f95262c83adebd9ec3a416d53d8d54ada166" 68d0f95]:
{{{
#!CommitTicketReference repository=""
revision="68d0f95262c83adebd9ec3a416d53d8d54ada166"
Fixed #34649 -- Fixed headless deprecation warning on Selenium 4.8+.
Thanks David Smith for the report and initial patch.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34649#comment:6>