import{typeLocator,typePage}from"playwright-core";exportasyncfunctionreloadUntilExists(page:Page,locator:Locator,reloadDurationMs=10000,timeoutMs=120000){conststartTime=Date.now();while((awaitlocator.count())===0){constcurrentTime=Date.now();if(currentTime-startTime>=timeoutMs){thrownewError("locator is not exists.");}try{awaitlocator.waitFor({state:"attached",timeout:reloadDurationMs});}catch(e){awaitpage.reload();}}}