PlayAudit function call is closing the browser/page automatically after first Lighthouse analysis

112 Views Asked by At

We are trying to perform Lighthouse analysis on a web application by using Playwright-lighthouse library as a utility by calling it in multiple stages within a single test.

Sample:

Before all { browser initiation }

test {

goto(url); await playaudit{} locator().click(); await playaudit{}

};

Problem is once the URL is opened and playaudit() function is called, the browser is automatically closing leading to which the locator().click() is throwing Error: locator.click: Target page, context or browser has been closed error.

I'm currently using downgraded version of lightHouse & playwright-lighthouse due to existing import issue in latest versions. "@playwright/test": "^1.35.1", "lighthouse": "^9.6.8", "playwright-lighthouse": "^2.2.2",

Can PlayAudit() be called multiple times within a single test? If not possible by design, are there any workarounds possible ?

Thanks!

Expectation: PlayAudit() function can be called multiple times within a single Playwright test without browser/page getting closed.

0

There are 0 best solutions below