From e069102cdaf6aaf8919195be0fd71125a8852fff Mon Sep 17 00:00:00 2001 From: dakota002 <dakota.d@live.com> Date: Mon, 8 Jul 2024 14:28:53 -0400 Subject: [PATCH] Example of using the waitForLoadState function and counts of results --- __playwright__/circulars/archive.spec.ts | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/__playwright__/circulars/archive.spec.ts b/__playwright__/circulars/archive.spec.ts index 5744f7fd8..4b3c3d211 100644 --- a/__playwright__/circulars/archive.spec.ts +++ b/__playwright__/circulars/archive.spec.ts @@ -41,23 +41,18 @@ test.describe('Circulars archive page', () => { page, }) => { await page.goto('/circulars?query=230812B') - await page.waitForFunction( - (n) => - document.getElementsByTagName('ol')[0].getElementsByTagName('li') - .length >= n, - 64 - ) + await page.waitForLoadState() + await expect(page.locator('ol', { has: page.locator('li') })).toBeVisible() + expect(await page.locator('ol > li').count()).toBe(64) }) test('search finds no results for query with typo', async ({ page }) => { // this highlights this search behaviour does not capture cases where there is a minor typo await page.goto('/circulars?query=230812C') - await page.waitForFunction( - (n) => - document.getElementsByTagName('ol')[0].getElementsByTagName('li') - .length === n, - 0 - ) + await page.waitForLoadState() + await expect( + page.locator('ol', { has: page.locator('li') }) + ).not.toBeVisible() }) test('search finds results that contain exact string but not similar strings', async ({