File tree 4 files changed +31
-0
lines changed
4 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 9
9
Super = require ( 'puppeteer-core/lib/cjs/puppeteer/common/JSHandle' ) . ElementHandle ;
10
10
}
11
11
12
+ Super . prototype . clear = function ( ) {
13
+ return this . click ( { clickCount : 3 } ) . then ( ( ) => this . press ( 'Backspace' ) ) ;
14
+ } ;
15
+
12
16
Super . prototype . clickAndWaitForNavigation = function ( options ?: WaitForOptions ) {
13
17
options = options ?? {
14
18
waitUntil : [
Original file line number Diff line number Diff line change 9
9
Super = require ( 'puppeteer-core/lib/cjs/puppeteer/common/FrameManager' ) . Frame ;
10
10
}
11
11
12
+ Super . prototype . clear = function ( selector : string ) {
13
+ return this . $ ( selector ) . then ( ( element ) => element ?. clear ( ) ) ;
14
+ } ;
15
+
12
16
Super . prototype . clickAndWaitForNavigation = function ( selector : string , options ?: WaitForOptions ) {
13
17
options = options ?? {
14
18
waitUntil : [
Original file line number Diff line number Diff line change @@ -15,6 +15,10 @@ Super.prototype.block = function (predicates: string[]) {
15
15
} ) ;
16
16
} ;
17
17
18
+ Super . prototype . clear = function ( selector : string ) {
19
+ return this . mainFrame ( ) . clear ( selector ) ;
20
+ } ;
21
+
18
22
Super . prototype . clickAndWaitForNavigation = function ( selector : string , options ?: WaitForOptions ) {
19
23
return this . mainFrame ( ) . clickAndWaitForNavigation ( selector , options ) ;
20
24
} ;
Original file line number Diff line number Diff line change @@ -39,6 +39,11 @@ declare module 'puppeteer-core' {
39
39
}
40
40
41
41
interface ElementHandle {
42
+ /**
43
+ * Selects all text in a editable element and clears it.
44
+ */
45
+ clear ( ) : Promise < void > ;
46
+
42
47
/**
43
48
* Clicks an element and waits for navigation to finish.
44
49
*
@@ -140,6 +145,13 @@ declare module 'puppeteer-core' {
140
145
}
141
146
142
147
interface Frame {
148
+ /**
149
+ * Selects all text in a editable element and clears it.
150
+ *
151
+ * @param selector - Selector to query for.
152
+ */
153
+ clear ( selector : string ) : Promise < void > ;
154
+
143
155
/**
144
156
* Clicks an element and waits for navigation to finish.
145
157
*
@@ -289,6 +301,13 @@ declare module 'puppeteer-core' {
289
301
*/
290
302
block ( patterns : string [ ] ) : Promise < void > ;
291
303
304
+ /**
305
+ * Selects all text in a editable element and clears it.
306
+ *
307
+ * @param selector - Selector to query for.
308
+ */
309
+ clear ( selector : string ) : Promise < void > ;
310
+
292
311
/**
293
312
* Clicks an element and waits for navigation to finish.
294
313
*
You can’t perform that action at this time.
0 commit comments