File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ class Playwright extends BrowserInterface {
2525 private browserName : string
2626
2727 async setup ( browserName : string ) {
28+ if ( browser ) return
2829 this . browserName = browserName
2930 const headless = ! ! process . env . HEADLESS
3031
@@ -35,18 +36,18 @@ class Playwright extends BrowserInterface {
3536 } else {
3637 browser = await chromium . launch ( { headless, devtools : ! headless } )
3738 }
39+ context = await browser . newContext ( )
3840 }
3941
4042 async get ( url : string ) : Promise < void > {
4143 return page . goto ( url ) as any
4244 }
4345
4446 async loadPage ( url : string ) {
45- if ( context ) {
46- await context . close ( )
47- context = undefined
47+ // clean-up existing pages
48+ for ( const oldPage of context . pages ( ) ) {
49+ await oldPage . close ( )
4850 }
49- context = await browser . newContext ( )
5051 page = await context . newPage ( )
5152 pageLogs = [ ]
5253
You can’t perform that action at this time.
0 commit comments