* {{> amOnPage }}
(url)
| 741 | * {{> amOnPage }} |
| 742 | */ |
| 743 | async amOnPage(url) { |
| 744 | if (!/^\w+\:\/\//.test(url)) { |
| 745 | url = this.options.url + url |
| 746 | } |
| 747 | |
| 748 | if (this.options.basicAuth && this.isAuthenticated !== true) { |
| 749 | if (url.includes(this.options.url)) { |
| 750 | await this.page.authenticate(this.options.basicAuth) |
| 751 | this.isAuthenticated = true |
| 752 | } |
| 753 | } |
| 754 | |
| 755 | if (this.options.trace) { |
| 756 | const fileName = `${`${store.outputDir}${path.sep}trace${path.sep}${uuidv4()}_${clearString(this.currentRunningTest.title)}`.slice(0, 245)}.json` |
| 757 | const dir = path.dirname(fileName) |
| 758 | if (!fileExists(dir)) fs.mkdirSync(dir) |
| 759 | await this.page.tracing.start({ screenshots: true, path: fileName }) |
| 760 | this.currentRunningTest.artifacts.trace = fileName |
| 761 | } |
| 762 | |
| 763 | try { |
| 764 | await this.page.goto(url, { waitUntil: this.options.waitForNavigation }) |
| 765 | } catch (err) { |
| 766 | // Handle terminal navigation errors that shouldn't be retried |
| 767 | if ( |
| 768 | err.message && |
| 769 | (err.message.includes('ERR_ABORTED') || err.message.includes('frame was detached') || err.message.includes('Target page, context or browser has been closed') || err.message.includes('Navigation timeout')) |
| 770 | ) { |
| 771 | // Mark this as a terminal error to prevent retries |
| 772 | const terminalError = new Error(err.message) |
| 773 | terminalError.isTerminal = true |
| 774 | throw terminalError |
| 775 | } |
| 776 | throw err |
| 777 | } |
| 778 | |
| 779 | const performanceTiming = JSON.parse(await this.page.evaluate(() => JSON.stringify(window.performance.timing))) |
| 780 | |
| 781 | perfTiming = this._extractDataFromPerformanceTiming(performanceTiming, 'responseEnd', 'domInteractive', 'domContentLoadedEventEnd', 'loadEventEnd') |
| 782 | |
| 783 | return this._waitForAction() |
| 784 | } |
| 785 | |
| 786 | /** |
| 787 | * |
no test coverage detected