@@ -900,7 +900,7 @@ class Playwright extends Helper {
900900 }
901901
902902 async _evaluateHandeInContext ( ...args ) {
903- const context = await this . _getContext ( )
903+ const context = ( await this . context ) || ( await this . _getContext ( ) )
904904 return context . evaluateHandle ( ...args )
905905 }
906906
@@ -1327,7 +1327,7 @@ class Playwright extends Helper {
13271327 * ```
13281328 */
13291329 async _locateClickable ( locator ) {
1330- const context = await this . _getContext ( )
1330+ const context = ( await this . context ) || ( await this . _getContext ( ) )
13311331 return findClickable . call ( this , context , locator )
13321332 }
13331333
@@ -2478,7 +2478,7 @@ class Playwright extends Helper {
24782478 locator = new Locator ( locator , 'css' )
24792479
24802480 let waiter
2481- const context = await this . _getContext ( )
2481+ const context = ( await this . context ) || ( await this . _getContext ( ) )
24822482 if ( ! locator . isXPath ( ) ) {
24832483 const valueFn = function ( [ locator ] ) {
24842484 return Array . from ( document . querySelectorAll ( locator ) ) . filter ( ( el ) => ! el . disabled ) . length > 0
@@ -2506,7 +2506,7 @@ class Playwright extends Helper {
25062506 locator = new Locator ( locator , 'css' )
25072507
25082508 let waiter
2509- const context = await this . _getContext ( )
2509+ const context = ( await this . context ) || ( await this . _getContext ( ) )
25102510 if ( ! locator . isXPath ( ) ) {
25112511 const valueFn = function ( [ locator ] ) {
25122512 return Array . from ( document . querySelectorAll ( locator ) ) . filter ( ( el ) => el . disabled ) . length > 0
@@ -2534,7 +2534,7 @@ class Playwright extends Helper {
25342534 const locator = new Locator ( field , 'css' )
25352535 const matcher = await this . context
25362536 let waiter
2537- const context = await this . _getContext ( )
2537+ const context = ( await this . context ) || ( await this . _getContext ( ) )
25382538 if ( ! locator . isXPath ( ) ) {
25392539 const valueFn = function ( [ locator , value ] ) {
25402540 return (
@@ -2569,7 +2569,7 @@ class Playwright extends Helper {
25692569 locator = new Locator ( locator , 'css' )
25702570
25712571 let waiter
2572- const context = await this . _getContext ( )
2572+ const context = ( await this . context ) || ( await this . _getContext ( ) )
25732573 if ( locator . isCSS ( ) ) {
25742574 const visibleFn = function ( [ locator , num ] ) {
25752575 const els = document . querySelectorAll ( locator )
@@ -2613,7 +2613,7 @@ class Playwright extends Helper {
26132613 const waitTimeout = sec ? sec * 1000 : this . options . waitForTimeout
26142614 locator = new Locator ( locator , 'css' )
26152615
2616- const context = await this . _getContext ( )
2616+ const context = ( await this . context ) || ( await this . _getContext ( ) )
26172617 try {
26182618 await context . locator ( buildLocatorString ( locator ) ) . first ( ) . waitFor ( { timeout : waitTimeout , state : 'attached' } )
26192619 } catch ( e ) {
@@ -2631,7 +2631,7 @@ class Playwright extends Helper {
26312631 async waitForVisible ( locator , sec ) {
26322632 const waitTimeout = sec ? sec * 1000 : this . options . waitForTimeout
26332633 locator = new Locator ( locator , 'css' )
2634- const context = await this . _getContext ( )
2634+ const context = ( await this . context ) || ( await this . _getContext ( ) )
26352635 let count = 0
26362636
26372637 // we have this as https://github.com/microsoft/playwright/issues/26829 is not yet implemented
@@ -2660,7 +2660,7 @@ class Playwright extends Helper {
26602660 async waitForInvisible ( locator , sec ) {
26612661 const waitTimeout = sec ? sec * 1000 : this . options . waitForTimeout
26622662 locator = new Locator ( locator , 'css' )
2663- const context = await this . _getContext ( )
2663+ const context = ( await this . context ) || ( await this . _getContext ( ) )
26642664 let waiter
26652665 let count = 0
26662666
@@ -2690,7 +2690,7 @@ class Playwright extends Helper {
26902690 async waitToHide ( locator , sec ) {
26912691 const waitTimeout = sec ? sec * 1000 : this . options . waitForTimeout
26922692 locator = new Locator ( locator , 'css' )
2693- const context = await this . _getContext ( )
2693+ const context = ( await this . context ) || ( await this . _getContext ( ) )
26942694 let waiter
26952695 let count = 0
26962696
@@ -2956,7 +2956,7 @@ class Playwright extends Helper {
29562956 }
29572957 }
29582958 const waitTimeout = sec ? sec * 1000 : this . options . waitForTimeout
2959- const context = await this . _getContext ( )
2959+ const context = ( await this . context ) || ( await this . _getContext ( ) )
29602960 return context . waitForFunction ( fn , args , { timeout : waitTimeout } )
29612961 }
29622962
@@ -3010,7 +3010,7 @@ class Playwright extends Helper {
30103010 locator = new Locator ( locator , 'css' )
30113011
30123012 let waiter
3013- const context = await this . _getContext ( )
3013+ const context = ( await this . context ) || ( await this . _getContext ( ) )
30143014 if ( ! locator . isXPath ( ) ) {
30153015 try {
30163016 await context
0 commit comments