import { StatusBar , WebElement , Workbench } from "vscode-extension-tester" ; import { delay } from "../helper" ; export class StatusPageObject { private workbench : Workbench ; constructor ( workbench ) { this . workbench = workbench ; } get statusBar ( ) : StatusBar { return this . workbench . getStatusBar ( ) ; } async statusBarWithText ( targetText , _wait = 1000 ) { const target = new RegExp ( targetText , "i" ) ; let steps = _wait / 500 ; let result = null ; while ( result === null && steps > 0 ) { const statusItems = await this . statusBar . getItems ( ) ; await delay ( 500 ) ; statusItems . forEach ( async ( element ) => { if ( ! result ) { const text = await element . getText ( ) ; if ( target . exec ( text ) ) { result = element ; } } } ) ; steps -- ; } return result ; } }