File tree 1 file changed +5
-4
lines changed
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 {
25
25
private browserName : string
26
26
27
27
async setup ( browserName : string ) {
28
+ if ( browser ) return
28
29
this . browserName = browserName
29
30
const headless = ! ! process . env . HEADLESS
30
31
@@ -35,18 +36,18 @@ class Playwright extends BrowserInterface {
35
36
} else {
36
37
browser = await chromium . launch ( { headless, devtools : ! headless } )
37
38
}
39
+ context = await browser . newContext ( )
38
40
}
39
41
40
42
async get ( url : string ) : Promise < void > {
41
43
return page . goto ( url ) as any
42
44
}
43
45
44
46
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 ( )
48
50
}
49
- context = await browser . newContext ( )
50
51
page = await context . newPage ( )
51
52
pageLogs = [ ]
52
53
You can’t perform that action at this time.
0 commit comments