Skip to content

Commit

Permalink
test: throw element not found error (#12665)
Browse files Browse the repository at this point in the history
  • Loading branch information
sun0day committed Mar 30, 2023
1 parent 363fa31 commit 1f011d8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion playground/test-utils.ts
Expand Up @@ -71,7 +71,11 @@ const timeout = (n: number) => new Promise((r) => setTimeout(r, n))

async function toEl(el: string | ElementHandle): Promise<ElementHandle> {
if (typeof el === 'string') {
return await page.$(el)
const realEl = await page.$(el)
if (realEl == null) {
throw new Error(`Cannot find element: "${el}"`)
}
return realEl
}
return el
}
Expand Down

0 comments on commit 1f011d8

Please sign in to comment.