Skip to content

Fix inconsistent playwright test #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 22, 2024
Merged

Conversation

dragid10
Copy link
Owner

@dragid10 dragid10 commented Sep 22, 2024

The Page.to_equal function doesn't seem to exist in playwright for python. There is a NodeJS equivalent, but there is no supported GenericAssertion equivalent for python

https://playwright.dev/docs/api/class-genericassertions

While the overall test assertion would succeed, this would cause the teardown of the test_destination test to fail (viewable by adding addopts = -v --tracing=on to pytest.ini)

This is part of the error I would get prior to adding the code change.

                ^^^^^^^^^^^^^^^^^^
  File "/Users/ao/blackpythondevs.github.io/.venv/lib/python3.11/site-packages/playwright/_impl/_impl_to_api_mapping.py", line 123, in wrapper_func
    return handler(
           ^^^^^^^^
  File "/Users/ao/blackpythondevs.github.io/tests/test.py", line 35, in <lambda>
    page.on("response", lambda response: expect(response.status).to_equal(200))
                                         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ao/blackpythondevs.github.io/.venv/lib/python3.11/site-packages/playwright/sync_api/__init__.py", line 142, in __call__
    raise ValueError(f"Unsupported type: {type(actual)}")
ValueError: Unsupported type: <class 'int'>

Playwright has a built-in "slowmo" feature that would be easiest to use.
https://playwright.dev/python/docs/test-runners#cli-arguments
The `to_equal` doesn't seem to exist in playwright for python. There is a NodeJS equivalent, but there is no supported GenericAssertion equivalent for python

https://playwright.dev/docs/api/class-genericassertions
@dragid10 dragid10 merged commit 07fc1ab into gh-pages Sep 22, 2024
2 checks passed
@dragid10 dragid10 deleted the fix-playwright-tests branch September 22, 2024 23:45
@dragid10 dragid10 restored the fix-playwright-tests branch September 23, 2024 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant