import { Workbench , EditorView , WebView , By } from 'vscode-extension-tester' ; import { expect } from 'chai' ; describe ( 'Sample WebView Test' , ( ) => { let view ; before ( async function ( ) { this . timeout ( 8000 ) ; await new Workbench ( ) . executeCommand ( 'Webview Test' ) ; await new Promise ( ( res ) => { setTimeout ( res , 500 ) ; } ) ; view = new WebView ( ) ; await view . switchToFrame ( ) ; } ) ; after ( async ( ) => { await view . switchBack ( ) ; await new EditorView ( ) . closeAllEditors ( ) ; } ) ; it ( 'Look for a web element' , async ( ) => { const element = await view . findWebElement ( By . css ( 'h1' ) ) ; expect ( await element . getText ( ) ) . has . string ( 'This is a web view' ) ; } ) ; it ( 'Look for all elements with given locator' , async ( ) => { const elements = await view . findWebElements ( By . css ( 'h1' ) ) ; expect ( elements . length ) . equals ( 1 ) ; } ) ; } ) ;