From 86dcee966e2d2982cd20d53d15e9d11ca424eb83 Mon Sep 17 00:00:00 2001 From: Santiago21112001 Date: Mon, 8 Apr 2024 01:04:29 +0200 Subject: [PATCH] waitSelector --- webapp/e2e/steps/history.steps.js | 3 +++ webapp/e2e/steps/jugar-form.steps.js | 5 +++++ webapp/e2e/steps/login-form.steps.js | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/webapp/e2e/steps/history.steps.js b/webapp/e2e/steps/history.steps.js index a4e1ab6..7e5c0b5 100644 --- a/webapp/e2e/steps/history.steps.js +++ b/webapp/e2e/steps/history.steps.js @@ -66,6 +66,9 @@ defineFeature(feature, test => { }); when('I press history', async () => { + // Espera a que el enlace con el texto "Historial" esté presente y sea clickeable + await page.waitForSelector('a', { text: 'Historial' }); + await expect(page).toClick('a', { text: 'Historial' }); }); diff --git a/webapp/e2e/steps/jugar-form.steps.js b/webapp/e2e/steps/jugar-form.steps.js index db5eb16..d031632 100644 --- a/webapp/e2e/steps/jugar-form.steps.js +++ b/webapp/e2e/steps/jugar-form.steps.js @@ -47,6 +47,11 @@ defineFeature(feature, (test) => { }); when('the user clicks the "Play" button on the homepage', async () => { + + + // Espera a que el botón con el texto "JUGAR" esté presente y sea clickeable + await page.waitForSelector('button', { text: 'JUGAR' }) + //NO LO ENCUENTRA await expect(page).toClick('button', { text: 'JUGAR' }) await page.waitForTimeout(1500); diff --git a/webapp/e2e/steps/login-form.steps.js b/webapp/e2e/steps/login-form.steps.js index e274275..a5dbf3d 100644 --- a/webapp/e2e/steps/login-form.steps.js +++ b/webapp/e2e/steps/login-form.steps.js @@ -50,7 +50,9 @@ defineFeature(feature, test => { then('The user is redirected', async () => { - //No lo encuentra + // Espera a que el elemento

con el texto deseado esté presente en la página + await page.waitForSelector('p', { text: '¿A que estás esperando?' }); + await expect(page).toMatchElement("p", { text: "¿A que estás esperando?" }); }); })