Skip to content

Commit a47a0e2

Browse files
committed
Playwright JavaScript Framework
1 parent 991a967 commit a47a0e2

File tree

2 files changed

+48
-33
lines changed

2 files changed

+48
-33
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Include playwright module
2+
const { test, expect } = require('@playwright/test');
3+
const { _android } = require('playwright');
4+
5+
/**
6+
* Bakkappa N
7+
*/
8+
test('Mobile Chrome browser Test', { tag: '@MobileTest' }, async ({ }) => {
9+
10+
// Setup for launching mobile app
11+
const browserServer = await _android.launchServer({ deviceSerialNumber: 'emulator-5554' })
12+
const wsEndPoint = browserServer.wsEndpoint();
13+
const device = await _android.connect(wsEndPoint);
14+
15+
let page;
16+
17+
await test.step(' Print device details - model, serial no.', async () => {
18+
console.log('Device model : ' + device.model());
19+
console.log('Device serial no. : ' + device.serial());
20+
})
21+
22+
await test.step('Close if already app is opened', async () => {
23+
await device.shell('am force-stop com.android.chrome');
24+
})
25+
26+
const context = await device.launchBrowser();
27+
page = await context.newPage();
28+
29+
await test.step('Open mobile chrome browser and enter URL', async () => {
30+
await page.goto('https://m.youtube.com/');
31+
await page.screenshot({ path: './mobile_app_test.png' });
32+
})
33+
34+
await test.step('Search with keywords', async () => {
35+
await page.click("(//*[@aria-label='Search YouTube'])[2]");
36+
await page.fill("[name='search_query']",'playwright by testers talk');
37+
await page.press("[name='search_query']",'Enter');
38+
await page.waitForTimeout(3000);
39+
})
40+
41+
await test.step('Validate Playwright by Testers Talk link', async () => {
42+
await expect(page.getByRole('link', { name: 'Playwright by Testers Talk☑️' })).toBeVisible();
43+
await page.screenshot({ path: './mobile_app_test_results.png' });
44+
await context.close();
45+
await page.close();
46+
});
47+
})
48+

Playwright-JavaScript/tests/04_Mobile_Tests.spec.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)