-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
62 lines (62 loc) · 2.42 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const {chromium} = require('playwright');
let browser;
let context;
let page;
describe('tests', async () => {
it('first test', async function() {
browser = await chromium.launch({
headless: false,
timeout: 5000,
slowMo: 250,
args: [
`--lang=en-GB`,
'--no-sandbox',
'--disable-setuid-sandbox',
]
});
context = await browser.newContext();
page = await context.newPage();
await page.goto('https://www.demoblaze.com/');
await page.waitForTimeout(5000);
await page.click('#login2');
await page.waitForTimeout(1000);
await page.type('#loginusername', 'testuserforqatechnicaltest');
await page.type('#loginpassword', 'toto');
await page.click('#logInModal > div > div > div.modal-footer > button.btn.btn-primary');
await page.waitForTimeout(5000);
await console.log('Check I am connected : '+ await page.evaluate(el => el.innerHTML, await page.$('#nameofuser')));
const var1 = await page.$$("#tbodyid .col-lg-4.col-md-6.mb-4");
await var1[0].click();
await page.waitForTimeout(2000);
await console.log(`Check the title is correct (Samsung GALAXY S6): `+await page.evaluate(el => el.innerText, await page.$('#tbodyid > h2')));
await browser.close();
});
it('second test', async function() {
browser = await chromium.launch({
headless: false,
timeout: 5000,
slowMo: 250,
args: [
`--lang=en-GB`,
'--no-sandbox',
'--disable-setuid-sandbox',
]
});
context = await browser.newContext();
page = await context.newPage();
await page.goto('https://www.demoblaze.com/');
await page.waitForTimeout(2000);
const var1 = await page.$$("#tbodyid .col-lg-4.col-md-6.mb-4");
await var1[0].click();
await page.waitForTimeout(2000);
await page.click("#tbodyid > div.row > div > a");
await page.on('dialog', async dialog => {
await dialog.accept()
});
await page.click("#cartur");
await page.waitForTimeout(2000);
const var2 = await page.$$("table.table #tbodyid tr.success");
await console.log("Number of products should be 1: " + var2.length);
await browser.close();
});
});