-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscale.js
102 lines (79 loc) · 2.26 KB
/
scale.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
const puppeteer = require('puppeteer');
const args = process.argv;
const env = args[2] || "local";
let webUrl = env === "local" ? 'http://localhost:9001/scale.html' : env;
(async () => {
const browser = await puppeteer.launch({
args: ['--use-fake-ui-for-media-stream'],
//dumpio: true
});
const page = await browser.newPage();
await page.evaluateOnNewDocument(function () {
navigator.geolocation.getCurrentPosition = function (cb) {
setTimeout(() => {
cb({
'coords': {
accuracy: 21,
altitude: null,
altitudeAccuracy: null,
heading: null,
latitude: 23.129163,
longitude: 113.264435,
speed: null
}
})
}, 1000)
}
});
await page.goto(webUrl);
const btn = await page.$('#open-or-join');
await btn.click();
await page.waitFor(300000)
await page.screenshot({path: 'example.png'});
await browser.close();
})();
/*
const { Cluster } = require('puppeteer-cluster');
(async () => {
const cluster = await Cluster.launch({
concurrency: Cluster.CONCURRENCY_CONTEXT,
maxConcurrency: 20,
puppeteerOptions: {
args: [ '--use-fake-ui-for-media-stream' ],
dumpio: true
}
});
await cluster.task(async ({ page, data: url }) => {
await page.evaluateOnNewDocument(function() {
navigator.geolocation.getCurrentPosition = function (cb) {
setTimeout(() => {
cb({
'coords': {
accuracy: 21,
altitude: null,
altitudeAccuracy: null,
heading: null,
latitude: 23.129163,
longitude: 113.264435,
speed: null
}
})
}, 1000)
}
});
await page.goto(url);
const btn = await page.$('#open-or-join');
await btn.click();
await page.waitFor(500000)
await page.screenshot({path: 'example.png'});
});
const url = webUrl;
while(browsers-- >0) {
cluster.queue(url);
}
await cluster.idle();
await cluster.close();
})();
/**
KITE, testRTC, Jattack, WebdriverIO, Pion, webdriverrtc, cypher, pupeteer, pupeteer cluster
**/