OAuth popup during a recording: everything I did in the popup is missing from the spec
Asked 5,730 views2 answers
24votes
Recording a login that goes through our identity provider. The provider opens in a popup, you finish there, the popup closes and the app is signed in.
bash
sdods record -p demo-shop -e staging --name sso-login
The recorded spec has the click that opens the popup, then nothing at all until after it closed. Everything I typed inside the popup is missing. Converting it gives me a feature that is one click followed by an assertion that cannot pass.
Is there a tag or a flag for multi-window flows that I have not found?
No, and I would rather say so plainly than send you looking for it.
The built-in UI step library has no step that waits for a popup or switches to another tab. Conversion maps recorded actions onto steps; with no step meaning "do this in the other window", the popup half of the flow has nothing to convert into and drops out. What you are seeing is that gap, not a recorder bug.
The workaround is to stop trying to say it in Gherkin. Put the whole popup in a page-object method and give it one step name:
ts
@When('I sign in through the identity provider as {string}')
async ssoLogin(username: string) {
const popup = await this.waitForPopup(async () => {
await this.page.getByRole('button', { name: 'Sign in with SSO' }).click();
});
await popup.getByLabel('Email').fill(username);
await popup.getByRole('button', { name: 'Continue' }).click();
await popup.waitForEvent('close');
}
waitForPopup(action) is on BasePage, and it starts waiting before it runs your action, which is the part people get wrong writing it themselves. The feature then reads as one line and the multi-window mechanics live in TypeScript, where they belong.
The recorded spec is still worth keeping for the parts before and after the popup — it runs fine under -l recorded, it just cannot become a feature on its own.
Confirming where the gap is: the step library, not the recorder and not the converter. BasePage carries waitForPopup(), frame(), setInputFiles() and waitForDownload() precisely because these are the flows Gherkin should not be asked to spell out.
If you would rather the suite never saw the popup at all, capture the state once with a person in the loop:
bash
sdods auth capture -p demo-shop -e staging -u standard --interactive
Interactive capture opens codegen and waits while you complete the login, popup and all, then saves the storage state. After that, scenarios tagged @user:standard never touch the identity provider, and neither does a recording started with --user standard.
You still want one scenario that exercises the real login. That is the one that gets Thom's page-object method; the other thirty do not need it.