-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathOnEventTest.ts
53 lines (48 loc) · 1 KB
/
OnEventTest.ts
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
import {
AddToQueue,
appInfo,
Events,
FromQueue,
Job,
Launcher,
OnEvent,
OnStart,
Page, PromiseUtil,
PuppeteerWorkerFactory
} from "../..";
class TestTask {
@OnStart({urls: "https://www.baidu.com"})
async start(job: Job, page: Page) {
await page.goto(job.url);
page.on("dialog", dialog => {
return dialog.accept();
});
await page.evaluate(() => confirm("test"));
}
@OnEvent(Events.QueueManager_JobExecuted)
async testEvent(info: {
job: Job,
worker: Page,
queues: any
}) {
await info.worker.screenshot({
path: appInfo.workplace + "/test.jpg",
type: "jpeg",
quality: 95,
encoding: "binary"
});
}
}
@Launcher({
workplace: "workplace_onEvent",
tasks: [
TestTask
],
workerFactorys: [
new PuppeteerWorkerFactory({
headless: false
})
],
webUiPort: 9001
})
class App {}