@@ -23,10 +23,6 @@ import { delay, serializeLog } from './util';
2323
2424const DEFAULT_TIMEOUT = 20000 ;
2525
26- interface XHRLogger {
27- logs : ( ) => string ;
28- }
29-
3026export class ElementSession {
3127 readonly consoleLog : LogBuffer < puppeteer . ConsoleMessage > ;
3228 readonly networkLog : LogBuffer < puppeteer . HTTPRequest > ;
@@ -80,10 +76,6 @@ export class ElementSession {
8076 return this . getElementProperty ( field , 'innerText' ) ;
8177 }
8278
83- public getOuterHTML ( field : puppeteer . ElementHandle ) : Promise < string > {
84- return this . getElementProperty ( field , 'outerHTML' ) ;
85- }
86-
8779 public isChecked ( field : puppeteer . ElementHandle ) : Promise < string > {
8880 return this . getElementProperty ( field , 'checked' ) ;
8981 }
@@ -96,29 +88,6 @@ export class ElementSession {
9688 return this . networkLog . buffer ;
9789 }
9890
99- public logXHRRequests ( ) : XHRLogger {
100- let buffer = "" ;
101- this . page . on ( 'requestfinished' , async ( req ) => {
102- const type = req . resourceType ( ) ;
103- const response = await req . response ( ) ;
104- //if (type === 'xhr' || type === 'fetch') {
105- buffer += `${ type } ${ response . status ( ) } ${ req . method ( ) } ${ req . url ( ) } \n` ;
106- // if (req.method() === "POST") {
107- // buffer += " Post data: " + req.postData();
108- // }
109- //}
110- } ) ;
111- return {
112- logs ( ) {
113- return buffer ;
114- } ,
115- } ;
116- }
117-
118- public async printElements ( label : string , elements : puppeteer . ElementHandle [ ] ) : Promise < void > {
119- console . log ( label , await Promise . all ( elements . map ( this . getOuterHTML ) ) ) ;
120- }
121-
12291 public async replaceInputText ( input : puppeteer . ElementHandle , text : string ) : Promise < void > {
12392 // click 3 times to select all text
12493 await input . click ( { clickCount : 3 } ) ;
@@ -149,45 +118,6 @@ export class ElementSession {
149118 return await this . page . $$ ( selector ) ;
150119 }
151120
152- public waitForReload ( ) : Promise < void > {
153- const timeout = DEFAULT_TIMEOUT ;
154- return new Promise ( ( resolve , reject ) => {
155- const timeoutHandle = setTimeout ( ( ) => {
156- this . page . off ( 'domcontentloaded' , callback ) ;
157- reject ( new Error ( `timeout of ${ timeout } ms for waitForReload elapsed` ) ) ;
158- } , timeout ) ;
159-
160- const callback = async ( ) => {
161- clearTimeout ( timeoutHandle ) ;
162- resolve ( ) ;
163- } ;
164-
165- this . page . once ( 'domcontentloaded' , callback ) ;
166- } ) ;
167- }
168-
169- public waitForNewPage ( ) : Promise < void > {
170- const timeout = DEFAULT_TIMEOUT ;
171- return new Promise ( ( resolve , reject ) => {
172- const timeoutHandle = setTimeout ( ( ) => {
173- this . browser . off ( 'targetcreated' , callback ) ;
174- reject ( new Error ( `timeout of ${ timeout } ms for waitForNewPage elapsed` ) ) ;
175- } , timeout ) ;
176-
177- const callback = async ( target ) => {
178- if ( target . type ( ) !== 'page' ) {
179- return ;
180- }
181- this . browser . off ( 'targetcreated' , callback ) ;
182- clearTimeout ( timeoutHandle ) ;
183- const page = await target . page ( ) ;
184- resolve ( page ) ;
185- } ;
186-
187- this . browser . on ( 'targetcreated' , callback ) ;
188- } ) ;
189- }
190-
191121 /** wait for a /sync request started after this call that gets a 200 response */
192122 public async waitForNextSuccessfulSync ( ) : Promise < void > {
193123 const syncUrls = [ ] ;
0 commit comments