Add local/Sauce Labs native Playwright session support to examples/playwright - #197
Merged
Merged
Conversation
…aywright Ports demo-csharp PR #115's TARGET=local|sauce design: tests can run against a locally launched browser or Sauce Labs' native Playwright WebSocket endpoint by flipping one env var, with GROUPING=module|test controlling session reuse and failure-recycling. Only the `browser` fixture is overridden, so pytest-playwright's native --browser/--headed/--tracing/--screenshot flags and markers keep working unmodified for both targets. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Resolves conflicts in Pipfile/Pipfile.lock: keeps this branch's playwright-tests --dist=loadfile fix alongside main's playwright==1.61.0 pin and certifi bump. Pipfile.lock regenerated via `pipenv lock`. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Resolves the root Pipfile modify/delete conflict from #199's per-suite Pipfile split: the root Pipfile is gone, and this branch's only real delta (playwright-tests' --dist=loadfile flag) is ported into the new examples/playwright/Pipfile instead. Verified the suite still passes with GROUPING=module reuse working correctly post-merge. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Runs TARGET=sauce against real Sauce Labs using the org's CI secrets, scoped to examples/playwright/**. No local browser install step needed - TARGET=sauce only ever calls browser_type.connect(), never .launch(). This is the first live run of the TARGET=sauce path outside personal credentials - the earlier 500 error was reproduced only with a personal Sauce account, so this run will show whether the org's CI secrets behave differently. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ng tests Adds test_cart.py, test_checkout.py, test_navigation.py, and test_sorting.py, each getting its own Sauce session under GROUPING=module since they're separate files. Also fixes test_login.py: the old "invalid" test used a locked-out username with a wrong password, which never actually exercised the locked-out error message - split into four scenarios (valid login, locked-out user, invalid credentials, logout). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
SAUCE_BUILD_NAME was computed from datetime.now() at module import time. Under pytest-xdist each worker is a separate process that imports conftest.py independently at its own slightly different startup moment, so different workers ended up with different timestamps and split one test run across multiple Sauce builds. Fixed via pytest-xdist's controller/worker data-sharing hooks: pytest_configure_node stashes the controller's build name for each worker before it starts, and pytest_configure overrides the worker's own value with it. Verified with 6 worker processes all reporting the identical build name. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
pytest now writes a JUnit XML report (--junitxml), which dorny/test-reporter publishes as a check run and job summary (reporter: python-xunit, matching pytest's xunit2-style output). Runs with if: always() so failures still get reported. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
examples/playwright: tests run against a locally launched browser (default) or Sauce Labs' native Playwright WebSocket endpoint by settingTARGET=sauce, withGROUPING=module|testcontrolling session reuse and failure-recycling (a passed test's session is kept for reuse, a failed one is closed immediately).browserfixture is overridden -pytest-playwright's nativecontext/page,--browser/--headed/--slowmo/--tracing/--video/--screenshotflags, and markers (browser_context_args,skip_browser/only_browser) all keep working unmodified for both targets.examples/playwright/Pipfile'splaywright-testsscript runs with--dist=loadfile, required forGROUPING=modulereuse to work correctly underpytest-xdist(its default scheduling can otherwise split one file's tests across worker processes).examples/playwright/README.mddocumentingTARGET,GROUPING, session lifecycle, and usage (mirrors the demo-csharp/demo-js Playwright READMEs)..github/workflows/playwright.yml, scoped toexamples/playwright/**, runningTARGET=sauceagainst real Sauce Labs with the org's CI secrets. No local browser install step needed -TARGET=sauceonly ever callsbrowser_type.connect(), never.launch().Pipfilesplit) -examples/playwrightnow has its ownPipfile/Pipfile.lockinstead of a shared root one.Test plan
TARGET=localverified: all 3 browser engines (chromium/firefox/webkit),GROUPING=moduleandGROUPING=test, and the failure-recycling lifecycle (failed test evicts+closes its session, passed test keeps it for reuse) all pass locally.pytest-playwrightflags verified end-to-end:--browser=firefox, multi-engine runs (--browser=chromium --browser=firefox), and--tracing=on --screenshot=on(produced realtrace.zip/screenshot artifacts).pytest -n8 --dist=loadfile examples/playwright/verified to keep each file's tests on the same xdist worker (required forGROUPING=modulereuse).TARGET=sauceverified end-to-end in CI: the newplaywright.ymlworkflow ran on this PR using the org's actualSAUCE_USERNAME/SAUCE_ACCESS_KEYsecrets and passed (3 passed in 22.92s- https://github.com/saucelabs-training/demo-python/actions/runs/30308827632). The earlier 500Infrastructure Erroronly reproduced with a personal Sauce account during local development; it wasn't a bug in this code.🤖 Generated with Claude Code