Así que he escrito una función que, en resumen, hace clic en un botón de preguntas frecuentes y valida que la nueva pestaña esté abierta en el mismo contexto del navegador. el problema que tengo cuando ejecuto mi prueba es que obtengo:
TypeError: no se puede leer la propiedad 'título' de indefinido
Aquí está mi función: PATH src/tests/rms/logoutAndFaqs.spec.ts :
async shouldSeeFaqsInNewTab() { const browserName = await chromium.launch(); const context = await browserName.newContext(); const pages = await context.pages(); await this.click(HomeScreen.faqButton); await this.page.waitForTimeout(1000); expect(await pages[1].title())?.toBe("Title"); } y aquí está la función que se llama - PATH src/pages/rms/rmsHome.page.ts :
import test from "../../helpers/base.page"; test.describe("Ensure you land on the home page when logged in", () => { test.beforeEach(async ({ rmsHome }) => { await rmsHome.gotoRmsHomePage(); }); test.only("Validate that FAQs opens in a new tab", async ({ rmsHome }) => { await rmsHome.shouldSeeFaqsInNewTab(); }); }); Sé que esta línea expect(await pages[1].title())?.toBe("Title") .
específicamente title() está causando un error debido a que es un valor sin asignar. estoy tratando de entender por qué este error? Y como arreglarlo. Gracias