@@ -23,10 +23,6 @@ import { delay, serializeLog } from './util';
23
23
24
24
const DEFAULT_TIMEOUT = 20000 ;
25
25
26
- interface XHRLogger {
27
- logs : ( ) => string ;
28
- }
29
-
30
26
export class ElementSession {
31
27
readonly consoleLog : LogBuffer < puppeteer . ConsoleMessage > ;
32
28
readonly networkLog : LogBuffer < puppeteer . HTTPRequest > ;
@@ -80,10 +76,6 @@ export class ElementSession {
80
76
return this . getElementProperty ( field , 'innerText' ) ;
81
77
}
82
78
83
- public getOuterHTML ( field : puppeteer . ElementHandle ) : Promise < string > {
84
- return this . getElementProperty ( field , 'outerHTML' ) ;
85
- }
86
-
87
79
public isChecked ( field : puppeteer . ElementHandle ) : Promise < string > {
88
80
return this . getElementProperty ( field , 'checked' ) ;
89
81
}
@@ -96,29 +88,6 @@ export class ElementSession {
96
88
return this . networkLog . buffer ;
97
89
}
98
90
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
-
122
91
public async replaceInputText ( input : puppeteer . ElementHandle , text : string ) : Promise < void > {
123
92
// click 3 times to select all text
124
93
await input . click ( { clickCount : 3 } ) ;
@@ -149,45 +118,6 @@ export class ElementSession {
149
118
return await this . page . $$ ( selector ) ;
150
119
}
151
120
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
-
191
121
/** wait for a /sync request started after this call that gets a 200 response */
192
122
public async waitForNextSuccessfulSync ( ) : Promise < void > {
193
123
const syncUrls = [ ] ;
0 commit comments