Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
8d010f39
Kaydet (Commit)
8d010f39
authored
Şub 26, 2019
tarafından
Johannes Hoppe
Kaydeden (comit)
Mariusz Felisiak
May 17, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #30220 -- Added support for headless mode in selenium tests.
üst
e286987a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
1 deletion
+27
-1
selenium.py
django/test/selenium.py
+16
-1
unit-tests.txt
docs/internals/contributing/writing-code/unit-tests.txt
+3
-0
3.0.txt
docs/releases/3.0.txt
+3
-0
runtests.py
tests/runtests.py
+5
-0
No files found.
django/test/selenium.py
Dosyayı görüntüle @
8d010f39
...
...
@@ -17,6 +17,8 @@ class SeleniumTestCaseBase(type(LiveServerTestCase)):
external_host
=
None
# Sentinel value to differentiate browser-specific instances.
browser
=
None
# Run browsers in headless mode.
headless
=
False
def
__new__
(
cls
,
name
,
bases
,
attrs
):
"""
...
...
@@ -62,11 +64,24 @@ class SeleniumTestCaseBase(type(LiveServerTestCase)):
def
import_webdriver
(
cls
,
browser
):
return
import_string
(
"selenium.webdriver.
%
s.webdriver.WebDriver"
%
browser
)
@classmethod
def
import_options
(
cls
,
browser
):
return
import_string
(
'selenium.webdriver.
%
s.options.Options'
%
browser
)
@classmethod
def
get_capability
(
cls
,
browser
):
from
selenium.webdriver.common.desired_capabilities
import
DesiredCapabilities
return
getattr
(
DesiredCapabilities
,
browser
.
upper
())
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.
return
options
def
create_webdriver
(
self
):
if
self
.
selenium_hub
:
from
selenium
import
webdriver
...
...
@@ -74,7 +89,7 @@ class SeleniumTestCaseBase(type(LiveServerTestCase)):
command_executor
=
self
.
selenium_hub
,
desired_capabilities
=
self
.
get_capability
(
self
.
browser
),
)
return
self
.
import_webdriver
(
self
.
browser
)()
return
self
.
import_webdriver
(
self
.
browser
)(
options
=
self
.
create_options
()
)
@tag
(
'selenium'
)
...
...
docs/internals/contributing/writing-code/unit-tests.txt
Dosyayı görüntüle @
8d010f39
...
...
@@ -230,6 +230,9 @@ See the `selenium.webdriver`_ package for the list of available browsers.
Specifying ``--selenium`` automatically sets ``--tags=selenium`` to run only
the tests that require selenium.
Some browsers (e.g. Chrome or Firefox) support headless testing, which can be
faster and more stable. Add the ``--headless`` option to enable this mode.
.. _selenium.webdriver: https://github.com/SeleniumHQ/selenium/tree/master/py/selenium/webdriver
.. _running-unit-tests-dependencies:
...
...
docs/releases/3.0.txt
Dosyayı görüntüle @
8d010f39
...
...
@@ -254,6 +254,9 @@ Tests
references, and entity references that refer to the same character as
equivalent.
* Django test runner now supports headless mode for selenium tests on supported
browsers. Add the ``--headless`` option to enable this mode.
URLs
~~~~
...
...
tests/runtests.py
Dosyayı görüntüle @
8d010f39
...
...
@@ -446,6 +446,10 @@ if __name__ == "__main__":
'--selenium'
,
action
=
ActionSelenium
,
metavar
=
'BROWSERS'
,
help
=
'A comma-separated list of browsers to run the Selenium tests against.'
,
)
parser
.
add_argument
(
'--headless'
,
action
=
'store_true'
,
help
=
'Run selenium tests in headless mode, if the browser supports the option.'
,
)
parser
.
add_argument
(
'--selenium-hub'
,
help
=
'A URL for a selenium hub instance to use in combination with --selenium.'
,
...
...
@@ -506,6 +510,7 @@ if __name__ == "__main__":
if
options
.
selenium_hub
:
SeleniumTestCaseBase
.
selenium_hub
=
options
.
selenium_hub
SeleniumTestCaseBase
.
external_host
=
options
.
external_host
SeleniumTestCaseBase
.
headless
=
options
.
headless
SeleniumTestCaseBase
.
browsers
=
options
.
selenium
if
options
.
bisect
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment