Repository navigation
Conversation
varunkasyap
left a comment
There was a problem hiding this comment.
Thanks for picking this. Could you please verify that you are able to run Playwright tests after changes?
| regressions, the `--screenshots` flag can be passed. | ||
|
|
||
| More information about [running the Selenium tests][8] for Django can be found | ||
| More information about [running the Playground tests][8] for Django can be found |
There was a problem hiding this comment.
I believe this is a typo
| More information about [running the Playground tests][8] for Django can be found | |
| More information about [running the Playwright tests][8] for Django can be found |
I think reference hyperlink should be available from Django 6.2 onwards in https://docs.djangoproject.com/en/stable/internals/contributing/writing-code/unit-tests/#running-the-playwright-tests
| /django/entrypoint.bash | ||
| --selenium=edge | ||
| --selenium-hub=http://selenium-hub:4444/wd/hub | ||
| --playwright=edge |
There was a problem hiding this comment.
only these browsers are available
--playwright=chromium,firefox,webkit
we no longer have edge
| working_dir: /django/source/docs | ||
| environment: | ||
| BUILDDIR: /django/output/docs | ||
| BUILDDIR: /django/output/docs No newline at end of file |
There was a problem hiding this comment.
new line at the end
| BUILDDIR: /django/output/docs | |
| BUILDDIR: /django/output/docs | |
|
|
||
| x-selenium-base: &selenium-base | ||
| x-playwright-base: &playwright-base | ||
| image: mcr.microsoft.com/playwright |
There was a problem hiding this comment.
its not only node image it has multiple things inside:
- Node.js runtime
- Playwright library pre-installed
- Chromium, Firefox, and WebKit browsers already downloaded
- All the OS-level dependencies those browsers need (fonts, codecs, etc.)
There was a problem hiding this comment.
not sure, why nodejs based image for a python project
There was a problem hiding this comment.
because this is necessay for playwright environment to get setup in our system to perform the test. Its just nodejs runtime
| - :test\_tube: Test supported core database backends — MariaDB, MySQL, Oracle, PostgreSQL, SQLite | ||
| - :earth\_africa: Test supported core geospatial backends — MariaDB, MySQL, Oracle, PostGIS, SpatiaLite | ||
| - :globe\_with\_meridians: Test user interfaces in different browsers using Selenium — Chrome, Edge, Firefox | ||
| - :globe\_with\_meridians: Test user interfaces in different browsers using Playwright — Chrome, Edge, Firefox |
There was a problem hiding this comment.
| - :globe\_with\_meridians: Test user interfaces in different browsers using Playwright — Chrome, Edge, Firefox | |
| - :globe\_with\_meridians: Test user interfaces in different browsers using Playwright — Chromium, Firefox, Webkit |
|
Thanks @varunkasyap, for the suggestion. I will apply the suggested changes |
|
@Vansh1419 Could you please verify that you are able to run Playwright tests? |
|
Hi @varunkasyap, I have made some changes the containerfile and compose.yml for playwright tests to work and out of all tests 2 tests are failing in case of chromium no testcase failed in case of firefox ======================================================================
FAIL: test_collapse_filter_with_unescaped_title (admin_changelist.tests.PlaywrightTests.test_collapse_filter_with_unescaped_title)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/django/source/tests/admin_changelist/tests.py", line 2185, in test_collapse_filter_with_unescaped_title
).not_to_have_attribute("open")
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/playwright/sync_api/_generated.py", line 22144, in not_to_have_attribute
self._sync(
~~~~~~~~~~^
self._impl_obj.not_to_have_attribute(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<4 lines>...
)
^
)
^
File "/usr/local/lib/python3.14/site-packages/playwright/_impl/_sync_base.py", line 115, in _sync
return task.result()
~~~~~~~~~~~^^
File "/usr/local/lib/python3.14/site-packages/playwright/_impl/_assertions.py", line 367, in not_to_have_attribute
await self._not.to_have_attribute(
name, value, ignoreCase=ignoreCase, timeout=timeout
)
File "/usr/local/lib/python3.14/site-packages/playwright/_impl/_assertions.py", line 340, in to_have_attribute
await self._expect_impl(
...<5 lines>...
)
File "/usr/local/lib/python3.14/site-packages/playwright/_impl/_assertions.py", line 128, in _expect_impl
_record_soft_or_raise(
~~~~~~~~~~~~~~~~~~~~~^
AssertionError(
^^^^^^^^^^^^^^^
...<2 lines>...
self._is_soft,
^^^^^^^^^^^^^^
)
^
File "/usr/local/lib/python3.14/site-packages/playwright/_impl/_assertions.py", line 60, in _record_soft_or_raise
raise error
AssertionError: Locator expected not to have attribute
Actual value: attribute present
Call log:
- Expect "not_to_have_attribute" with timeout 5000ms
- waiting for locator("[data-filter-title='It\\'s OK']")
14 × locator resolved to <details open="" data-filter-title="It's OK">…</details>
- unexpected value "attribute present"
Aria snapshot:
- group:
- text: ↓ By It's OK
- list
======================================================================
FAIL: test_collapse_filters (admin_changelist.tests.PlaywrightTests.test_collapse_filters)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/django/source/tests/admin_changelist/tests.py", line 2154, in test_collapse_filters
).not_to_have_attribute("open")
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/playwright/sync_api/_generated.py", line 22144, in not_to_have_attribute
self._sync(
~~~~~~~~~~^
self._impl_obj.not_to_have_attribute(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<4 lines>...
)
^
)
^
File "/usr/local/lib/python3.14/site-packages/playwright/_impl/_sync_base.py", line 115, in _sync
return task.result()
~~~~~~~~~~~^^
File "/usr/local/lib/python3.14/site-packages/playwright/_impl/_assertions.py", line 367, in not_to_have_attribute
await self._not.to_have_attribute(
name, value, ignoreCase=ignoreCase, timeout=timeout
)
File "/usr/local/lib/python3.14/site-packages/playwright/_impl/_assertions.py", line 340, in to_have_attribute
await self._expect_impl(
...<5 lines>...
)
File "/usr/local/lib/python3.14/site-packages/playwright/_impl/_assertions.py", line 128, in _expect_impl
_record_soft_or_raise(
~~~~~~~~~~~~~~~~~~~~~^
AssertionError(
^^^^^^^^^^^^^^^
...<2 lines>...
self._is_soft,
^^^^^^^^^^^^^^
)
^
File "/usr/local/lib/python3.14/site-packages/playwright/_impl/_assertions.py", line 60, in _record_soft_or_raise
raise error
AssertionError: Locator expected not to have attribute
Actual value: attribute present
Call log:
- Expect "not_to_have_attribute" with timeout 5000ms
- waiting for locator("[data-filter-title='superuser status']")
14 × locator resolved to <details open="" data-filter-title="superuser status">…</details>
- unexpected value "attribute present"
Aria snapshot:
- group:
- text: ↓ By superuser status
- list
----------------------------------------------------------------------
Ran 107 tests in 91.132s
FAILED (failures=2)I have added the failed tests could u suggest me where i am doing wrong |
…and fix documentation typo
ffd08a4 to
ab4794f
Compare
i dont know, but, you may not need to think about failing tests. |
| --selenium=chrome | ||
| --selenium-hub=http://selenium-hub:4444/wd/hub | ||
| --playwright=chromium | ||
| --parallel=1 |
There was a problem hiding this comment.
i see this was not there earlier🤔
--parallel=1
There was a problem hiding this comment.
yeah i have added this because i am getting a error while running the docker. I have 2 option
- Is to use --parallel=1 everytime running docker
- is to add in the compose .yml
so i have gone for the 2nd option so person running for the first time won't bother about it
There was a problem hiding this comment.
We should not hardcode that.
please refer https://github.com/django/django/blob/main/tests/runtests.py#L738-L746
There was a problem hiding this comment.
Okay @varunkasyap, i will add this reference in the readme.md
There was a problem hiding this comment.
👍
for your understanding, parallelism is not supported in spawn and forkserver start methods. but, for systems which do not fall in this category can run parallelly.
There was a problem hiding this comment.
thanks @varunkasyap, for clarification i have added these and already made a commit
| [7]: https://docs.djangoproject.com/en/stable/internals/contributing/writing-code/unit-tests/#running-the-unit-tests | ||
| [8]: https://docs.djangoproject.com/en/stable/internals/contributing/writing-code/unit-tests/#running-the-selenium-tests | ||
| [9]: https://docs.djangoproject.com/en/stable/ref/contrib/gis/testing/#geodjango-tests | ||
| [9]: https://docs.djangoproject.com/en/stable/ref/contrib/gis/testing/#geodjango-tests No newline at end of file |
There was a problem hiding this comment.
Because there is no dedicated reference link available for playwright testing in djangoproject
There was a problem hiding this comment.
I'm not sure which one to use
stable will be available after 6.2
https://docs.djangoproject.com/en/stable/internals/contributing/writing-code/unit-tests/#running-the-playwright-tests
There was a problem hiding this comment.
Exactly thats why i havn't put any of these.
Could we put both of them in this case or for now we add reference to the stable one
|
In that case @varunkasyap, the tests are working fine in all three chromium, firefox and webkit |
|
hi @varunkasyap, I have update the readme to add 8 link with its reference to stable one and removed --parallel=1 from compose.yml as suggested |
|
|
||
| x-selenium-base: &selenium-base | ||
| x-playwright-base: &playwright-base | ||
| image: mcr.microsoft.com/playwright |
There was a problem hiding this comment.
I see an issue. The browsers come along with PW Docker image, and you're also running playwright install --with-deps chromium firefox webkit. 🤔
There was a problem hiding this comment.
yeah i got it, by doing so it becoming retundent
|
are you able to run tests now? |
Yes i am able to run the tests |
|
The sidecar is unused, and system without a cached browser will get this. |
Hi @varunkasyap, could you tell me how can i recreate this error in my system. I had already uninstalled the playwright completely and after that is have tested it with this command My tests run completely fine vansh@vanshs-MacBook-Air django-docker-box % docker compose run --rm webkit --parallel=1
[+] 1/1t 1/1
✔ Container django-docker-box-playwright-webkit-1 Started 0.0s
Container django-docker-box-webkit-run-bff21bb97dba Creating
Container django-docker-box-webkit-run-bff21bb97dba Created
Testing against Django installed in '/django/source/django'
Found 107 test(s).
Creating test database for alias 'default'...
System check identified no issues (46 silenced).
................................ssss.......................................................................
----------------------------------------------------------------------
Ran 107 tests in 86.763s
OK (skipped=4)
Destroying test database for alias 'default'... |
|
Hi, |

Summary
Replaces Selenium with Playwright for running Django's user interface tests.
Changes
docker-compose.yml:x-selenium-baseanchor withx-playwright-base(image:
mcr.microsoft.com/playwright)selenium-hubservice and its port mapping — Playwrighthas no hub/grid model, so there's no direct equivalent
selenium-chrome/selenium-edge/selenium-firefoxwith
playwright-chrome/playwright-edge/playwright-firefoxchrome,edge,firefoxcommand services keep their names,now depend on the corresponding
playwright-*service insteadof the hub
--selenium=<browser> --selenium-hub=http://selenium-hub:4444/wd/hubto--playwright=<browser>README.md: updated references to Selenium (Highlights section,User Interface Tests section, Other Versions section) to Playwright
Notes
behavior of always using the latest Selenium tag)
--playwright=<browser>flag assumesruntests.pywill supportthis option — will need to be confirmed/implemented on the Django
side since
entrypoint.bashjust forwards args[8]in the README still points to Django's own docs pagetitled "Running the Selenium tests" (external URL, unchanged)
Closes : #78