diff --git a/e2e/hotkeys.spec.ts b/e2e/hotkeys.spec.ts index 60c1d163e7a..69ae5e0d019 100644 --- a/e2e/hotkeys.spec.ts +++ b/e2e/hotkeys.spec.ts @@ -36,10 +36,18 @@ test('User can interact with the app using the keyboard', async ({ await page.keyboard.press('n'); const nextCourse = '**/declare-javascript-variables'; await page.waitForURL(nextCourse); + // Ensure that the page content is loaded before simulating user interactions. + await expect( + page.getByRole('heading', { name: 'Declare JavaScript Variables' }) + ).toBeVisible(); await page.keyboard.press('p'); const previousCourse = '**/comment-your-javascript-code'; await page.waitForURL(previousCourse); + // Ensure that the page content is loaded before simulating user interactions. + await expect( + page.getByRole('heading', { name: 'Comment Your JavaScript Code' }) + ).toBeVisible(); await page.keyboard.press('e'); await expect(page.getByLabel(editorPaneLabel)).toBeFocused();