| 3448 | } |
| 3449 | |
| 3450 | async function targetCreatedHandler(page) { |
| 3451 | if (!page) return |
| 3452 | this.withinLocator = null |
| 3453 | page.on('load', () => { |
| 3454 | page |
| 3455 | .$('body') |
| 3456 | .catch(() => null) |
| 3457 | .then(context => (this.context = context)) |
| 3458 | }) |
| 3459 | page.on('console', msg => { |
| 3460 | this.debugSection(`Browser:${ucfirst(msg.type())}`, (msg._text || '') + msg.args().join(' ')) |
| 3461 | consoleLogStore.add(msg) |
| 3462 | }) |
| 3463 | |
| 3464 | if (this.options.userAgent) { |
| 3465 | await page.setUserAgent(this.options.userAgent) |
| 3466 | } |
| 3467 | if (this.options.windowSize && this.options.windowSize.indexOf('x') > 0) { |
| 3468 | const dimensions = this.options.windowSize.split('x') |
| 3469 | const width = parseInt(dimensions[0], 10) |
| 3470 | const height = parseInt(dimensions[1], 10) |
| 3471 | await page.setViewport({ width, height }) |
| 3472 | } |
| 3473 | } |
| 3474 | |
| 3475 | // BC compatibility for Puppeteer < 10 |
| 3476 | async function getClickablePoint(el) { |