(remotePage?: RemotePage)
| 347 | } |
| 348 | |
| 349 | async handleTestDialog(remotePage?: RemotePage) { |
| 350 | const question_box = $el('.ai-test-question-wrapper'); |
| 351 | const done = $el('.ai-test-question-wrapper .done'); |
| 352 | if (question_box) { |
| 353 | $message.info('正在关闭弹窗测验...'); |
| 354 | const close_btn = $el('.close-box', question_box); |
| 355 | if (done) { |
| 356 | if (close_btn) { |
| 357 | if (remotePage) { |
| 358 | await remotePage.click(close_btn); |
| 359 | } else { |
| 360 | close_btn.click(); |
| 361 | } |
| 362 | } |
| 363 | } else { |
| 364 | const options = $$el('.options .option', question_box); |
| 365 | if (options.length !== 0) { |
| 366 | await waitForCaptcha(); |
| 367 | // 最小化脚本窗口 |
| 368 | $render.moveToEdge(); |
| 369 | // 随机选 |
| 370 | const random = Math.floor(Math.random() * options.length); |
| 371 | await $.sleep(1000); |
| 372 | if (remotePage) { |
| 373 | await remotePage.click(options[random]); |
| 374 | } else { |
| 375 | options[random].click(); |
| 376 | } |
| 377 | |
| 378 | await $.sleep(1000); |
| 379 | } |
| 380 | await $.sleep(1000); |
| 381 | const submit_btn = $el('.submit-btn .submits'); |
| 382 | if (submit_btn) { |
| 383 | if (remotePage) { |
| 384 | await remotePage.click(submit_btn); |
| 385 | } else { |
| 386 | submit_btn.click(); |
| 387 | } |
| 388 | } |
| 389 | await $.sleep(1000); |
| 390 | |
| 391 | if (close_btn) { |
| 392 | if (remotePage) { |
| 393 | await remotePage.click(close_btn); |
| 394 | } else { |
| 395 | close_btn.click(); |
| 396 | } |
| 397 | } |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | /** |
| 402 | * 每过三秒递归检测是否有弹窗 |
| 403 | */ |
| 404 | await $.sleep(3000); |
| 405 | await this.handleTestDialog(remotePage); |
| 406 | } |
nothing calls this directly
no test coverage detected