I want the network traffic from a recording session so we can replay the flow offline in CI later. Do I record the flow, then do a second pass for the HAR, or is there a way to get both out of one sitting? Doing it twice means the two artefacts are of two slightly different journeys, which feels like it will bite us.
Can one session give me both the recorded spec and a HAR for offline replay?
2 answers
Accepted answer
One session.
--save-harcaptures the network while you drive:bashsdods record -p demo-shop -e staging --name checkout --user standard --save-har --har-glob "**/api/**"Three files come out of that:
textprojects/demo-shop/recorded/checkout.spec.ts projects/demo-shop/har/staging/checkout.har projects/demo-shop/har/staging/checkout.har.jsonThe
.har.jsonis the sidecar: the URL glob you used, when it was captured, andsource: codegenso you can tell it apart from a HAR produced by a run.--har-globdefaults to**/*, which on a real app means fonts, images and analytics beacons all land in the file, so narrowing it is usually right.One naming detail: the name is slugified for both files.
--name "Checkout Flow"gives youcheckout-flow.spec.tsandcheckout-flow.har, not what you typed, so pick something you would have typed anyway.answered by Gio Castellano521 ·Capturing it is half the job — replay is keyed on the scenario tag, not on the recording. A scenario plays back from
har/<env>/<name>.harbecause it carries@har:<name>, so when you convert the recording into a feature, tag the scenario to match the file you just wrote:gherkin@ui @regression @har:checkout Scenario: Standard user checks outThen:
bashsdods run -p demo-shop -e staging -t @har:checkout --har-replay --strict--strictaborts any request that is not in the HAR and blocks every other network call, which is what makes the CI run genuinely offline rather than mostly offline.Two failure modes to know about. Lint tells you
@har:checkout has no recorded file under har/<env>/checkout.harif the tag and the file drifted apart, which is the good outcome. And the tag has no room for spaces, so the slugified name from the recording is the one to type.answered by Priya Venkateshmaintainer29,604 ·
Have the same question?
Ask it with the command you ran and the output you got, and it will be answered here.
Ask a questionRelated
- Does colorScheme from the env use: block reach a recording, or only the runner?0 answers
- har record printed no scrub line and the Cookie header is still sitting in the file0 answers
- sdods har list leaves glob and recorded blank even though the sidecar exists2 answers
- Closed the browser after ten minutes and got "Codegen closed without writing a spec"2 answers
- OAuth popup during a recording: everything I did in the popup is missing from the spec2 answers