diff --git a/tests/openvidu-recording-java-tutorial.spec.js b/tests/openvidu-recording-java-tutorial.spec.js index 004ae1e7..26b3c538 100644 --- a/tests/openvidu-recording-java-tutorial.spec.js +++ b/tests/openvidu-recording-java-tutorial.spec.js @@ -1,6 +1,7 @@ const { test, expect, chromium } = require('@playwright/test'); test('Checking for the presence of two active webcams in an OpenVidu session', async () => { + // Launch a headless Chromium browser with specific settings. const browser = await chromium.launch({ headless: true, deviceScaleFactor: 1, @@ -8,32 +9,39 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a args: ["--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream", "--ignore-certificate-errors"] }); + // Create a new context in the browser with necessary permissions for the first page. const context = await browser.newContext({ permissions: ['camera', 'microphone'], }); + // Create a new page within the first context. const page1 = await context.newPage(); + // Create a new incognito context for the second page. const context2 = await browser.newContext({ incognito: true }); + // Create a new page within the second context. const page2 = await context2.newPage(); try { - + // Navigate to a specific URL on the first page. await page1.goto('https://localhost:5000'); + // Perform actions on the first page. await page1.click('#join-btn'); await page1.waitForSelector('#session', { visible: true }); + // Find video elements on the first page and verify there is exactly one. var videoElements = await page1.$$('video'); - expect(videoElements.length).toEqual(1); + // Capture a screenshot of the first page and save it to a file. await page1.screenshot({ path: '../results/screenshots/page1_screenshot.png' }); + // Navigate to a specific URL on the second page. await page2.goto('https://localhost:5000'); - + // Perform actions on the second page. await page2.click('#join-btn'); await page2.waitForSelector('#session', { visible: true }); await page2.click('#buttonStartRecording'); @@ -44,20 +52,17 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a await page2.click('#buttonGetRecording'); await page2.screenshot({ path: '../results/screenshots/page2_stoprecording_screenshot.png' }); - // Buscar los elementos HTML que contienen los streams de video + // Find video elements on the second page and verify there are exactly two. videoElements = await page2.$$('video'); - - // Comprobar que hay exactamente dos elementos encontrados expect(videoElements.length).toEqual(2); - // Cerrar las páginas y el navegador. + // Close the pages and the browser. await Promise.all([page1.close(), page2.close()]); - } catch (error) { - // En caso de error, captura las pantallas y registra el error + // In case of error, capture screenshots and log the error. await page1.screenshot({ path: '../results/screenshots/error_page1_screenshot.png' }); await page2.screenshot({ path: '../results/screenshots/error_page2_screenshot.png' }); - throw error; // Lanza el error nuevamente para que el test falle + throw error; // Rethrow the error to make the test fail } }); diff --git a/tests/openvidu-recording-node-tutorial.spec.js b/tests/openvidu-recording-node-tutorial.spec.js index b60fff9c..6d9dbb1e 100644 --- a/tests/openvidu-recording-node-tutorial.spec.js +++ b/tests/openvidu-recording-node-tutorial.spec.js @@ -1,6 +1,7 @@ const { test, expect, chromium } = require('@playwright/test'); test('Checking for the presence of two active webcams in an OpenVidu session', async () => { + // Launch a headless Chromium browser with specific settings. const browser = await chromium.launch({ headless: true, deviceScaleFactor: 1, @@ -8,31 +9,39 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a args: ["--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream", "--ignore-certificate-errors"] }); + // Create a new context in the browser with necessary permissions for the first page. const context = await browser.newContext({ permissions: ['camera', 'microphone'], }); + // Create a new page within the first context. const page1 = await context.newPage(); + // Create a new incognito context for the second page. const context2 = await browser.newContext({ incognito: true }); + // Create a new page within the second context. const page2 = await context2.newPage(); try { + // Navigate to a specific URL on the first page. await page1.goto('http://localhost:5000'); + // Perform actions on the first page. await page1.click('#join-btn'); await page1.waitForSelector('#session', { visible: true }); + // Find video elements on the first page and verify there is exactly one. var videoElements = await page1.$$('video'); - expect(videoElements.length).toEqual(1); + // Capture a screenshot of the first page and save it to a file. await page1.screenshot({ path: '../results/screenshots/page1_screenshot.png' }); + // Navigate to a specific URL on the second page. await page2.goto('http://localhost:5000'); - + // Perform actions on the second page. await page2.click('#join-btn'); await page2.waitForSelector('#session', { visible: true }); await page2.click('#buttonStartRecording'); @@ -43,20 +52,17 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a await page2.click('#buttonGetRecording'); await page2.screenshot({ path: '../results/screenshots/page2_stoprecording_screenshot.png' }); - // Buscar los elementos HTML que contienen los streams de video + // Find video elements on the second page and verify there are exactly two. videoElements = await page2.$$('video'); - - // Comprobar que hay exactamente dos elementos encontrados expect(videoElements.length).toEqual(2); - // Cerrar las páginas y el navegador. + // Close the pages and the browser. await Promise.all([page1.close(), page2.close()]); - } catch (error) { - // En caso de error, captura las pantallas y registra el error + // In case of error, capture screenshots and log the error. await page1.screenshot({ path: '../results/screenshots/error_page1_screenshot.png' }); await page2.screenshot({ path: '../results/screenshots/error_page2_screenshot.png' }); - throw error; // Lanza el error nuevamente para que el test falle + throw error; // Rethrow the error to make the test fail } }); diff --git a/tests/openvidu-vue-tutorial.spec.js b/tests/openvidu-vue-tutorial.spec.js index d89acbf2..9b846069 100644 --- a/tests/openvidu-vue-tutorial.spec.js +++ b/tests/openvidu-vue-tutorial.spec.js @@ -1,7 +1,7 @@ const { test, expect, chromium } = require('@playwright/test'); test('Checking for the presence of two active webcams in an OpenVidu session', async () => { - // Inicia una instancia del navegador Chromium en modo headless con configuraciones específicas. + // Launch a headless Chromium browser with specific settings. const browser = await chromium.launch({ headless: true, deviceScaleFactor: 1, @@ -9,53 +9,52 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a args: ["--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream"] }); - // Crea un nuevo contexto en el navegador con los permisos necesarios. + // Create a new context in the browser with necessary permissions. const context = await browser.newContext({ permissions: ['camera', 'microphone'], }); - // Crea dos nuevas páginas dentro del contexto del navegador. + // Create two new pages within the browser context. const page1 = await context.newPage(); const page2 = await context.newPage(); try { - // Navega a una URL específica en la primera página y realiza acciones como llenar un campo de texto y hacer clic en un botón. + // Navigate to a specific URL on page 1 and perform actions such as filling a text field and clicking a button. await page1.goto('http://localhost:8080'); await page1.fill('input[type="text"]', 'User1'); await page1.click('button.btn.btn-lg.btn-success'); - // Espera a que un elemento específico se vuelva visible. + // Wait for a specific element to become visible. await page1.waitForSelector('#session', { visible: true }); - await page1.waitForTimeout(5000); - - // Encuentra los elementos de video en la página y verifica que haya exactamente dos de ellos. + + // Find video elements on page 1 and verify there are exactly two of them. var videoElements = await page1.$$('video'); expect(videoElements.length).toEqual(2); - // Captura una captura de pantalla de la página 1 y la guarda en un archivo. + // Capture a screenshot of page 1 and save it to a file. await page1.screenshot({ path: '../results/screenshots/page1_screenshot.png' }); - // Navega a una URL específica en la segunda página y realiza acciones similares a las de la primera página. + // Navigate to a specific URL on page 2 and perform similar actions to page 1. await page2.goto('http://localhost:8080'); await page2.fill('input[type="text"]', 'User2'); await page2.click('button.btn.btn-lg.btn-success'); await page2.waitForSelector('#session', { visible: true }); await page2.waitForTimeout(5000); - // Busca los elementos de video en la segunda página y verifica que haya exactamente dos de ellos. + // Find video elements on page 2 and verify there are exactly two of them. videoElements = await page2.$$('video'); - expect(videoElements.length).toEqual(3); + expect(videoElements.length).toEqual(2); - // Captura una captura de pantalla de la página 2 y la guarda en un archivo. + // Capture a screenshot of page 2 and save it to a file. await page2.screenshot({ path: '../results/screenshots/page2_screenshot.png' }); - // Cierra las páginas y el navegador. + // Close the pages and the browser. await Promise.all([page1.close(), page2.close()]); await browser.close(); } catch (error) { - // En caso de error, captura las pantallas y registra el error. + // In case of error, capture screenshots and log the error. await page1.screenshot({ path: '../results/screenshots/error_page1_screenshot.png' }); await page2.screenshot({ path: '../results/screenshots/error_page2_screenshot.png' }); - throw error; // Lanza el error nuevamente para que la prueba falle. + throw error; // Rethrow the error to make the test fail. } });