forked from codeurjc-students/openvidu-tutorials-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3cf789d
commit 255cc71
Showing
3 changed files
with
45 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,60 @@ | ||
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, | ||
userAgent: 'Chrome/88.0.4324.182', | ||
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. | ||
} | ||
}); |