-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
41 lines (37 loc) · 1.2 KB
/
test.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
const { chromium } = require('playwright');
(async () => {
/* comment the row below and de-comment the ones below
to run the test using an existing browser context
*/
let browser = await chromium.launch({headless: false, slowMo: 100});
const context = await browser.newContext({
viewport: {
width: 1280, // 1280 in commit 1ee6578
height: 720, // 720 in commit 1ee6578
}
})
const page = await context.newPage();
await page.goto('http://localhost:3000');
await page.hover('button');
await page.click('[data-testid=facebook]')
browser.close()
// needs a running browser to work
// use --remote-debugging-port=9222
// if using --headless the test will pass, otherwise not
let browserCDP = await chromium.connectOverCDP({
endpointURL: 'http://localhost:9222',
headless: false,
slowMo: 100
});
const contextCDP = await browserCDP.newContext({
viewport: {
width: 1280, // 1280 in commit 1ee6578
height: 720, // 720 in commit 1ee6578
}
})
const pageCDP = await contextCDP.newPage();
await pageCDP.goto('http://localhost:3000');
await pageCDP.hover('button');
await pageCDP.click('[data-testid=facebook]')
browserCDP.close()
})();