Add BrowserStack SDK + Playwright xUnit/Reqnroll sample#1
Add BrowserStack SDK + Playwright xUnit/Reqnroll sample#1Jimesh-browserstack wants to merge 2 commits intomainfrom
Conversation
Customer-facing starting point for running xUnit + Reqnroll BDD tests on BrowserStack via Playwright .NET and the BrowserStack .NET SDK. Mirrors the shape of browserstack/csharp-playwright-browserstack (NUnit) but adapted for xUnit + Reqnroll. What customers get: - browserstack.yml with 2-platform parallel default (Win11-Chrome, macOS-WebKit) and the Local toggle - Reqnroll feature + step definitions for the bstackdemo add-to-cart scenario - Hooks/PlaywrightHooks.cs that creates an IPage per scenario; the SDK redirects the launch to BrowserStack at runtime, so customer code uses pure Microsoft.Playwright with no manual ConnectAsync - README and yml comments documenting credential setup, parallel run, and the Local-tunnel flip Verified end-to-end against BrowserStack (build hashed_ids 0a6a6690b74901b2691a24ccd6875d4e0fb1f4fb, e04c95b5abc3602aa01874eecfd899b63f57b1c3): both Win11/Chrome and OSX/WebKit sessions started concurrently and passed the cart scenario. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Baaryan
left a comment
There was a problem hiding this comment.
Can we please add the workflows? https://github.com/browserstack/csharp-playwright-browserstack/tree/main/.github/workflows
This is needed for verification before and after the repo setup is done
Also, please trigger that workflow on a fork to test the results for the same
| [BeforeScenario] | ||
| public async Task SetUp() | ||
| { | ||
| _pw = await Playwright.CreateAsync(); |
Mirrors browserstack/csharp-playwright-browserstack/.github/workflows/sanity-workflow.yml so the repo can be verified pre/post setup via workflow_dispatch with a commit_sha input.
- .github/workflows/sanity-workflow.yml: workflow_dispatch + commit_sha input, dotnet 8.0.x on windows-latest, github-script in_progress/completed check-runs, two test phases
- public bstackdemo run (browserstackLocal: false)
- Local run: spins up python -m http.server 45454 with a title-matching index.html, flips browserstackLocal to true, SDK starts/stops the tunnel, scenario asserts the tunneled page title contains "BrowserStack Local"
- Features/LocalSample.feature + StepDefinitions/LocalSampleSteps.cs: BDD analogue of csharp-playwright-browserstack/SampleLocalTest.cs (page.GotoAsync("http://bs-local.com:45454/") + title contains assertion)
- Verified locally on BrowserStack build b06134226200d2c2e5550e70de73dec89b835187: 2 sessions (Win11/Chrome 147 + OSX/Ventura/playwright-webkit 26), both browserstack_status=done, status=passed
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Thanks for the review @Baaryan — addressing both threads here. 1. Workflow ask (review #4242494122)
Done in
The yml also strips the literal Required org-level secrets for
|
| Mode | Build | Sessions | Result |
|---|---|---|---|
| Public bstackdemo (env-var creds) | 0a6a6690… |
2 (Win11/Chrome + OSX/playwright-webkit) | both passed, parallel |
| Public bstackdemo (yml-creds) | e04c95b5… |
2 | both passed, parallel |
| BrowserStack Local + harness on :45454 (new, gating this commit) | b06134226… |
2 (Win11/Chrome 147 7s + OSX/Ventura/playwright-webkit 26 9s) | both passed, browserstack_status: done, tunneled bs-local.com page title matched |
Two readable tells if you'd ever want to confirm "SDK vs not" on a customer's repo at a glance:
- Test-DLL path appears in
browserstack_sdk.Programlog lines underXunitReqnrollPlaywrightBrowserstack.Tests/log/adapter.log. - The dashboard build's
sourcevalue →xunit-reqnroll-playwright:sample-master:v1.0(set in the yml; SDK-path-only — the legacy explicit-ConnectAsyncflow doesn't emit asourcetag).
Happy to add a one-liner // SDK rewrites this at runtime via BrowserStack.TestAdapter above the LaunchAsync if you'd like a permanent in-code signpost so future readers don't ask the same question — let me know.
cc @Baaryan — please re-review when you have a moment.
|
@Baaryan — fork dispatch done. Workflow run:
Total: 3m 25s on Smoking-gun proof the Local tunnel actually carried traffic on the fork runFrom the runner's python http.server stdout (workflow log, step 8): Those Setup notes for future fork dispatches
Re-pinging — please re-review at your convenience. |
Summary
Customer-facing starting point for running xUnit + Reqnroll BDD tests on BrowserStack via Playwright .NET and the BrowserStack .NET SDK. Mirrors the shape of
browserstack/csharp-playwright-browserstack(NUnit reference) but adapted for xUnit + Reqnroll.What customers get
One customer-facing entry point —
dotnet testfrom the project directory runs both platforms in parallel on BrowserStack.Design notes
Hooks/PlaywrightHooks.cscallspw.Chromium.LaunchAsync()unconditionally; the SDK rewrites the launch (Harmony patches viaLib.Harmony) at runtime to route to the per-platform browser configured inbrowserstack.yml. NoChromium.ConnectAsync(wss_url)plumbing in customer code.config/alt-yml directory, and the local-html harness; documented Local mode as a single-linebrowserstackLocal: trueflip in the README rather than a separate run target.Microsoft.Playwright(*) andBrowserStack.TestAdapter(0.*) to match the NUnit reference repo's pinning policy.<framework>-<library>:sample-master:v<N>→xunit-reqnroll-playwright:sample-master:v1.0.userName/accessKeyin the yml are passed literally to the wss CDP endpoint — env vars override only when the lines are absent. Both the yml comment and the README state this explicitly so customers don't get a confusing "Invalid username or password" or BS Local "Auth Token must be alphanumeric" error.Semgrep.ymlalready onmaincontinues to run on PRs.Local verification (already complete)
Ran end-to-end against BrowserStack with Jimesh's creds in env vars (and again with creds substituted into the yml):
dotnet test(env vars, lines absent)0a6a6690…dotnet test(real creds in yml, the customer-facing default)e04c95b5…Cleanup: no leftover
.bakfiles, no strayBrowserStackLocalprocesses (Local toggle isfalsein default yml), Reqnroll-generated*.feature.csare gitignored.Test plan
dotnet testruns both platforms in parallel on BrowserStack — verified via builds linked aboveXunitReqnrollPlaywrightBrowserstack.Tests.Features.BStackDemoCartFeature.AddTheFirstItemToCart Add the first item to cart)bin/,obj/,log/,.config/,.browserstack/,*.feature.cs) are committedxunit-reqnroll-playwright:sample-master:v1.0(please confirm with the ASI team if a different version/prefix is preferred)🤖 Generated with Claude Code