Skip to content

Commit 9b637f8

Browse files
fix waitForExpression
1 parent 5e9ed5b commit 9b637f8

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/stringifyExtension.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,9 @@ export class StringifyExtension extends PuppeteerStringifyExtension {
252252
out: LineWriter,
253253
step: WaitForExpressionStep
254254
): void {
255-
out.appendLine(`await browser.executeAsync(async () => ${step.expression})`)
255+
out.appendLine('await browser.waitUntil(() => (').startBlock()
256+
out.appendLine( `browser.execute(() => ${step.expression})`).endBlock()
257+
out.appendLine(')')
256258
}
257259

258260
getSelector(selectors: Selector[], flow: UserFlow): string | undefined {

test/stringifyExtension.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@ describe('StringifyExtension', () => {
5858
})
5959

6060
it('should correctly exports change step', async () => {
61+
const ext = new StringifyExtension()
62+
const step = {
63+
type: 'waitForExpression',
64+
expression: 'document.querySelector(\'#someElem\').innerText === \' x 2\''
65+
}
66+
const flow = { title: 'change step', steps: [step] }
67+
const writer = new InMemoryLineWriter(' ')
68+
await ext.stringifyStep(writer, step as any, flow as any)
69+
expect(writer.toString()).toBe(
70+
'await browser.waitUntil(() => (\n' +
71+
' browser.execute(() => document.querySelector(\'#someElem\').innerText === \' x 2\')\n' +
72+
')\n'
73+
)
74+
})
75+
76+
it('supports waitForExpression', async () => {
6177
const ext = new StringifyExtension()
6278
const step = {
6379
type: 'change' as const,

0 commit comments

Comments
 (0)