import { By , WebElement , WebView } from "vscode-extension-tester" ; import { delay } from "../helper" ; export class AbstractPageObject { private _webView : WebView ; public get webView ( ) : WebView { return this . _webView ; } async beginWebView ( ) { this . _webView = new WebView ( ) ; await this . webView . wait ( ) ; await this . webView . switchToFrame ( ) ; await delay ( 2000 ) ; } async endWebView ( ) { this . webView . switchBack ( ) ; await delay ( 2000 ) ; this . _webView = null ; } async findElement ( id ) { return await this . webView . findWebElement ( By . id ( id ) ) ; } async getValue ( elementId ) { const element = await this . findElement ( elementId ) ; return ( await element . getAttribute ( "value" ) ) || ( await element . getText ( ) ) ; } async isValue ( elementId ) { const element = await this . findElement ( elementId ) ; return await element . isSelected ( ) ; } async setValue ( elementId , value ) { const element = await this . findElement ( elementId ) ; if ( typeof value == "string" ) { await element . clear ( ) ; await element . sendKeys ( value ) ; } else { await element . click ( ) ; const check = await element . isSelected ( ) ; if ( check != value ) { await element . click ( ) ; } } } async click ( elementId ) { const element = await this . findElement ( elementId ) ; await element . click ( ) ; await delay ( ) ; } }