Skip to content

Instantly share code, notes, and snippets.

@joshbrooks
Last active September 20, 2021 14:26
Show Gist options
  • Save joshbrooks/77801e611f919d3d793e3d1d86ce7077 to your computer and use it in GitHub Desktop.
Save joshbrooks/77801e611f919d3d793e3d1d86ce7077 to your computer and use it in GitHub Desktop.
Collection of useful things to do with playwright
# Create and Enter your venv (if not already done)
python -m venv env
. env/bin/activate
# Install playwright
pip install playwright
# Install the chromium browser runner
playwright install chromium

If you have a failed test run on openly_dird and you want to know why, you can go to "Actions" -> click your failed test -> download "trace" You will get a zip file. Extract the test run you need (you may need to consult the test file to find the file name).

Here's a failed test run example

E       playwright._impl._api_types.TimeoutError: Timeout 10000ms exceeded.
E       =========================== logs ===========================
E       waiting for selector "text=Add Project"
E       ============================================================
=========================== short test summary info ============================
FAILED dird_tests/test_editor.py::EditorSaveTests::test_create_activity - pla...
============ 1 failed, 165 passed, 4 warnings in 203.48s (0:03:23) =============

In the file test_editor.py I found the line context.tracing.stop(path="test_new_activity.zip") That's the file I extract and load into playwright:

(env) josh@m4800:~/Downloads/trace$ playwright show-trace test_new_activity.zip 

This gives me an interface to view screen content, console logs, and network calls made from that page Here I can see from the screenshot the test which did not pass

Timeout 10000ms exceeded.
page.click
PARAMETERS
selector: "text=Add Project"
LOG
waiting for selector "text=Add Project"

and I find a JS error on page navigation which cause that timeout

Cannot read properties of undefined (reading 'name')
TypeError: Cannot read properties of undefined (reading 'name')
    at http://localhost:54047/static/dird.js:1:237863
    at Array.map (<anonymous>)
    at http://localhost:54047/static/dird.js:1:237809
    at Array.forEach (<anonymous>)
    at Object.onBeforeMount (http://localhost:54047/static/dird.js:1:237627)
    at Object.mount (http://localhost:54047/static/vendors.js:2:286853)
    at Object.mount (http://localhost:54047/static/vendors.js:2:285973)
    at Object.update (http://localhost:54047/static/vendors.js:2:279865)
    at Object.mount (http://localhost:54047/static/vendors.js:2:279482)
    at http://localhost:54047/static/vendors.js:2:282436
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment