Skip to content

Commit

Permalink
Changes on playwright test
Browse files Browse the repository at this point in the history
  • Loading branch information
IsmailJniah committed Apr 19, 2024
1 parent 3c6fb7c commit ac6dd8e
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 52 deletions.
3 changes: 2 additions & 1 deletion tests/openvidu-angular-web-tutorial.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a
const browser = await chromium.launch({
headless: true,
deviceScaleFactor: 1,
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36',
userAgent: 'Chrome/88.0.4324.182',
args: ["--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream"]
});

Expand All @@ -20,6 +20,7 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a
const page2 = await context.newPage();

try {

// Navigate to the specified URL on page1.
await page1.goto('http://localhost:4200');

Expand Down
4 changes: 2 additions & 2 deletions tests/openvidu-getaroom-test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a
const browser = await chromium.launch({
headless: true,
deviceScaleFactor: 1,
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36',
userAgent: 'Chrome/88.0.4324.182',
args: ["--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream"]
});

Expand All @@ -20,7 +20,7 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a

try {
// Navigate to the specified URL on page1.
await page1.goto('http://127.0.0.1:8080');
await page1.goto('http://localhost:8080');

// Wait for the 'button.btn-success' to be present on the page, with a timeout of 10 seconds.
await page1.waitForSelector('button.btn-success', { timeout: 10000 });
Expand Down
6 changes: 3 additions & 3 deletions tests/openvidu-hello-world-test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a
const browser = await chromium.launch({
headless: true,
deviceScaleFactor: 1,
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36', // Specify the user agent
userAgent: 'Chrome/88.0.4324.182', // Specify the user agent
args: ["--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream"]
});

Expand All @@ -20,7 +20,7 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a

try {
// Navigate to a specific URL on page 1.
await page1.goto('http://127.0.0.1:8080');
await page1.goto('http://localhost:8080');


// Interact with page1, such as clicking a button and waiting for a specific element to become visible, then wait for a timeout..
Expand All @@ -32,7 +32,7 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a
await page1.screenshot({ path: '../results/screenshots/page1_screenshot.png' });

// Navigate to a specific URL on page 1.
await page2.goto('http://127.0.0.1:8080');
await page2.goto('http://localhost:8080');

// Interact with page2 and wait for a specific element to become visible, then wait for a timeout.
await page2.click('#join input[type="submit"]');
Expand Down
3 changes: 2 additions & 1 deletion tests/openvidu-iframe-tutorial.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a
const browser = await chromium.launch({
headless: true,
deviceScaleFactor: 1, // Specify the page's scale factor
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36', // Specify the user agent
userAgent: 'Chrome/88.0.4324.182', // Specify the user agent
args: ["--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream"]
});

Expand All @@ -19,6 +19,7 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a
const page2 = await context.newPage();

try {

// Navigate to the specified URL on page1.
await page1.goto('http://localhost:8081/');

Expand Down
6 changes: 3 additions & 3 deletions tests/openvidu-js-screen-share-tutorial.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a
const browser = await chromium.launch({
headless: true,
deviceScaleFactor: 1, // Specify the page's scale factor
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36', // Specify the user agent
userAgent: 'Chrome/88.0.4324.182', // Specify the user agent
args: ["--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream"]
});

Expand All @@ -20,7 +20,7 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a

try {
// Navigate to the specified URL on page1.
await page1.goto('http://127.0.0.1:8080');
await page1.goto('http://localhost:8080');

// Fill in the '#userName' field with 'Page1', click the 'JOIN' button, and wait for the '#session' element to become visible.
await page1.fill('#userName', 'Page1');
Expand All @@ -32,7 +32,7 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a
await page1.screenshot({ path: '../results/screenshots/page1.png' });

// Navigate to the specified URL on page2.
await page2.goto('http://127.0.0.1:8080');
await page2.goto('http://localhost:8080');

// Fill in the '#userName' field with 'Page2', click the 'JOIN' button, wait for the '#buttonScreenShare' element to become visible, and click it.
await page2.fill('#userName', 'Page2');
Expand Down
13 changes: 10 additions & 3 deletions tests/openvidu-js-web-tutorial.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ 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,
headless: false,
deviceScaleFactor: 1, // Specify the page's scale factor
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36', // Specify the user agent
userAgent: 'Chrome/88.0.4324.182', // Specify the user agent
args: ["--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream"]
});

Expand All @@ -30,9 +30,16 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a
await page1.waitForSelector('#session', { visible: true });
await page1.waitForTimeout(5000);

// Find HTML elements within page2 that contain video streams.
var videoElements = await page1.$$('video');

expect(videoElements.length).toEqual(2);

// Capture a screenshot of page1 and save it to a specific location.
await page1.screenshot({ path: '../results/screenshots/page1.png' });



// Navigate to a specific URL on page2.
await page2.goto('http://localhost:8080');

Expand All @@ -46,7 +53,7 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a
await page2.screenshot({ path: '../results/screenshots/page2.png' });

// Find HTML elements within page2 that contain video streams.
const videoElements = await page2.$$('video');
videoElements = await page2.$$('video');

// Check that there are exactly three elements found.
expect(videoElements.length).toEqual(3);
Expand Down
3 changes: 2 additions & 1 deletion tests/openvidu-react-web-tutorial.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a
const browser = await chromium.launch({
headless: true,
deviceScaleFactor: 1, // Specify the page's scale factor
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36', // Specify the user agent
userAgent: 'Chrome/88.0.4324.182', // Specify the user agent
args: ["--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream"]
});

Expand All @@ -21,6 +21,7 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a
const page2 = await context.newPage();

try {

// Navigate to a specific URL on page1.
await page1.goto('http://localhost:3000');

Expand Down
3 changes: 2 additions & 1 deletion tests/openvidu-recording-java-tutorial.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a
const browser = await chromium.launch({
headless: true,
deviceScaleFactor: 1,
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36',
userAgent: 'Chrome/88.0.4324.182',
args: ["--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream", "--ignore-certificate-errors"]
});

Expand All @@ -19,6 +19,7 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a
const page2 = await context2.newPage();

try {

await page1.goto('https://localhost:5000');

await page1.click('#join-btn');
Expand Down
2 changes: 1 addition & 1 deletion tests/openvidu-recording-node-tutorial.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ test('Checking for the presence of two active webcams in an OpenVidu session', a
const browser = await chromium.launch({
headless: true,
deviceScaleFactor: 1,
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36',
userAgent: 'Chrome/88.0.4324.182',
args: ["--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream", "--ignore-certificate-errors"]
});

Expand Down
85 changes: 49 additions & 36 deletions tests/openvidu-vue-tutorial.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,53 @@ const { test, expect, chromium } = require('@playwright/test');


test('Checking for the presence of two active webcams in an OpenVidu session', async () => {
const browser = await chromium.launch({ headless: true , deviceScaleFactor: 1,
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36',
args : ["--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream"]
});

const context = await browser.newContext({
permissions: ['camera', 'microphone'],
});

const page1 = await context.newPage();
await page1.goto('http://localhost:8080');
await page1.fill('input[type="text"]', 'User1');
await page1.click('button.btn.btn-lg.btn-success');
await page1.waitForSelector('#session', { visible: true });

const page2 = await context.newPage();

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);

await page1.screenshot({ path: 'page1.png' });
await page2.screenshot({ path: 'page2.png' });

// Buscar los elementos HTML que contienen los streams de video
const videoElements = await page2.$$('video');

// Comprobar que hay exactamente dos elementos encontrados
expect(videoElements.length).toEqual(3);

// Cerrar las páginas y el navegador.

await Promise.all([page1.close(), page2.close()]);
await browser.close();
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"]
});

const context = await browser.newContext({
permissions: ['camera', 'microphone'],
});

const page1 = await context.newPage();
const page2 = await context.newPage();

try {
await page1.goto('http://localhost:8080');
await page1.fill('input[type="text"]', 'User1');
await page1.click('button.btn.btn-lg.btn-success');
await page1.waitForSelector('#session', { visible: true });


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);

await page1.screenshot({ path: 'page1.png' });
await page2.screenshot({ path: 'page2.png' });

// Buscar los elementos HTML que contienen los streams de video
const videoElements = await page2.$$('video');

// Comprobar que hay exactamente dos elementos encontrados
expect(videoElements.length).toEqual(3);

// Cerrar las páginas y el navegador.

await Promise.all([page1.close(), page2.close()]);
await browser.close();

} catch (error) {

// En caso de error, captura las pantallas y registra el 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
}


});

0 comments on commit ac6dd8e

Please sign in to comment.