isomorfeus-puppetmaster 0.5.2 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (836) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -17
  3. data/lib/isomorfeus/puppetmaster/console_message.rb +18 -18
  4. data/lib/isomorfeus/puppetmaster/cookie.rb +46 -46
  5. data/lib/isomorfeus/puppetmaster/driver/puppeteer.rb +413 -403
  6. data/lib/isomorfeus/puppetmaster/driver/puppeteer_document.rb +953 -953
  7. data/lib/isomorfeus/puppetmaster/driver/puppeteer_node.rb +851 -851
  8. data/lib/isomorfeus/puppetmaster/errors.rb +90 -90
  9. data/lib/isomorfeus/puppetmaster/iframe.rb +16 -16
  10. data/lib/isomorfeus/puppetmaster/node/content_editable.rb +17 -17
  11. data/lib/isomorfeus/puppetmaster/node/input.rb +20 -20
  12. data/lib/isomorfeus/puppetmaster/node/select.rb +35 -35
  13. data/lib/isomorfeus/puppetmaster/node.rb +279 -279
  14. data/lib/isomorfeus/puppetmaster/request.rb +16 -16
  15. data/lib/isomorfeus/puppetmaster/response.rb +25 -25
  16. data/lib/isomorfeus/puppetmaster/self_forwardable.rb +38 -38
  17. data/lib/isomorfeus/puppetmaster/server.rb +1 -1
  18. data/lib/isomorfeus/puppetmaster/version.rb +3 -3
  19. data/lib/isomorfeus/puppetmaster.rb +85 -85
  20. data/lib/isomorfeus-puppetmaster.rb +1 -0
  21. data/node_modules/.bin/extract-zip +12 -12
  22. data/node_modules/.bin/extract-zip.ps1 +28 -28
  23. data/node_modules/.bin/rimraf +12 -12
  24. data/node_modules/.bin/rimraf.ps1 +28 -28
  25. data/node_modules/.package-lock.json +530 -574
  26. data/node_modules/@types/node/LICENSE +21 -21
  27. data/node_modules/@types/node/assert/strict.d.ts +8 -8
  28. data/node_modules/@types/node/assert.d.ts +912 -912
  29. data/node_modules/@types/node/async_hooks.d.ts +497 -497
  30. data/node_modules/@types/node/buffer.d.ts +2142 -2142
  31. data/node_modules/@types/node/child_process.d.ts +1355 -1355
  32. data/node_modules/@types/node/cluster.d.ts +414 -414
  33. data/node_modules/@types/node/console.d.ts +407 -407
  34. data/node_modules/@types/node/constants.d.ts +18 -18
  35. data/node_modules/@types/node/crypto.d.ts +3224 -3224
  36. data/node_modules/@types/node/dgram.d.ts +545 -545
  37. data/node_modules/@types/node/diagnostics_channel.d.ts +128 -128
  38. data/node_modules/@types/node/dns/promises.d.ts +357 -357
  39. data/node_modules/@types/node/dns.d.ts +643 -643
  40. data/node_modules/@types/node/domain.d.ts +169 -169
  41. data/node_modules/@types/node/events.d.ts +623 -623
  42. data/node_modules/@types/node/fs/promises.d.ts +997 -997
  43. data/node_modules/@types/node/fs.d.ts +3723 -3723
  44. data/node_modules/@types/node/globals.d.ts +285 -285
  45. data/node_modules/@types/node/globals.global.d.ts +1 -1
  46. data/node_modules/@types/node/http.d.ts +1358 -1358
  47. data/node_modules/@types/node/http2.d.ts +2100 -2100
  48. data/node_modules/@types/node/https.d.ts +391 -391
  49. data/node_modules/@types/node/index.d.ts +131 -131
  50. data/node_modules/@types/node/inspector.d.ts +2738 -2738
  51. data/node_modules/@types/node/module.d.ts +114 -114
  52. data/node_modules/@types/node/net.d.ts +783 -783
  53. data/node_modules/@types/node/os.d.ts +455 -455
  54. data/node_modules/@types/node/package.json +229 -229
  55. data/node_modules/@types/node/path.d.ts +172 -172
  56. data/node_modules/@types/node/perf_hooks.d.ts +555 -555
  57. data/node_modules/@types/node/process.d.ts +1477 -1477
  58. data/node_modules/@types/node/punycode.d.ts +117 -117
  59. data/node_modules/@types/node/querystring.d.ts +131 -131
  60. data/node_modules/@types/node/readline.d.ts +542 -542
  61. data/node_modules/@types/node/repl.d.ts +424 -424
  62. data/node_modules/@types/node/stream/consumers.d.ts +24 -24
  63. data/node_modules/@types/node/stream/promises.d.ts +42 -42
  64. data/node_modules/@types/node/stream/web.d.ts +6 -6
  65. data/node_modules/@types/node/stream.d.ts +1181 -1181
  66. data/node_modules/@types/node/string_decoder.d.ts +67 -67
  67. data/node_modules/@types/node/timers/promises.d.ts +68 -68
  68. data/node_modules/@types/node/timers.d.ts +94 -94
  69. data/node_modules/@types/node/tls.d.ts +1019 -1019
  70. data/node_modules/@types/node/trace_events.d.ts +161 -161
  71. data/node_modules/@types/node/tty.d.ts +206 -206
  72. data/node_modules/@types/node/url.d.ts +798 -798
  73. data/node_modules/@types/node/util.d.ts +1556 -1556
  74. data/node_modules/@types/node/v8.d.ts +378 -378
  75. data/node_modules/@types/node/vm.d.ts +504 -504
  76. data/node_modules/@types/node/wasi.d.ts +153 -153
  77. data/node_modules/@types/node/worker_threads.d.ts +649 -649
  78. data/node_modules/@types/node/zlib.d.ts +517 -517
  79. data/node_modules/@types/yauzl/LICENSE +21 -21
  80. data/node_modules/@types/yauzl/index.d.ts +98 -98
  81. data/node_modules/@types/yauzl/package.json +26 -26
  82. data/node_modules/agent-base/README.md +145 -145
  83. data/node_modules/agent-base/dist/src/index.d.ts +78 -78
  84. data/node_modules/agent-base/dist/src/index.js +202 -202
  85. data/node_modules/agent-base/dist/src/promisify.d.ts +4 -4
  86. data/node_modules/agent-base/dist/src/promisify.js +17 -17
  87. data/node_modules/agent-base/package.json +64 -64
  88. data/node_modules/agent-base/src/index.ts +345 -345
  89. data/node_modules/agent-base/src/promisify.ts +33 -33
  90. data/node_modules/balanced-match/.github/FUNDING.yml +2 -2
  91. data/node_modules/balanced-match/LICENSE.md +21 -21
  92. data/node_modules/balanced-match/README.md +97 -97
  93. data/node_modules/balanced-match/index.js +62 -62
  94. data/node_modules/balanced-match/package.json +48 -48
  95. data/node_modules/base64-js/LICENSE +21 -21
  96. data/node_modules/base64-js/README.md +34 -34
  97. data/node_modules/base64-js/index.d.ts +3 -3
  98. data/node_modules/base64-js/index.js +150 -150
  99. data/node_modules/base64-js/package.json +47 -47
  100. data/node_modules/bl/.travis.yml +17 -17
  101. data/node_modules/bl/BufferList.js +396 -396
  102. data/node_modules/bl/LICENSE.md +13 -13
  103. data/node_modules/bl/README.md +247 -247
  104. data/node_modules/bl/bl.js +84 -84
  105. data/node_modules/bl/package.json +37 -37
  106. data/node_modules/bl/test/convert.js +21 -21
  107. data/node_modules/bl/test/indexOf.js +492 -492
  108. data/node_modules/bl/test/isBufferList.js +32 -32
  109. data/node_modules/bl/test/test.js +869 -869
  110. data/node_modules/brace-expansion/LICENSE +21 -21
  111. data/node_modules/brace-expansion/README.md +129 -129
  112. data/node_modules/brace-expansion/index.js +201 -201
  113. data/node_modules/brace-expansion/package.json +47 -47
  114. data/node_modules/buffer/AUTHORS.md +70 -70
  115. data/node_modules/buffer/LICENSE +21 -21
  116. data/node_modules/buffer/README.md +410 -410
  117. data/node_modules/buffer/index.d.ts +186 -186
  118. data/node_modules/buffer/index.js +1817 -1817
  119. data/node_modules/buffer/package.json +96 -96
  120. data/node_modules/buffer-crc32/LICENSE +19 -19
  121. data/node_modules/buffer-crc32/README.md +47 -47
  122. data/node_modules/buffer-crc32/index.js +111 -111
  123. data/node_modules/buffer-crc32/package.json +39 -39
  124. data/node_modules/chownr/LICENSE +15 -15
  125. data/node_modules/chownr/README.md +3 -3
  126. data/node_modules/chownr/chownr.js +167 -167
  127. data/node_modules/chownr/package.json +29 -29
  128. data/node_modules/concat-map/.travis.yml +4 -4
  129. data/node_modules/concat-map/LICENSE +18 -18
  130. data/node_modules/concat-map/README.markdown +62 -62
  131. data/node_modules/concat-map/example/map.js +6 -6
  132. data/node_modules/concat-map/index.js +13 -13
  133. data/node_modules/concat-map/package.json +43 -43
  134. data/node_modules/concat-map/test/map.js +39 -39
  135. data/node_modules/debug/LICENSE +19 -19
  136. data/node_modules/debug/README.md +455 -455
  137. data/node_modules/debug/package.json +59 -59
  138. data/node_modules/debug/src/browser.js +269 -269
  139. data/node_modules/debug/src/common.js +274 -261
  140. data/node_modules/debug/src/index.js +10 -10
  141. data/node_modules/debug/src/node.js +263 -263
  142. data/node_modules/devtools-protocol/LICENSE +27 -27
  143. data/node_modules/devtools-protocol/README.md +12 -12
  144. data/node_modules/devtools-protocol/json/browser_protocol.json +20985 -20640
  145. data/node_modules/devtools-protocol/json/js_protocol.json +3531 -3580
  146. data/node_modules/devtools-protocol/package.json +17 -18
  147. data/node_modules/devtools-protocol/pdl/browser_protocol.pdl +9849 -9637
  148. data/node_modules/devtools-protocol/pdl/js_protocol.pdl +1653 -1678
  149. data/node_modules/devtools-protocol/types/protocol-mapping.d.ts +4333 -4321
  150. data/node_modules/devtools-protocol/types/protocol-proxy-api.d.ts +3695 -3683
  151. data/node_modules/devtools-protocol/types/protocol.d.ts +15714 -15538
  152. data/node_modules/end-of-stream/LICENSE +20 -20
  153. data/node_modules/end-of-stream/README.md +54 -54
  154. data/node_modules/end-of-stream/index.js +94 -94
  155. data/node_modules/end-of-stream/package.json +37 -37
  156. data/node_modules/extract-zip/LICENSE +23 -23
  157. data/node_modules/extract-zip/cli.js +19 -19
  158. data/node_modules/extract-zip/index.d.ts +21 -21
  159. data/node_modules/extract-zip/index.js +173 -173
  160. data/node_modules/extract-zip/package.json +80 -80
  161. data/node_modules/extract-zip/readme.md +57 -57
  162. data/node_modules/fd-slicer/.npmignore +2 -2
  163. data/node_modules/fd-slicer/.travis.yml +7 -7
  164. data/node_modules/fd-slicer/CHANGELOG.md +49 -49
  165. data/node_modules/fd-slicer/LICENSE +21 -21
  166. data/node_modules/fd-slicer/README.md +199 -199
  167. data/node_modules/fd-slicer/index.js +296 -296
  168. data/node_modules/fd-slicer/package.json +36 -36
  169. data/node_modules/fd-slicer/test/test.js +350 -350
  170. data/node_modules/find-up/index.d.ts +137 -137
  171. data/node_modules/find-up/index.js +89 -89
  172. data/node_modules/find-up/license +9 -9
  173. data/node_modules/find-up/package.json +53 -53
  174. data/node_modules/find-up/readme.md +156 -156
  175. data/node_modules/fs-constants/LICENSE +21 -21
  176. data/node_modules/fs-constants/README.md +26 -26
  177. data/node_modules/fs-constants/browser.js +1 -1
  178. data/node_modules/fs-constants/index.js +1 -1
  179. data/node_modules/fs-constants/package.json +19 -19
  180. data/node_modules/fs.realpath/LICENSE +43 -43
  181. data/node_modules/fs.realpath/README.md +33 -33
  182. data/node_modules/fs.realpath/index.js +66 -66
  183. data/node_modules/fs.realpath/old.js +303 -303
  184. data/node_modules/fs.realpath/package.json +26 -26
  185. data/node_modules/get-stream/buffer-stream.js +52 -52
  186. data/node_modules/get-stream/index.d.ts +108 -108
  187. data/node_modules/get-stream/index.js +60 -60
  188. data/node_modules/get-stream/license +9 -9
  189. data/node_modules/get-stream/package.json +50 -50
  190. data/node_modules/get-stream/readme.md +124 -124
  191. data/node_modules/glob/LICENSE +21 -21
  192. data/node_modules/glob/README.md +375 -375
  193. data/node_modules/glob/changelog.md +67 -67
  194. data/node_modules/glob/common.js +234 -234
  195. data/node_modules/glob/glob.js +788 -788
  196. data/node_modules/glob/package.json +51 -51
  197. data/node_modules/glob/sync.js +484 -484
  198. data/node_modules/https-proxy-agent/README.md +137 -137
  199. data/node_modules/https-proxy-agent/dist/agent.d.ts +30 -30
  200. data/node_modules/https-proxy-agent/dist/agent.js +179 -179
  201. data/node_modules/https-proxy-agent/dist/index.d.ts +23 -23
  202. data/node_modules/https-proxy-agent/dist/index.js +13 -13
  203. data/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts +7 -7
  204. data/node_modules/https-proxy-agent/dist/parse-proxy-response.js +65 -65
  205. data/node_modules/https-proxy-agent/package.json +56 -56
  206. data/node_modules/ieee754/LICENSE +11 -11
  207. data/node_modules/ieee754/README.md +51 -51
  208. data/node_modules/ieee754/index.d.ts +9 -9
  209. data/node_modules/ieee754/index.js +85 -85
  210. data/node_modules/ieee754/package.json +52 -52
  211. data/node_modules/inflight/LICENSE +15 -15
  212. data/node_modules/inflight/README.md +37 -37
  213. data/node_modules/inflight/inflight.js +54 -54
  214. data/node_modules/inflight/package.json +29 -29
  215. data/node_modules/inherits/LICENSE +16 -16
  216. data/node_modules/inherits/README.md +42 -42
  217. data/node_modules/inherits/inherits.js +9 -9
  218. data/node_modules/inherits/inherits_browser.js +27 -27
  219. data/node_modules/inherits/package.json +29 -29
  220. data/node_modules/locate-path/index.d.ts +83 -83
  221. data/node_modules/locate-path/index.js +65 -65
  222. data/node_modules/locate-path/license +9 -9
  223. data/node_modules/locate-path/package.json +45 -45
  224. data/node_modules/locate-path/readme.md +122 -122
  225. data/node_modules/minimatch/LICENSE +15 -15
  226. data/node_modules/minimatch/README.md +209 -209
  227. data/node_modules/minimatch/minimatch.js +923 -923
  228. data/node_modules/minimatch/package.json +30 -30
  229. data/node_modules/{mkdirp → mkdirp-classic}/LICENSE +21 -21
  230. data/node_modules/mkdirp-classic/README.md +18 -0
  231. data/node_modules/{mkdirp → mkdirp-classic}/index.js +98 -99
  232. data/node_modules/mkdirp-classic/package.json +18 -0
  233. data/node_modules/ms/index.js +162 -162
  234. data/node_modules/ms/license.md +21 -21
  235. data/node_modules/ms/package.json +37 -37
  236. data/node_modules/ms/readme.md +60 -60
  237. data/node_modules/node-fetch/LICENSE.md +22 -22
  238. data/node_modules/node-fetch/README.md +590 -590
  239. data/node_modules/node-fetch/browser.js +24 -24
  240. data/node_modules/node-fetch/lib/index.es.js +1662 -1640
  241. data/node_modules/node-fetch/lib/index.js +1671 -1649
  242. data/node_modules/node-fetch/lib/index.mjs +1660 -1638
  243. data/node_modules/node-fetch/package.json +68 -66
  244. data/node_modules/once/LICENSE +15 -15
  245. data/node_modules/once/README.md +79 -79
  246. data/node_modules/once/once.js +42 -42
  247. data/node_modules/once/package.json +33 -33
  248. data/node_modules/p-limit/index.d.ts +38 -38
  249. data/node_modules/p-limit/index.js +57 -57
  250. data/node_modules/p-limit/license +9 -9
  251. data/node_modules/p-limit/package.json +52 -52
  252. data/node_modules/p-limit/readme.md +101 -101
  253. data/node_modules/p-locate/index.d.ts +64 -64
  254. data/node_modules/p-locate/index.js +52 -52
  255. data/node_modules/p-locate/license +9 -9
  256. data/node_modules/p-locate/package.json +53 -53
  257. data/node_modules/p-locate/readme.md +90 -90
  258. data/node_modules/p-try/index.d.ts +39 -39
  259. data/node_modules/p-try/index.js +9 -9
  260. data/node_modules/p-try/license +9 -9
  261. data/node_modules/p-try/package.json +42 -42
  262. data/node_modules/p-try/readme.md +58 -58
  263. data/node_modules/path-exists/index.d.ts +28 -28
  264. data/node_modules/path-exists/index.js +23 -23
  265. data/node_modules/path-exists/license +9 -9
  266. data/node_modules/path-exists/package.json +39 -39
  267. data/node_modules/path-exists/readme.md +52 -52
  268. data/node_modules/path-is-absolute/index.js +20 -20
  269. data/node_modules/path-is-absolute/license +21 -21
  270. data/node_modules/path-is-absolute/package.json +43 -43
  271. data/node_modules/path-is-absolute/readme.md +59 -59
  272. data/node_modules/pend/LICENSE +23 -23
  273. data/node_modules/pend/README.md +41 -41
  274. data/node_modules/pend/index.js +55 -55
  275. data/node_modules/pend/package.json +18 -18
  276. data/node_modules/pend/test.js +137 -137
  277. data/node_modules/pkg-dir/index.d.ts +44 -44
  278. data/node_modules/pkg-dir/index.js +17 -17
  279. data/node_modules/pkg-dir/license +9 -9
  280. data/node_modules/pkg-dir/package.json +56 -56
  281. data/node_modules/pkg-dir/readme.md +66 -66
  282. data/node_modules/progress/CHANGELOG.md +115 -115
  283. data/node_modules/progress/LICENSE +22 -22
  284. data/node_modules/progress/Makefile +8 -8
  285. data/node_modules/progress/Readme.md +146 -146
  286. data/node_modules/progress/index.js +1 -1
  287. data/node_modules/progress/lib/node-progress.js +236 -235
  288. data/node_modules/progress/package.json +26 -26
  289. data/node_modules/proxy-from-env/.eslintrc +29 -29
  290. data/node_modules/proxy-from-env/.travis.yml +10 -10
  291. data/node_modules/proxy-from-env/LICENSE +20 -20
  292. data/node_modules/proxy-from-env/README.md +131 -131
  293. data/node_modules/proxy-from-env/index.js +108 -108
  294. data/node_modules/proxy-from-env/package.json +34 -34
  295. data/node_modules/proxy-from-env/test.js +483 -483
  296. data/node_modules/pump/.travis.yml +5 -5
  297. data/node_modules/pump/LICENSE +20 -20
  298. data/node_modules/pump/README.md +65 -65
  299. data/node_modules/pump/index.js +82 -82
  300. data/node_modules/pump/package.json +24 -24
  301. data/node_modules/pump/test-browser.js +66 -66
  302. data/node_modules/pump/test-node.js +53 -53
  303. data/node_modules/puppeteer-core/CHANGELOG.md +319 -226
  304. data/node_modules/puppeteer-core/LICENSE +202 -202
  305. data/node_modules/puppeteer-core/README.md +481 -483
  306. data/node_modules/puppeteer-core/cjs-entry-core.js +29 -29
  307. data/node_modules/puppeteer-core/cjs-entry.js +29 -29
  308. data/node_modules/puppeteer-core/install.js +89 -89
  309. data/node_modules/puppeteer-core/lib/cjs/puppeteer/api-docs-entry.d.ts +110 -110
  310. data/node_modules/puppeteer-core/lib/cjs/puppeteer/api-docs-entry.js +80 -80
  311. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Accessibility.d.ts +175 -175
  312. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Accessibility.js +360 -360
  313. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/AriaQueryHandler.d.ts +20 -20
  314. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/AriaQueryHandler.d.ts.map +1 -1
  315. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/AriaQueryHandler.js +84 -84
  316. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/AriaQueryHandler.js.map +1 -1
  317. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Browser.d.ts +455 -437
  318. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Browser.d.ts.map +1 -1
  319. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Browser.js +540 -527
  320. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Browser.js.map +1 -1
  321. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/BrowserConnector.d.ts +53 -53
  322. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/BrowserConnector.js +97 -97
  323. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/BrowserConnector.js.map +1 -1
  324. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/BrowserWebSocketTransport.d.ts +25 -25
  325. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/BrowserWebSocketTransport.js +34 -34
  326. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.d.ts +135 -129
  327. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.d.ts.map +1 -1
  328. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js +298 -280
  329. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js.map +1 -1
  330. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/ConnectionTransport.d.ts +24 -24
  331. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/ConnectionTransport.js +17 -17
  332. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/ConsoleMessage.d.ts +72 -72
  333. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/ConsoleMessage.js +64 -64
  334. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Coverage.d.ts +204 -188
  335. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Coverage.d.ts.map +1 -1
  336. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Coverage.js +335 -328
  337. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Coverage.js.map +1 -1
  338. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/DOMWorld.d.ts +175 -172
  339. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/DOMWorld.d.ts.map +1 -1
  340. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/DOMWorld.js +662 -654
  341. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/DOMWorld.js.map +1 -1
  342. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Debug.d.ts +52 -52
  343. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Debug.js +81 -81
  344. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/DeviceDescriptors.d.ts +40 -40
  345. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/DeviceDescriptors.d.ts.map +1 -1
  346. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/DeviceDescriptors.js +1070 -950
  347. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/DeviceDescriptors.js.map +1 -1
  348. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Dialog.d.ts +74 -74
  349. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Dialog.js +97 -97
  350. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Dialog.js.map +1 -1
  351. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/EmulationManager.d.ts +24 -24
  352. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/EmulationManager.js +37 -37
  353. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Errors.d.ts +50 -41
  354. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Errors.d.ts.map +1 -1
  355. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Errors.js +56 -48
  356. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Errors.js.map +1 -1
  357. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/EvalTypes.d.ts +60 -60
  358. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/EvalTypes.d.ts.map +1 -1
  359. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/EvalTypes.js +17 -17
  360. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/EventEmitter.d.ts +92 -92
  361. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/EventEmitter.js +116 -116
  362. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/EventEmitter.js.map +1 -1
  363. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Events.d.ts +81 -81
  364. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Events.js +86 -86
  365. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/ExecutionContext.d.ts +193 -193
  366. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/ExecutionContext.js +321 -321
  367. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/ExecutionContext.js.map +1 -1
  368. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/FileChooser.d.ts +58 -58
  369. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/FileChooser.js +71 -71
  370. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/FileChooser.js.map +1 -1
  371. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/FrameManager.d.ts +744 -732
  372. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/FrameManager.d.ts.map +1 -1
  373. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/FrameManager.js +1047 -964
  374. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/FrameManager.js.map +1 -1
  375. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/HTTPRequest.d.ts +350 -340
  376. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/HTTPRequest.d.ts.map +1 -1
  377. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/HTTPRequest.js +549 -546
  378. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/HTTPRequest.js.map +1 -1
  379. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/HTTPResponse.d.ts +134 -125
  380. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/HTTPResponse.d.ts.map +1 -1
  381. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/HTTPResponse.js +184 -154
  382. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/HTTPResponse.js.map +1 -1
  383. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Input.d.ts +358 -359
  384. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Input.d.ts.map +1 -1
  385. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Input.js +543 -544
  386. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Input.js.map +1 -1
  387. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/JSHandle.d.ts +490 -468
  388. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/JSHandle.d.ts.map +1 -1
  389. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/JSHandle.js +827 -802
  390. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/JSHandle.js.map +1 -1
  391. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/LifecycleWatcher.d.ts +65 -65
  392. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/LifecycleWatcher.d.ts.map +1 -1
  393. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/LifecycleWatcher.js +149 -148
  394. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/LifecycleWatcher.js.map +1 -1
  395. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/NetworkConditions.d.ts +26 -26
  396. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/NetworkConditions.js +33 -33
  397. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/NetworkManager.d.ts +126 -96
  398. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/NetworkManager.d.ts.map +1 -1
  399. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/NetworkManager.js +467 -340
  400. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/NetworkManager.js.map +1 -1
  401. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/PDFOptions.d.ts +161 -156
  402. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/PDFOptions.d.ts.map +1 -1
  403. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/PDFOptions.js +34 -34
  404. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/PDFOptions.js.map +1 -1
  405. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Page.d.ts +2055 -2010
  406. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Page.d.ts.map +1 -1
  407. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Page.js +2533 -2426
  408. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Page.js.map +1 -1
  409. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Product.d.ts +20 -20
  410. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Product.js +17 -17
  411. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Puppeteer.d.ts +159 -159
  412. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Puppeteer.js +161 -161
  413. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Puppeteer.js.map +1 -1
  414. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/PuppeteerViewport.d.ts +51 -51
  415. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/PuppeteerViewport.js +2 -2
  416. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/QueryHandler.d.ts +64 -64
  417. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/QueryHandler.js +165 -165
  418. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/SecurityDetails.d.ts +60 -60
  419. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/SecurityDetails.js +76 -76
  420. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Target.d.ts +100 -98
  421. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Target.d.ts.map +1 -1
  422. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Target.js +145 -144
  423. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Target.js.map +1 -1
  424. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/TaskQueue.d.ts +21 -0
  425. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/TaskQueue.d.ts.map +1 -0
  426. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/TaskQueue.js +30 -0
  427. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/TaskQueue.js.map +1 -0
  428. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/TimeoutSettings.d.ts +27 -27
  429. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/TimeoutSettings.js +47 -47
  430. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Tracing.d.ts +46 -46
  431. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Tracing.d.ts.map +1 -1
  432. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Tracing.js +109 -103
  433. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Tracing.js.map +1 -1
  434. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/USKeyboardLayout.d.ts +39 -39
  435. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/USKeyboardLayout.js +406 -406
  436. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/WebWorker.d.ts +98 -98
  437. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/WebWorker.js +112 -112
  438. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/assert.d.ts +22 -21
  439. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/assert.d.ts.map +1 -1
  440. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/assert.js +33 -28
  441. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/assert.js.map +1 -1
  442. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/fetch.d.ts +16 -16
  443. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/fetch.js +43 -43
  444. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/helper.d.ts +84 -84
  445. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/helper.js +327 -327
  446. data/node_modules/puppeteer-core/lib/cjs/puppeteer/common/helper.js.map +1 -1
  447. data/node_modules/puppeteer-core/lib/cjs/puppeteer/environment.d.ts +16 -16
  448. data/node_modules/puppeteer-core/lib/cjs/puppeteer/environment.js +19 -19
  449. data/node_modules/puppeteer-core/lib/cjs/puppeteer/global.d.ts +17 -0
  450. data/node_modules/puppeteer-core/lib/cjs/puppeteer/global.d.ts.map +1 -0
  451. data/node_modules/puppeteer-core/lib/cjs/puppeteer/global.js +3 -0
  452. data/node_modules/puppeteer-core/lib/cjs/puppeteer/global.js.map +1 -0
  453. data/node_modules/puppeteer-core/lib/cjs/puppeteer/initialize-node.d.ts +17 -17
  454. data/node_modules/puppeteer-core/lib/cjs/puppeteer/initialize-node.js +44 -44
  455. data/node_modules/puppeteer-core/lib/cjs/puppeteer/initialize-web.d.ts +17 -17
  456. data/node_modules/puppeteer-core/lib/cjs/puppeteer/initialize-web.js +26 -26
  457. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserFetcher.d.ts +133 -133
  458. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserFetcher.d.ts.map +1 -1
  459. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserFetcher.js +500 -501
  460. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserFetcher.js.map +1 -1
  461. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserRunner.d.ts +40 -39
  462. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserRunner.d.ts.map +1 -1
  463. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserRunner.js +256 -224
  464. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserRunner.js.map +1 -1
  465. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/LaunchOptions.d.ts +134 -130
  466. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/LaunchOptions.d.ts.map +1 -1
  467. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/LaunchOptions.js +17 -17
  468. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/Launcher.d.ts +16 -16
  469. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/Launcher.d.ts.map +1 -1
  470. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/Launcher.js +655 -573
  471. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/Launcher.js.map +1 -1
  472. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/NodeWebSocketTransport.d.ts +26 -26
  473. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/NodeWebSocketTransport.d.ts.map +1 -1
  474. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/NodeWebSocketTransport.js +47 -41
  475. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/NodeWebSocketTransport.js.map +1 -1
  476. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/PipeTransport.d.ts +29 -29
  477. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/PipeTransport.js +64 -64
  478. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/Puppeteer.d.ts +153 -153
  479. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/Puppeteer.js +188 -188
  480. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/Puppeteer.js.map +1 -1
  481. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/install.d.ts +17 -17
  482. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/install.d.ts.map +1 -1
  483. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/install.js +173 -159
  484. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node/install.js.map +1 -1
  485. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node-puppeteer-core.d.ts +17 -17
  486. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node-puppeteer-core.js +24 -24
  487. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node-puppeteer-core.js.map +1 -1
  488. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node.d.ts +17 -17
  489. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node.js +23 -23
  490. data/node_modules/puppeteer-core/lib/cjs/puppeteer/node.js.map +1 -1
  491. data/node_modules/puppeteer-core/lib/cjs/puppeteer/revisions.d.ts +21 -21
  492. data/node_modules/puppeteer-core/lib/cjs/puppeteer/revisions.js +22 -22
  493. data/node_modules/puppeteer-core/lib/cjs/puppeteer/web.d.ts +17 -17
  494. data/node_modules/puppeteer-core/lib/cjs/puppeteer/web.js +23 -23
  495. data/node_modules/puppeteer-core/lib/cjs/puppeteer/web.js.map +1 -1
  496. data/node_modules/puppeteer-core/lib/cjs/vendor/mitt/src/index.d.ts +27 -27
  497. data/node_modules/puppeteer-core/lib/cjs/vendor/mitt/src/index.js +56 -56
  498. data/node_modules/puppeteer-core/lib/esm/puppeteer/api-docs-entry.d.ts +110 -110
  499. data/node_modules/puppeteer-core/lib/esm/puppeteer/api-docs-entry.js +80 -80
  500. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Accessibility.d.ts +175 -175
  501. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Accessibility.js +356 -356
  502. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/AriaQueryHandler.d.ts +20 -20
  503. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/AriaQueryHandler.d.ts.map +1 -1
  504. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/AriaQueryHandler.js +81 -81
  505. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/AriaQueryHandler.js.map +1 -1
  506. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Browser.d.ts +455 -437
  507. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Browser.d.ts.map +1 -1
  508. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Browser.js +535 -522
  509. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Browser.js.map +1 -1
  510. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/BrowserConnector.d.ts +53 -53
  511. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/BrowserConnector.js +74 -74
  512. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/BrowserWebSocketTransport.d.ts +25 -25
  513. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/BrowserWebSocketTransport.js +30 -30
  514. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Connection.d.ts +135 -129
  515. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Connection.d.ts.map +1 -1
  516. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Connection.js +293 -275
  517. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Connection.js.map +1 -1
  518. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/ConnectionTransport.d.ts +24 -24
  519. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/ConnectionTransport.js +16 -16
  520. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/ConsoleMessage.d.ts +72 -72
  521. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/ConsoleMessage.js +60 -60
  522. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Coverage.d.ts +204 -188
  523. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Coverage.d.ts.map +1 -1
  524. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Coverage.js +329 -322
  525. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Coverage.js.map +1 -1
  526. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/DOMWorld.d.ts +175 -172
  527. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/DOMWorld.d.ts.map +1 -1
  528. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/DOMWorld.js +657 -649
  529. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/DOMWorld.js.map +1 -1
  530. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Debug.d.ts +52 -52
  531. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Debug.js +77 -77
  532. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/DeviceDescriptors.d.ts +40 -40
  533. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/DeviceDescriptors.d.ts.map +1 -1
  534. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/DeviceDescriptors.js +1067 -947
  535. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/DeviceDescriptors.js.map +1 -1
  536. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Dialog.d.ts +74 -74
  537. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Dialog.js +93 -93
  538. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/EmulationManager.d.ts +24 -24
  539. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/EmulationManager.js +33 -33
  540. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Errors.d.ts +50 -41
  541. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Errors.d.ts.map +1 -1
  542. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Errors.js +50 -43
  543. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Errors.js.map +1 -1
  544. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/EvalTypes.d.ts +60 -60
  545. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/EvalTypes.d.ts.map +1 -1
  546. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/EvalTypes.js +16 -16
  547. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/EventEmitter.d.ts +92 -92
  548. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/EventEmitter.js +109 -109
  549. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Events.d.ts +81 -81
  550. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Events.js +83 -83
  551. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/ExecutionContext.d.ts +193 -193
  552. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/ExecutionContext.js +317 -317
  553. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/FileChooser.d.ts +58 -58
  554. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/FileChooser.js +67 -67
  555. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/FrameManager.d.ts +744 -732
  556. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/FrameManager.d.ts.map +1 -1
  557. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/FrameManager.js +1042 -959
  558. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/FrameManager.js.map +1 -1
  559. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/HTTPRequest.d.ts +350 -340
  560. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/HTTPRequest.d.ts.map +1 -1
  561. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/HTTPRequest.js +545 -542
  562. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/HTTPRequest.js.map +1 -1
  563. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/HTTPResponse.d.ts +134 -125
  564. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/HTTPResponse.d.ts.map +1 -1
  565. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/HTTPResponse.js +180 -150
  566. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/HTTPResponse.js.map +1 -1
  567. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Input.d.ts +358 -359
  568. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Input.d.ts.map +1 -1
  569. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Input.js +537 -538
  570. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Input.js.map +1 -1
  571. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/JSHandle.d.ts +490 -468
  572. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/JSHandle.d.ts.map +1 -1
  573. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/JSHandle.js +802 -777
  574. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/JSHandle.js.map +1 -1
  575. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/LifecycleWatcher.d.ts +65 -65
  576. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/LifecycleWatcher.d.ts.map +1 -1
  577. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/LifecycleWatcher.js +145 -144
  578. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/LifecycleWatcher.js.map +1 -1
  579. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/NetworkConditions.d.ts +26 -26
  580. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/NetworkConditions.js +30 -30
  581. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/NetworkManager.d.ts +126 -96
  582. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/NetworkManager.d.ts.map +1 -1
  583. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/NetworkManager.js +463 -336
  584. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/NetworkManager.js.map +1 -1
  585. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/PDFOptions.d.ts +161 -156
  586. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/PDFOptions.d.ts.map +1 -1
  587. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/PDFOptions.js +31 -31
  588. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/PDFOptions.js.map +1 -1
  589. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Page.d.ts +2055 -2010
  590. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Page.d.ts.map +1 -1
  591. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Page.js +2529 -2422
  592. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Page.js.map +1 -1
  593. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Product.d.ts +20 -20
  594. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Product.js +16 -16
  595. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Puppeteer.d.ts +159 -159
  596. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Puppeteer.js +157 -157
  597. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/PuppeteerViewport.d.ts +51 -51
  598. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/PuppeteerViewport.js +1 -1
  599. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/QueryHandler.d.ts +64 -64
  600. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/QueryHandler.js +157 -157
  601. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/SecurityDetails.d.ts +60 -60
  602. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/SecurityDetails.js +72 -72
  603. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Target.d.ts +100 -98
  604. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Target.d.ts.map +1 -1
  605. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Target.js +141 -140
  606. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Target.js.map +1 -1
  607. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/TaskQueue.d.ts +21 -0
  608. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/TaskQueue.d.ts.map +1 -0
  609. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/TaskQueue.js +26 -0
  610. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/TaskQueue.js.map +1 -0
  611. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/TimeoutSettings.d.ts +27 -27
  612. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/TimeoutSettings.js +43 -43
  613. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Tracing.d.ts +46 -46
  614. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Tracing.d.ts.map +1 -1
  615. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Tracing.js +105 -99
  616. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/Tracing.js.map +1 -1
  617. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/USKeyboardLayout.d.ts +39 -39
  618. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/USKeyboardLayout.js +403 -403
  619. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/WebWorker.d.ts +98 -98
  620. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/WebWorker.js +108 -108
  621. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/assert.d.ts +22 -21
  622. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/assert.d.ts.map +1 -1
  623. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/assert.js +28 -24
  624. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/assert.js.map +1 -1
  625. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/fetch.d.ts +16 -16
  626. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/fetch.js +20 -20
  627. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/helper.d.ts +84 -84
  628. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/helper.js +305 -305
  629. data/node_modules/puppeteer-core/lib/esm/puppeteer/common/helper.js.map +1 -1
  630. data/node_modules/puppeteer-core/lib/esm/puppeteer/environment.d.ts +16 -16
  631. data/node_modules/puppeteer-core/lib/esm/puppeteer/environment.js +16 -16
  632. data/node_modules/puppeteer-core/lib/esm/puppeteer/global.d.ts +17 -0
  633. data/node_modules/puppeteer-core/lib/esm/puppeteer/global.d.ts.map +1 -0
  634. data/node_modules/puppeteer-core/lib/esm/puppeteer/global.js +2 -0
  635. data/node_modules/puppeteer-core/lib/esm/puppeteer/global.js.map +1 -0
  636. data/node_modules/puppeteer-core/lib/esm/puppeteer/initialize-node.d.ts +17 -17
  637. data/node_modules/puppeteer-core/lib/esm/puppeteer/initialize-node.js +37 -37
  638. data/node_modules/puppeteer-core/lib/esm/puppeteer/initialize-web.d.ts +17 -17
  639. data/node_modules/puppeteer-core/lib/esm/puppeteer/initialize-web.js +22 -22
  640. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/BrowserFetcher.d.ts +133 -133
  641. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/BrowserFetcher.d.ts.map +1 -1
  642. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/BrowserFetcher.js +474 -475
  643. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/BrowserFetcher.js.map +1 -1
  644. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/BrowserRunner.d.ts +40 -39
  645. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/BrowserRunner.d.ts.map +1 -1
  646. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/BrowserRunner.js +230 -198
  647. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/BrowserRunner.js.map +1 -1
  648. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/LaunchOptions.d.ts +134 -130
  649. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/LaunchOptions.d.ts.map +1 -1
  650. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/LaunchOptions.js +16 -16
  651. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/Launcher.d.ts +16 -16
  652. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/Launcher.d.ts.map +1 -1
  653. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/Launcher.js +633 -551
  654. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/Launcher.js.map +1 -1
  655. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/NodeWebSocketTransport.d.ts +26 -26
  656. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/NodeWebSocketTransport.d.ts.map +1 -1
  657. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/NodeWebSocketTransport.js +40 -34
  658. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/NodeWebSocketTransport.js.map +1 -1
  659. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/PipeTransport.d.ts +29 -29
  660. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/PipeTransport.js +60 -60
  661. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/Puppeteer.d.ts +153 -153
  662. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/Puppeteer.js +181 -181
  663. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/install.d.ts +17 -17
  664. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/install.d.ts.map +1 -1
  665. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/install.js +165 -151
  666. data/node_modules/puppeteer-core/lib/esm/puppeteer/node/install.js.map +1 -1
  667. data/node_modules/puppeteer-core/lib/esm/puppeteer/node-puppeteer-core.d.ts +17 -17
  668. data/node_modules/puppeteer-core/lib/esm/puppeteer/node-puppeteer-core.js +22 -22
  669. data/node_modules/puppeteer-core/lib/esm/puppeteer/node.d.ts +17 -17
  670. data/node_modules/puppeteer-core/lib/esm/puppeteer/node.js +21 -21
  671. data/node_modules/puppeteer-core/lib/esm/puppeteer/revisions.d.ts +21 -21
  672. data/node_modules/puppeteer-core/lib/esm/puppeteer/revisions.js +19 -19
  673. data/node_modules/puppeteer-core/lib/esm/puppeteer/web.d.ts +17 -17
  674. data/node_modules/puppeteer-core/lib/esm/puppeteer/web.js +21 -21
  675. data/node_modules/puppeteer-core/lib/esm/vendor/mitt/src/index.d.ts +27 -27
  676. data/node_modules/puppeteer-core/lib/esm/vendor/mitt/src/index.js +53 -53
  677. data/node_modules/puppeteer-core/lib/types.d.ts +3965 -3735
  678. data/node_modules/puppeteer-core/package.json +115 -121
  679. data/node_modules/puppeteer-core/typescript-if-required.js +61 -61
  680. data/node_modules/readable-stream/CONTRIBUTING.md +38 -38
  681. data/node_modules/readable-stream/GOVERNANCE.md +136 -136
  682. data/node_modules/readable-stream/LICENSE +47 -47
  683. data/node_modules/readable-stream/README.md +106 -106
  684. data/node_modules/readable-stream/errors-browser.js +127 -127
  685. data/node_modules/readable-stream/errors.js +116 -116
  686. data/node_modules/readable-stream/experimentalWarning.js +17 -17
  687. data/node_modules/readable-stream/lib/_stream_duplex.js +138 -138
  688. data/node_modules/readable-stream/lib/_stream_passthrough.js +38 -38
  689. data/node_modules/readable-stream/lib/_stream_readable.js +1123 -1123
  690. data/node_modules/readable-stream/lib/_stream_transform.js +200 -200
  691. data/node_modules/readable-stream/lib/_stream_writable.js +696 -696
  692. data/node_modules/readable-stream/lib/internal/streams/async_iterator.js +206 -206
  693. data/node_modules/readable-stream/lib/internal/streams/buffer_list.js +209 -209
  694. data/node_modules/readable-stream/lib/internal/streams/destroy.js +104 -104
  695. data/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +103 -103
  696. data/node_modules/readable-stream/lib/internal/streams/from-browser.js +3 -3
  697. data/node_modules/readable-stream/lib/internal/streams/from.js +63 -63
  698. data/node_modules/readable-stream/lib/internal/streams/pipeline.js +96 -96
  699. data/node_modules/readable-stream/lib/internal/streams/state.js +26 -26
  700. data/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -1
  701. data/node_modules/readable-stream/lib/internal/streams/stream.js +1 -1
  702. data/node_modules/readable-stream/package.json +68 -68
  703. data/node_modules/readable-stream/readable-browser.js +9 -9
  704. data/node_modules/readable-stream/readable.js +16 -16
  705. data/node_modules/rimraf/CHANGELOG.md +65 -65
  706. data/node_modules/rimraf/LICENSE +15 -15
  707. data/node_modules/rimraf/README.md +101 -101
  708. data/node_modules/rimraf/bin.js +68 -68
  709. data/node_modules/rimraf/package.json +32 -32
  710. data/node_modules/rimraf/rimraf.js +360 -360
  711. data/node_modules/safe-buffer/LICENSE +21 -21
  712. data/node_modules/safe-buffer/README.md +584 -584
  713. data/node_modules/safe-buffer/index.d.ts +186 -186
  714. data/node_modules/safe-buffer/index.js +65 -65
  715. data/node_modules/safe-buffer/package.json +51 -51
  716. data/node_modules/string_decoder/LICENSE +48 -48
  717. data/node_modules/string_decoder/README.md +47 -47
  718. data/node_modules/string_decoder/lib/string_decoder.js +295 -295
  719. data/node_modules/string_decoder/package.json +34 -34
  720. data/node_modules/tar-fs/.travis.yml +6 -5
  721. data/node_modules/tar-fs/LICENSE +20 -20
  722. data/node_modules/tar-fs/README.md +165 -163
  723. data/node_modules/tar-fs/index.js +351 -348
  724. data/node_modules/tar-fs/package.json +41 -41
  725. data/node_modules/tar-fs/test/fixtures/a/hello.txt +1 -1
  726. data/node_modules/tar-fs/test/fixtures/b/a/test.txt +1 -1
  727. data/node_modules/tar-fs/test/index.js +346 -346
  728. data/node_modules/tar-stream/LICENSE +20 -20
  729. data/node_modules/tar-stream/README.md +168 -168
  730. data/node_modules/tar-stream/extract.js +257 -257
  731. data/node_modules/tar-stream/headers.js +295 -295
  732. data/node_modules/tar-stream/index.js +2 -2
  733. data/node_modules/tar-stream/pack.js +255 -255
  734. data/node_modules/tar-stream/package.json +58 -58
  735. data/node_modules/tar-stream/sandbox.js +11 -11
  736. data/node_modules/through/.travis.yml +5 -5
  737. data/node_modules/through/LICENSE.APACHE2 +15 -15
  738. data/node_modules/through/LICENSE.MIT +24 -24
  739. data/node_modules/through/index.js +108 -108
  740. data/node_modules/through/package.json +36 -36
  741. data/node_modules/through/readme.markdown +64 -64
  742. data/node_modules/through/test/async.js +28 -28
  743. data/node_modules/through/test/auto-destroy.js +30 -30
  744. data/node_modules/through/test/buffering.js +71 -71
  745. data/node_modules/through/test/end.js +45 -45
  746. data/node_modules/through/test/index.js +133 -133
  747. data/node_modules/tr46/.npmignore +4 -0
  748. data/node_modules/tr46/index.js +193 -0
  749. data/node_modules/tr46/lib/.gitkeep +0 -0
  750. data/node_modules/tr46/lib/mappingTable.json +1 -0
  751. data/node_modules/tr46/package.json +31 -0
  752. data/node_modules/unbzip2-stream/LICENSE +24 -24
  753. data/node_modules/unbzip2-stream/README.md +59 -59
  754. data/node_modules/unbzip2-stream/dist/unbzip2-stream.min.js +1 -1
  755. data/node_modules/unbzip2-stream/index.js +93 -92
  756. data/node_modules/unbzip2-stream/lib/bit_iterator.js +39 -39
  757. data/node_modules/unbzip2-stream/lib/bzip2.js +365 -367
  758. data/node_modules/unbzip2-stream/package.json +51 -51
  759. data/node_modules/util-deprecate/History.md +16 -16
  760. data/node_modules/util-deprecate/LICENSE +24 -24
  761. data/node_modules/util-deprecate/README.md +53 -53
  762. data/node_modules/util-deprecate/browser.js +67 -67
  763. data/node_modules/util-deprecate/node.js +6 -6
  764. data/node_modules/util-deprecate/package.json +27 -27
  765. data/node_modules/webidl-conversions/LICENSE.md +12 -0
  766. data/node_modules/webidl-conversions/README.md +53 -0
  767. data/node_modules/webidl-conversions/lib/index.js +189 -0
  768. data/node_modules/webidl-conversions/package.json +23 -0
  769. data/node_modules/whatwg-url/LICENSE.txt +21 -0
  770. data/node_modules/whatwg-url/README.md +67 -0
  771. data/node_modules/whatwg-url/lib/URL-impl.js +200 -0
  772. data/node_modules/whatwg-url/lib/URL.js +196 -0
  773. data/node_modules/whatwg-url/lib/public-api.js +11 -0
  774. data/node_modules/whatwg-url/lib/url-state-machine.js +1297 -0
  775. data/node_modules/whatwg-url/lib/utils.js +20 -0
  776. data/node_modules/whatwg-url/package.json +32 -0
  777. data/node_modules/wrappy/LICENSE +15 -15
  778. data/node_modules/wrappy/README.md +36 -36
  779. data/node_modules/wrappy/package.json +29 -29
  780. data/node_modules/wrappy/wrappy.js +33 -33
  781. data/node_modules/ws/LICENSE +19 -21
  782. data/node_modules/ws/README.md +493 -496
  783. data/node_modules/ws/browser.js +8 -8
  784. data/node_modules/ws/index.js +13 -10
  785. data/node_modules/ws/lib/buffer-util.js +126 -129
  786. data/node_modules/ws/lib/constants.js +12 -10
  787. data/node_modules/ws/lib/event-target.js +266 -184
  788. data/node_modules/ws/lib/extension.js +203 -223
  789. data/node_modules/ws/lib/limiter.js +55 -55
  790. data/node_modules/ws/lib/permessage-deflate.js +511 -517
  791. data/node_modules/ws/lib/receiver.js +612 -507
  792. data/node_modules/ws/lib/sender.js +422 -405
  793. data/node_modules/ws/lib/stream.js +180 -165
  794. data/node_modules/ws/lib/subprotocol.js +62 -0
  795. data/node_modules/ws/lib/validation.js +124 -104
  796. data/node_modules/ws/lib/websocket-server.js +485 -418
  797. data/node_modules/ws/lib/websocket.js +1149 -942
  798. data/node_modules/ws/package.json +61 -56
  799. data/node_modules/ws/wrapper.mjs +8 -0
  800. data/node_modules/yauzl/LICENSE +21 -21
  801. data/node_modules/yauzl/README.md +658 -658
  802. data/node_modules/yauzl/index.js +796 -796
  803. data/node_modules/yauzl/package.json +40 -40
  804. data/package.json +1 -1
  805. metadata +81 -61
  806. data/node_modules/.bin/mkdirp +0 -12
  807. data/node_modules/.bin/mkdirp.cmd +0 -17
  808. data/node_modules/.bin/mkdirp.ps1 +0 -28
  809. data/node_modules/devtools-protocol/changelog.md +0 -10491
  810. data/node_modules/devtools-protocol/externs/protocol_externs.js +0 -9734
  811. data/node_modules/minimist/.travis.yml +0 -8
  812. data/node_modules/minimist/LICENSE +0 -18
  813. data/node_modules/minimist/example/parse.js +0 -2
  814. data/node_modules/minimist/index.js +0 -245
  815. data/node_modules/minimist/package.json +0 -45
  816. data/node_modules/minimist/readme.markdown +0 -95
  817. data/node_modules/minimist/test/all_bool.js +0 -32
  818. data/node_modules/minimist/test/bool.js +0 -178
  819. data/node_modules/minimist/test/dash.js +0 -31
  820. data/node_modules/minimist/test/default_bool.js +0 -35
  821. data/node_modules/minimist/test/dotted.js +0 -22
  822. data/node_modules/minimist/test/kv_short.js +0 -16
  823. data/node_modules/minimist/test/long.js +0 -31
  824. data/node_modules/minimist/test/num.js +0 -36
  825. data/node_modules/minimist/test/parse.js +0 -197
  826. data/node_modules/minimist/test/parse_modified.js +0 -9
  827. data/node_modules/minimist/test/proto.js +0 -44
  828. data/node_modules/minimist/test/short.js +0 -67
  829. data/node_modules/minimist/test/stop_early.js +0 -15
  830. data/node_modules/minimist/test/unknown.js +0 -102
  831. data/node_modules/minimist/test/whitespace.js +0 -8
  832. data/node_modules/mkdirp/bin/cmd.js +0 -33
  833. data/node_modules/mkdirp/bin/usage.txt +0 -12
  834. data/node_modules/mkdirp/package.json +0 -34
  835. data/node_modules/mkdirp/readme.markdown +0 -100
  836. data/node_modules/node-fetch/CHANGELOG.md +0 -272
@@ -1,2011 +1,2056 @@
1
- /**
2
- * Copyright 2017 Google Inc. All rights reserved.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- /// <reference types="node" />
17
- import type { Readable } from 'stream';
18
- import { EventEmitter } from './EventEmitter.js';
19
- import { CDPSession } from './Connection.js';
20
- import { Dialog } from './Dialog.js';
21
- import { Frame } from './FrameManager.js';
22
- import { Keyboard, Mouse, Touchscreen, MouseButton } from './Input.js';
23
- import { Tracing } from './Tracing.js';
24
- import { Coverage } from './Coverage.js';
25
- import { WebWorker } from './WebWorker.js';
26
- import { Browser, BrowserContext } from './Browser.js';
27
- import { Target } from './Target.js';
28
- import { JSHandle, ElementHandle } from './JSHandle.js';
29
- import { Viewport } from './PuppeteerViewport.js';
30
- import { Credentials, NetworkConditions } from './NetworkManager.js';
31
- import { HTTPRequest } from './HTTPRequest.js';
32
- import { HTTPResponse } from './HTTPResponse.js';
33
- import { Accessibility } from './Accessibility.js';
34
- import { FileChooser } from './FileChooser.js';
35
- import { ConsoleMessage } from './ConsoleMessage.js';
36
- import { PuppeteerLifeCycleEvent } from './LifecycleWatcher.js';
37
- import { Protocol } from 'devtools-protocol';
38
- import { SerializableOrJSHandle, EvaluateHandleFn, WrapElementHandle, EvaluateFn, EvaluateFnReturnType, UnwrapPromiseLike } from './EvalTypes.js';
39
- import { PDFOptions } from './PDFOptions.js';
40
- /**
41
- * @public
42
- */
43
- export interface Metrics {
44
- Timestamp?: number;
45
- Documents?: number;
46
- Frames?: number;
47
- JSEventListeners?: number;
48
- Nodes?: number;
49
- LayoutCount?: number;
50
- RecalcStyleCount?: number;
51
- LayoutDuration?: number;
52
- RecalcStyleDuration?: number;
53
- ScriptDuration?: number;
54
- TaskDuration?: number;
55
- JSHeapUsedSize?: number;
56
- JSHeapTotalSize?: number;
57
- }
58
- /**
59
- * @public
60
- */
61
- export interface WaitTimeoutOptions {
62
- /**
63
- * Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to
64
- * disable the timeout.
65
- *
66
- * @remarks
67
- * The default value can be changed by using the
68
- * {@link Page.setDefaultTimeout} method.
69
- */
70
- timeout?: number;
71
- }
72
- /**
73
- * @public
74
- */
75
- export interface WaitForOptions {
76
- /**
77
- * Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to
78
- * disable the timeout.
79
- *
80
- * @remarks
81
- * The default value can be changed by using the
82
- * {@link Page.setDefaultTimeout} or {@link Page.setDefaultNavigationTimeout}
83
- * methods.
84
- */
85
- timeout?: number;
86
- waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[];
87
- }
88
- /**
89
- * @public
90
- */
91
- export interface GeolocationOptions {
92
- /**
93
- * Latitude between -90 and 90.
94
- */
95
- longitude: number;
96
- /**
97
- * Longitude between -180 and 180.
98
- */
99
- latitude: number;
100
- /**
101
- * Optional non-negative accuracy value.
102
- */
103
- accuracy?: number;
104
- }
105
- /**
106
- * @public
107
- */
108
- export interface MediaFeature {
109
- name: string;
110
- value: string;
111
- }
112
- /**
113
- * @public
114
- */
115
- export interface ScreenshotClip {
116
- x: number;
117
- y: number;
118
- width: number;
119
- height: number;
120
- }
121
- /**
122
- * @public
123
- */
124
- export interface ScreenshotOptions {
125
- /**
126
- * @defaultValue 'png'
127
- */
128
- type?: 'png' | 'jpeg';
129
- /**
130
- * The file path to save the image to. The screenshot type will be inferred
131
- * from file extension. If path is a relative path, then it is resolved
132
- * relative to current working directory. If no path is provided, the image
133
- * won't be saved to the disk.
134
- */
135
- path?: string;
136
- /**
137
- * When true, takes a screenshot of the full page.
138
- * @defaultValue false
139
- */
140
- fullPage?: boolean;
141
- /**
142
- * An object which specifies the clipping region of the page.
143
- */
144
- clip?: ScreenshotClip;
145
- /**
146
- * Quality of the image, between 0-100. Not applicable to `png` images.
147
- */
148
- quality?: number;
149
- /**
150
- * Hides default white background and allows capturing screenshots with transparency.
151
- * @defaultValue false
152
- */
153
- omitBackground?: boolean;
154
- /**
155
- * Encoding of the image.
156
- * @defaultValue 'binary'
157
- */
158
- encoding?: 'base64' | 'binary';
159
- /**
160
- * If you need a screenshot bigger than the Viewport
161
- * @defaultValue true
162
- */
163
- captureBeyondViewport?: boolean;
164
- }
165
- /**
166
- * All the events that a page instance may emit.
167
- *
168
- * @public
169
- */
170
- export declare const enum PageEmittedEvents {
171
- /** Emitted when the page closes. */
172
- Close = "close",
173
- /**
174
- * Emitted when JavaScript within the page calls one of console API methods,
175
- * e.g. `console.log` or `console.dir`. Also emitted if the page throws an
176
- * error or a warning.
177
- *
178
- * @remarks
179
- *
180
- * A `console` event provides a {@link ConsoleMessage} representing the
181
- * console message that was logged.
182
- *
183
- * @example
184
- * An example of handling `console` event:
185
- * ```js
186
- * page.on('console', msg => {
187
- * for (let i = 0; i < msg.args().length; ++i)
188
- * console.log(`${i}: ${msg.args()[i]}`);
189
- * });
190
- * page.evaluate(() => console.log('hello', 5, {foo: 'bar'}));
191
- * ```
192
- */
193
- Console = "console",
194
- /**
195
- * Emitted when a JavaScript dialog appears, such as `alert`, `prompt`,
196
- * `confirm` or `beforeunload`. Puppeteer can respond to the dialog via
197
- * {@link Dialog.accept} or {@link Dialog.dismiss}.
198
- */
199
- Dialog = "dialog",
200
- /**
201
- * Emitted when the JavaScript
202
- * {@link https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded | DOMContentLoaded } event is dispatched.
203
- */
204
- DOMContentLoaded = "domcontentloaded",
205
- /**
206
- * Emitted when the page crashes. Will contain an `Error`.
207
- */
208
- Error = "error",
209
- /** Emitted when a frame is attached. Will contain a {@link Frame}. */
210
- FrameAttached = "frameattached",
211
- /** Emitted when a frame is detached. Will contain a {@link Frame}. */
212
- FrameDetached = "framedetached",
213
- /** Emitted when a frame is navigated to a new URL. Will contain a {@link Frame}. */
214
- FrameNavigated = "framenavigated",
215
- /**
216
- * Emitted when the JavaScript
217
- * {@link https://developer.mozilla.org/en-US/docs/Web/Events/load | load}
218
- * event is dispatched.
219
- */
220
- Load = "load",
221
- /**
222
- * Emitted when the JavaScript code makes a call to `console.timeStamp`. For
223
- * the list of metrics see {@link Page.metrics | page.metrics}.
224
- *
225
- * @remarks
226
- * Contains an object with two properties:
227
- * - `title`: the title passed to `console.timeStamp`
228
- * - `metrics`: objec containing metrics as key/value pairs. The values will
229
- * be `number`s.
230
- */
231
- Metrics = "metrics",
232
- /**
233
- * Emitted when an uncaught exception happens within the page.
234
- * Contains an `Error`.
235
- */
236
- PageError = "pageerror",
237
- /**
238
- * Emitted when the page opens a new tab or window.
239
- *
240
- * Contains a {@link Page} corresponding to the popup window.
241
- *
242
- * @example
243
- *
244
- * ```js
245
- * const [popup] = await Promise.all([
246
- * new Promise(resolve => page.once('popup', resolve)),
247
- * page.click('a[target=_blank]'),
248
- * ]);
249
- * ```
250
- *
251
- * ```js
252
- * const [popup] = await Promise.all([
253
- * new Promise(resolve => page.once('popup', resolve)),
254
- * page.evaluate(() => window.open('https://example.com')),
255
- * ]);
256
- * ```
257
- */
258
- Popup = "popup",
259
- /**
260
- * Emitted when a page issues a request and contains a {@link HTTPRequest}.
261
- *
262
- * @remarks
263
- * The object is readonly. See {@link Page.setRequestInterception} for intercepting
264
- * and mutating requests.
265
- */
266
- Request = "request",
267
- /**
268
- * Emitted when a request ended up loading from cache. Contains a {@link HTTPRequest}.
269
- *
270
- * @remarks
271
- * For certain requests, might contain undefined.
272
- * {@link https://crbug.com/750469}
273
- */
274
- RequestServedFromCache = "requestservedfromcache",
275
- /**
276
- * Emitted when a request fails, for example by timing out.
277
- *
278
- * Contains a {@link HTTPRequest}.
279
- *
280
- * @remarks
281
- *
282
- * NOTE: HTTP Error responses, such as 404 or 503, are still successful
283
- * responses from HTTP standpoint, so request will complete with
284
- * `requestfinished` event and not with `requestfailed`.
285
- */
286
- RequestFailed = "requestfailed",
287
- /**
288
- * Emitted when a request finishes successfully. Contains a {@link HTTPRequest}.
289
- */
290
- RequestFinished = "requestfinished",
291
- /**
292
- * Emitted when a response is received. Contains a {@link HTTPResponse}.
293
- */
294
- Response = "response",
295
- /**
296
- * Emitted when a dedicated
297
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API | WebWorker}
298
- * is spawned by the page.
299
- */
300
- WorkerCreated = "workercreated",
301
- /**
302
- * Emitted when a dedicated
303
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API | WebWorker}
304
- * is destroyed by the page.
305
- */
306
- WorkerDestroyed = "workerdestroyed"
307
- }
308
- /**
309
- * Denotes the objects received by callback functions for page events.
310
- *
311
- * See {@link PageEmittedEvents} for more detail on the events and when they are
312
- * emitted.
313
- * @public
314
- */
315
- export interface PageEventObject {
316
- close: never;
317
- console: ConsoleMessage;
318
- dialog: Dialog;
319
- domcontentloaded: never;
320
- error: Error;
321
- frameattached: Frame;
322
- framedetached: Frame;
323
- framenavigated: Frame;
324
- load: never;
325
- metrics: {
326
- title: string;
327
- metrics: Metrics;
328
- };
329
- pageerror: Error;
330
- popup: Page;
331
- request: HTTPRequest;
332
- response: HTTPResponse;
333
- requestfailed: HTTPRequest;
334
- requestfinished: HTTPRequest;
335
- requestservedfromcache: HTTPRequest;
336
- workercreated: WebWorker;
337
- workerdestroyed: WebWorker;
338
- }
339
- /**
340
- * Page provides methods to interact with a single tab or
341
- * {@link https://developer.chrome.com/extensions/background_pages | extension background page} in Chromium.
342
- *
343
- * @remarks
344
- *
345
- * One Browser instance might have multiple Page instances.
346
- *
347
- * @example
348
- * This example creates a page, navigates it to a URL, and then * saves a screenshot:
349
- * ```js
350
- * const puppeteer = require('puppeteer');
351
- *
352
- * (async () => {
353
- * const browser = await puppeteer.launch();
354
- * const page = await browser.newPage();
355
- * await page.goto('https://example.com');
356
- * await page.screenshot({path: 'screenshot.png'});
357
- * await browser.close();
358
- * })();
359
- * ```
360
- *
361
- * The Page class extends from Puppeteer's {@link EventEmitter} class and will
362
- * emit various events which are documented in the {@link PageEmittedEvents} enum.
363
- *
364
- * @example
365
- * This example logs a message for a single page `load` event:
366
- * ```js
367
- * page.once('load', () => console.log('Page loaded!'));
368
- * ```
369
- *
370
- * To unsubscribe from events use the `off` method:
371
- *
372
- * ```js
373
- * function logRequest(interceptedRequest) {
374
- * console.log('A request was made:', interceptedRequest.url());
375
- * }
376
- * page.on('request', logRequest);
377
- * // Sometime later...
378
- * page.off('request', logRequest);
379
- * ```
380
- * @public
381
- */
382
- export declare class Page extends EventEmitter {
383
- /**
384
- * @internal
385
- */
386
- static create(client: CDPSession, target: Target, ignoreHTTPSErrors: boolean, defaultViewport: Viewport | null): Promise<Page>;
387
- private _closed;
388
- private _client;
389
- private _target;
390
- private _keyboard;
391
- private _mouse;
392
- private _timeoutSettings;
393
- private _touchscreen;
394
- private _accessibility;
395
- private _frameManager;
396
- private _emulationManager;
397
- private _tracing;
398
- private _pageBindings;
399
- private _coverage;
400
- private _javascriptEnabled;
401
- private _viewport;
402
- private _screenshotTaskQueue;
403
- private _workers;
404
- private _fileChooserInterceptors;
405
- private _disconnectPromise?;
406
- private _userDragInterceptionEnabled;
407
- /**
408
- * @internal
409
- */
410
- constructor(client: CDPSession, target: Target, ignoreHTTPSErrors: boolean);
411
- private _initialize;
412
- private _onFileChooser;
413
- /**
414
- * @returns `true` if drag events are being intercepted, `false` otherwise.
415
- */
416
- isDragInterceptionEnabled(): boolean;
417
- /**
418
- * @returns `true` if the page has JavaScript enabled, `false` otherwise.
419
- */
420
- isJavaScriptEnabled(): boolean;
421
- /**
422
- * Listen to page events.
423
- */
424
- on<K extends keyof PageEventObject>(eventName: K, handler: (event: PageEventObject[K]) => void): EventEmitter;
425
- once<K extends keyof PageEventObject>(eventName: K, handler: (event: PageEventObject[K]) => void): EventEmitter;
426
- /**
427
- * This method is typically coupled with an action that triggers file
428
- * choosing. The following example clicks a button that issues a file chooser
429
- * and then responds with `/tmp/myfile.pdf` as if a user has selected this file.
430
- *
431
- * ```js
432
- * const [fileChooser] = await Promise.all([
433
- * page.waitForFileChooser(),
434
- * page.click('#upload-file-button'),
435
- * // some button that triggers file selection
436
- * ]);
437
- * await fileChooser.accept(['/tmp/myfile.pdf']);
438
- * ```
439
- *
440
- * NOTE: This must be called before the file chooser is launched. It will not
441
- * return a currently active file chooser.
442
- * @param options - Optional waiting parameters
443
- * @returns Resolves after a page requests a file picker.
444
- * @remarks
445
- * NOTE: In non-headless Chromium, this method results in the native file picker
446
- * dialog `not showing up` for the user.
447
- */
448
- waitForFileChooser(options?: WaitTimeoutOptions): Promise<FileChooser>;
449
- /**
450
- * Sets the page's geolocation.
451
- * @remarks
452
- * NOTE: Consider using {@link BrowserContext.overridePermissions} to grant
453
- * permissions for the page to read its geolocation.
454
- * @example
455
- * ```js
456
- * await page.setGeolocation({latitude: 59.95, longitude: 30.31667});
457
- * ```
458
- */
459
- setGeolocation(options: GeolocationOptions): Promise<void>;
460
- /**
461
- * @returns A target this page was created from.
462
- */
463
- target(): Target;
464
- /**
465
- * Get the browser the page belongs to.
466
- */
467
- browser(): Browser;
468
- /**
469
- * Get the browser context that the page belongs to.
470
- */
471
- browserContext(): BrowserContext;
472
- private _onTargetCrashed;
473
- private _onLogEntryAdded;
474
- /**
475
- * @returns The page's main frame.
476
- * @remarks
477
- * Page is guaranteed to have a main frame which persists during navigations.
478
- */
479
- mainFrame(): Frame;
480
- get keyboard(): Keyboard;
481
- get touchscreen(): Touchscreen;
482
- get coverage(): Coverage;
483
- get tracing(): Tracing;
484
- get accessibility(): Accessibility;
485
- /**
486
- * @returns An array of all frames attached to the page.
487
- */
488
- frames(): Frame[];
489
- /**
490
- * @returns all of the dedicated
491
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API |
492
- * WebWorkers}
493
- * associated with the page.
494
- * @remarks
495
- * NOTE: This does not contain ServiceWorkers
496
- */
497
- workers(): WebWorker[];
498
- /**
499
- * @param value - Whether to enable request interception.
500
- *
501
- * @remarks
502
- * Activating request interception enables {@link HTTPRequest.abort},
503
- * {@link HTTPRequest.continue} and {@link HTTPRequest.respond} methods. This
504
- * provides the capability to modify network requests that are made by a page.
505
- *
506
- * Once request interception is enabled, every request will stall unless it's
507
- * continued, responded or aborted; or completed using the browser cache.
508
- *
509
- * @example
510
- * An example of a naïve request interceptor that aborts all image requests:
511
- * ```js
512
- * const puppeteer = require('puppeteer');
513
- * (async () => {
514
- * const browser = await puppeteer.launch();
515
- * const page = await browser.newPage();
516
- * await page.setRequestInterception(true);
517
- * page.on('request', interceptedRequest => {
518
- * if (interceptedRequest.url().endsWith('.png') ||
519
- * interceptedRequest.url().endsWith('.jpg'))
520
- * interceptedRequest.abort();
521
- * else
522
- * interceptedRequest.continue();
523
- * });
524
- * await page.goto('https://example.com');
525
- * await browser.close();
526
- * })();
527
- * ```
528
- * NOTE: Enabling request interception disables page caching.
529
- */
530
- setRequestInterception(value: boolean): Promise<void>;
531
- /**
532
- * @param enabled - Whether to enable drag interception.
533
- *
534
- * @remarks
535
- * Activating drag interception enables the `Input.drag`,
536
- * methods This provides the capability to capture drag events emitted
537
- * on the page, which can then be used to simulate drag-and-drop.
538
- */
539
- setDragInterception(enabled: boolean): Promise<void>;
540
- /**
541
- * @param enabled - When `true`, enables offline mode for the page.
542
- * @remarks
543
- * NOTE: while this method sets the network connection to offline, it does
544
- * not change the parameters used in [page.emulateNetworkConditions(networkConditions)]
545
- * (#pageemulatenetworkconditionsnetworkconditions)
546
- */
547
- setOfflineMode(enabled: boolean): Promise<void>;
548
- /**
549
- * @param networkConditions - Passing `null` disables network condition emulation.
550
- * @example
551
- * ```js
552
- * const puppeteer = require('puppeteer');
553
- * const slow3G = puppeteer.networkConditions['Slow 3G'];
554
- *
555
- * (async () => {
556
- * const browser = await puppeteer.launch();
557
- * const page = await browser.newPage();
558
- * await page.emulateNetworkConditions(slow3G);
559
- * await page.goto('https://www.google.com');
560
- * // other actions...
561
- * await browser.close();
562
- * })();
563
- * ```
564
- * @remarks
565
- * NOTE: This does not affect WebSockets and WebRTC PeerConnections (see
566
- * https://crbug.com/563644). To set the page offline, you can use
567
- * [page.setOfflineMode(enabled)](#pagesetofflinemodeenabled).
568
- */
569
- emulateNetworkConditions(networkConditions: NetworkConditions | null): Promise<void>;
570
- /**
571
- * This setting will change the default maximum navigation time for the
572
- * following methods and related shortcuts:
573
- *
574
- * - {@link Page.goBack | page.goBack(options)}
575
- *
576
- * - {@link Page.goForward | page.goForward(options)}
577
- *
578
- * - {@link Page.goto | page.goto(url,options)}
579
- *
580
- * - {@link Page.reload | page.reload(options)}
581
- *
582
- * - {@link Page.setContent | page.setContent(html,options)}
583
- *
584
- * - {@link Page.waitForNavigation | page.waitForNavigation(options)}
585
- * @param timeout - Maximum navigation time in milliseconds.
586
- */
587
- setDefaultNavigationTimeout(timeout: number): void;
588
- /**
589
- * @param timeout - Maximum time in milliseconds.
590
- */
591
- setDefaultTimeout(timeout: number): void;
592
- /**
593
- * Runs `document.querySelector` within the page. If no element matches the
594
- * selector, the return value resolves to `null`.
595
- *
596
- * @remarks
597
- * Shortcut for {@link Frame.$ | Page.mainFrame().$(selector) }.
598
- *
599
- * @param selector - A `selector` to query page for
600
- * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | selector}
601
- * to query page for.
602
- */
603
- $<T extends Element = Element>(selector: string): Promise<ElementHandle<T> | null>;
604
- /**
605
- * @remarks
606
- *
607
- * The only difference between {@link Page.evaluate | page.evaluate} and
608
- * `page.evaluateHandle` is that `evaluateHandle` will return the value
609
- * wrapped in an in-page object.
610
- *
611
- * If the function passed to `page.evaluteHandle` returns a Promise, the
612
- * function will wait for the promise to resolve and return its value.
613
- *
614
- * You can pass a string instead of a function (although functions are
615
- * recommended as they are easier to debug and use with TypeScript):
616
- *
617
- * @example
618
- * ```
619
- * const aHandle = await page.evaluateHandle('document')
620
- * ```
621
- *
622
- * @example
623
- * {@link JSHandle} instances can be passed as arguments to the `pageFunction`:
624
- * ```
625
- * const aHandle = await page.evaluateHandle(() => document.body);
626
- * const resultHandle = await page.evaluateHandle(body => body.innerHTML, aHandle);
627
- * console.log(await resultHandle.jsonValue());
628
- * await resultHandle.dispose();
629
- * ```
630
- *
631
- * Most of the time this function returns a {@link JSHandle},
632
- * but if `pageFunction` returns a reference to an element,
633
- * you instead get an {@link ElementHandle} back:
634
- *
635
- * @example
636
- * ```
637
- * const button = await page.evaluateHandle(() => document.querySelector('button'));
638
- * // can call `click` because `button` is an `ElementHandle`
639
- * await button.click();
640
- * ```
641
- *
642
- * The TypeScript definitions assume that `evaluateHandle` returns
643
- * a `JSHandle`, but if you know it's going to return an
644
- * `ElementHandle`, pass it as the generic argument:
645
- *
646
- * ```
647
- * const button = await page.evaluateHandle<ElementHandle>(...);
648
- * ```
649
- *
650
- * @param pageFunction - a function that is run within the page
651
- * @param args - arguments to be passed to the pageFunction
652
- */
653
- evaluateHandle<HandlerType extends JSHandle = JSHandle>(pageFunction: EvaluateHandleFn, ...args: SerializableOrJSHandle[]): Promise<HandlerType>;
654
- /**
655
- * This method iterates the JavaScript heap and finds all objects with the
656
- * given prototype.
657
- *
658
- * @remarks
659
- * Shortcut for
660
- * {@link ExecutionContext.queryObjects |
661
- * page.mainFrame().executionContext().queryObjects(prototypeHandle)}.
662
- *
663
- * @example
664
- *
665
- * ```js
666
- * // Create a Map object
667
- * await page.evaluate(() => window.map = new Map());
668
- * // Get a handle to the Map object prototype
669
- * const mapPrototype = await page.evaluateHandle(() => Map.prototype);
670
- * // Query all map instances into an array
671
- * const mapInstances = await page.queryObjects(mapPrototype);
672
- * // Count amount of map objects in heap
673
- * const count = await page.evaluate(maps => maps.length, mapInstances);
674
- * await mapInstances.dispose();
675
- * await mapPrototype.dispose();
676
- * ```
677
- * @param prototypeHandle - a handle to the object prototype.
678
- * @returns Promise which resolves to a handle to an array of objects with
679
- * this prototype.
680
- */
681
- queryObjects(prototypeHandle: JSHandle): Promise<JSHandle>;
682
- /**
683
- * This method runs `document.querySelector` within the page and passes the
684
- * result as the first argument to the `pageFunction`.
685
- *
686
- * @remarks
687
- *
688
- * If no element is found matching `selector`, the method will throw an error.
689
- *
690
- * If `pageFunction` returns a promise `$eval` will wait for the promise to
691
- * resolve and then return its value.
692
- *
693
- * @example
694
- *
695
- * ```
696
- * const searchValue = await page.$eval('#search', el => el.value);
697
- * const preloadHref = await page.$eval('link[rel=preload]', el => el.href);
698
- * const html = await page.$eval('.main-container', el => el.outerHTML);
699
- * ```
700
- *
701
- * If you are using TypeScript, you may have to provide an explicit type to the
702
- * first argument of the `pageFunction`.
703
- * By default it is typed as `Element`, but you may need to provide a more
704
- * specific sub-type:
705
- *
706
- * @example
707
- *
708
- * ```
709
- * // if you don't provide HTMLInputElement here, TS will error
710
- * // as `value` is not on `Element`
711
- * const searchValue = await page.$eval('#search', (el: HTMLInputElement) => el.value);
712
- * ```
713
- *
714
- * The compiler should be able to infer the return type
715
- * from the `pageFunction` you provide. If it is unable to, you can use the generic
716
- * type to tell the compiler what return type you expect from `$eval`:
717
- *
718
- * @example
719
- *
720
- * ```
721
- * // The compiler can infer the return type in this case, but if it can't
722
- * // or if you want to be more explicit, provide it as the generic type.
723
- * const searchValue = await page.$eval<string>(
724
- * '#search', (el: HTMLInputElement) => el.value
725
- * );
726
- * ```
727
- *
728
- * @param selector - the
729
- * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | selector}
730
- * to query for
731
- * @param pageFunction - the function to be evaluated in the page context.
732
- * Will be passed the result of `document.querySelector(selector)` as its
733
- * first argument.
734
- * @param args - any additional arguments to pass through to `pageFunction`.
735
- *
736
- * @returns The result of calling `pageFunction`. If it returns an element it
737
- * is wrapped in an {@link ElementHandle}, else the raw value itself is
738
- * returned.
739
- */
740
- $eval<ReturnType>(selector: string, pageFunction: (element: Element, ...args: unknown[]) => ReturnType | Promise<ReturnType>, ...args: SerializableOrJSHandle[]): Promise<WrapElementHandle<ReturnType>>;
741
- /**
742
- * This method runs `Array.from(document.querySelectorAll(selector))` within
743
- * the page and passes the result as the first argument to the `pageFunction`.
744
- *
745
- * @remarks
746
- *
747
- * If `pageFunction` returns a promise `$$eval` will wait for the promise to
748
- * resolve and then return its value.
749
- *
750
- * @example
751
- *
752
- * ```
753
- * // get the amount of divs on the page
754
- * const divCount = await page.$$eval('div', divs => divs.length);
755
- *
756
- * // get the text content of all the `.options` elements:
757
- * const options = await page.$$eval('div > span.options', options => {
758
- * return options.map(option => option.textContent)
759
- * });
760
- * ```
761
- *
762
- * If you are using TypeScript, you may have to provide an explicit type to the
763
- * first argument of the `pageFunction`.
764
- * By default it is typed as `Element[]`, but you may need to provide a more
765
- * specific sub-type:
766
- *
767
- * @example
768
- *
769
- * ```
770
- * // if you don't provide HTMLInputElement here, TS will error
771
- * // as `value` is not on `Element`
772
- * await page.$$eval('input', (elements: HTMLInputElement[]) => {
773
- * return elements.map(e => e.value);
774
- * });
775
- * ```
776
- *
777
- * The compiler should be able to infer the return type
778
- * from the `pageFunction` you provide. If it is unable to, you can use the generic
779
- * type to tell the compiler what return type you expect from `$$eval`:
780
- *
781
- * @example
782
- *
783
- * ```
784
- * // The compiler can infer the return type in this case, but if it can't
785
- * // or if you want to be more explicit, provide it as the generic type.
786
- * const allInputValues = await page.$$eval<string[]>(
787
- * 'input', (elements: HTMLInputElement[]) => elements.map(e => e.textContent)
788
- * );
789
- * ```
790
- *
791
- * @param selector - the
792
- * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | selector}
793
- * to query for
794
- * @param pageFunction - the function to be evaluated in the page context. Will
795
- * be passed the result of `Array.from(document.querySelectorAll(selector))`
796
- * as its first argument.
797
- * @param args - any additional arguments to pass through to `pageFunction`.
798
- *
799
- * @returns The result of calling `pageFunction`. If it returns an element it
800
- * is wrapped in an {@link ElementHandle}, else the raw value itself is
801
- * returned.
802
- */
803
- $$eval<ReturnType>(selector: string, pageFunction: (elements: Element[], ...args: unknown[]) => ReturnType | Promise<ReturnType>, ...args: SerializableOrJSHandle[]): Promise<WrapElementHandle<ReturnType>>;
804
- /**
805
- * The method runs `document.querySelectorAll` within the page. If no elements
806
- * match the selector, the return value resolves to `[]`.
807
- * @remarks
808
- * Shortcut for {@link Frame.$$ | Page.mainFrame().$$(selector) }.
809
- * @param selector - A `selector` to query page for
810
- */
811
- $$<T extends Element = Element>(selector: string): Promise<Array<ElementHandle<T>>>;
812
- /**
813
- * The method evaluates the XPath expression relative to the page document as
814
- * its context node. If there are no such elements, the method resolves to an
815
- * empty array.
816
- * @remarks
817
- * Shortcut for {@link Frame.$x | Page.mainFrame().$x(expression) }.
818
- * @param expression - Expression to evaluate
819
- */
820
- $x(expression: string): Promise<ElementHandle[]>;
821
- /**
822
- * If no URLs are specified, this method returns cookies for the current page
823
- * URL. If URLs are specified, only cookies for those URLs are returned.
824
- */
825
- cookies(...urls: string[]): Promise<Protocol.Network.Cookie[]>;
826
- deleteCookie(...cookies: Protocol.Network.DeleteCookiesRequest[]): Promise<void>;
827
- /**
828
- * @example
829
- * ```js
830
- * await page.setCookie(cookieObject1, cookieObject2);
831
- * ```
832
- */
833
- setCookie(...cookies: Protocol.Network.CookieParam[]): Promise<void>;
834
- /**
835
- * Adds a `<script>` tag into the page with the desired URL or content.
836
- * @remarks
837
- * Shortcut for {@link Frame.addScriptTag | page.mainFrame().addScriptTag(options) }.
838
- * @returns Promise which resolves to the added tag when the script's onload fires or
839
- * when the script content was injected into frame.
840
- */
841
- addScriptTag(options: {
842
- url?: string;
843
- path?: string;
844
- content?: string;
845
- type?: string;
846
- }): Promise<ElementHandle>;
847
- /**
848
- * Adds a `<link rel="stylesheet">` tag into the page with the desired URL or a
849
- * `<style type="text/css">` tag with the content.
850
- * @returns Promise which resolves to the added tag when the stylesheet's
851
- * onload fires or when the CSS content was injected into frame.
852
- */
853
- addStyleTag(options: {
854
- url?: string;
855
- path?: string;
856
- content?: string;
857
- }): Promise<ElementHandle>;
858
- /**
859
- * The method adds a function called `name` on the page's `window` object. When
860
- * called, the function executes `puppeteerFunction` in node.js and returns a
861
- * `Promise` which resolves to the return value of `puppeteerFunction`.
862
- *
863
- * If the puppeteerFunction returns a `Promise`, it will be awaited.
864
- *
865
- * NOTE: Functions installed via `page.exposeFunction` survive navigations.
866
- * @param name - Name of the function on the window object
867
- * @param puppeteerFunction - Callback function which will be called in
868
- * Puppeteer's context.
869
- * @example
870
- * An example of adding an `md5` function into the page:
871
- * ```js
872
- * const puppeteer = require('puppeteer');
873
- * const crypto = require('crypto');
874
- *
875
- * (async () => {
876
- * const browser = await puppeteer.launch();
877
- * const page = await browser.newPage();
878
- * page.on('console', (msg) => console.log(msg.text()));
879
- * await page.exposeFunction('md5', (text) =>
880
- * crypto.createHash('md5').update(text).digest('hex')
881
- * );
882
- * await page.evaluate(async () => {
883
- * // use window.md5 to compute hashes
884
- * const myString = 'PUPPETEER';
885
- * const myHash = await window.md5(myString);
886
- * console.log(`md5 of ${myString} is ${myHash}`);
887
- * });
888
- * await browser.close();
889
- * })();
890
- * ```
891
- * An example of adding a `window.readfile` function into the page:
892
- * ```js
893
- * const puppeteer = require('puppeteer');
894
- * const fs = require('fs');
895
- *
896
- * (async () => {
897
- * const browser = await puppeteer.launch();
898
- * const page = await browser.newPage();
899
- * page.on('console', (msg) => console.log(msg.text()));
900
- * await page.exposeFunction('readfile', async (filePath) => {
901
- * return new Promise((resolve, reject) => {
902
- * fs.readFile(filePath, 'utf8', (err, text) => {
903
- * if (err) reject(err);
904
- * else resolve(text);
905
- * });
906
- * });
907
- * });
908
- * await page.evaluate(async () => {
909
- * // use window.readfile to read contents of a file
910
- * const content = await window.readfile('/etc/hosts');
911
- * console.log(content);
912
- * });
913
- * await browser.close();
914
- * })();
915
- * ```
916
- */
917
- exposeFunction(name: string, puppeteerFunction: Function): Promise<void>;
918
- /**
919
- * Provide credentials for `HTTP authentication`.
920
- * @remarks To disable authentication, pass `null`.
921
- */
922
- authenticate(credentials: Credentials): Promise<void>;
923
- /**
924
- * The extra HTTP headers will be sent with every request the page initiates.
925
- * NOTE: All HTTP header names are lowercased. (HTTP headers are
926
- * case-insensitive, so this shouldn’t impact your server code.)
927
- * NOTE: page.setExtraHTTPHeaders does not guarantee the order of headers in
928
- * the outgoing requests.
929
- * @param headers - An object containing additional HTTP headers to be sent
930
- * with every request. All header values must be strings.
931
- * @returns
932
- */
933
- setExtraHTTPHeaders(headers: Record<string, string>): Promise<void>;
934
- /**
935
- * @param userAgent - Specific user agent to use in this page
936
- * @param userAgentData - Specific user agent client hint data to use in this
937
- * page
938
- * @returns Promise which resolves when the user agent is set.
939
- */
940
- setUserAgent(userAgent: string, userAgentMetadata?: Protocol.Emulation.UserAgentMetadata): Promise<void>;
941
- /**
942
- * @returns Object containing metrics as key/value pairs.
943
- *
944
- * - `Timestamp` : The timestamp when the metrics sample was taken.
945
- *
946
- * - `Documents` : Number of documents in the page.
947
- *
948
- * - `Frames` : Number of frames in the page.
949
- *
950
- * - `JSEventListeners` : Number of events in the page.
951
- *
952
- * - `Nodes` : Number of DOM nodes in the page.
953
- *
954
- * - `LayoutCount` : Total number of full or partial page layout.
955
- *
956
- * - `RecalcStyleCount` : Total number of page style recalculations.
957
- *
958
- * - `LayoutDuration` : Combined durations of all page layouts.
959
- *
960
- * - `RecalcStyleDuration` : Combined duration of all page style
961
- * recalculations.
962
- *
963
- * - `ScriptDuration` : Combined duration of JavaScript execution.
964
- *
965
- * - `TaskDuration` : Combined duration of all tasks performed by the browser.
966
- *
967
- *
968
- * - `JSHeapUsedSize` : Used JavaScript heap size.
969
- *
970
- * - `JSHeapTotalSize` : Total JavaScript heap size.
971
- * @remarks
972
- * NOTE: All timestamps are in monotonic time: monotonically increasing time
973
- * in seconds since an arbitrary point in the past.
974
- */
975
- metrics(): Promise<Metrics>;
976
- private _emitMetrics;
977
- private _buildMetricsObject;
978
- private _handleException;
979
- private _onConsoleAPI;
980
- private _onBindingCalled;
981
- private _addConsoleMessage;
982
- private _onDialog;
983
- /**
984
- * Resets default white background
985
- */
986
- private _resetDefaultBackgroundColor;
987
- /**
988
- * Hides default white background
989
- */
990
- private _setTransparentBackgroundColor;
991
- /**
992
- *
993
- * @returns
994
- * @remarks Shortcut for
995
- * {@link Frame.url | page.mainFrame().url()}.
996
- */
997
- url(): string;
998
- content(): Promise<string>;
999
- /**
1000
- * @param html - HTML markup to assign to the page.
1001
- * @param options - Parameters that has some properties.
1002
- * @remarks
1003
- * The parameter `options` might have the following options.
1004
- *
1005
- * - `timeout` : Maximum time in milliseconds for resources to load, defaults
1006
- * to 30 seconds, pass `0` to disable timeout. The default value can be
1007
- * changed by using the
1008
- * {@link Page.setDefaultNavigationTimeout |
1009
- * page.setDefaultNavigationTimeout(timeout)}
1010
- * or {@link Page.setDefaultTimeout | page.setDefaultTimeout(timeout)}
1011
- * methods.
1012
- *
1013
- * - `waitUntil`: When to consider setting markup succeeded, defaults to `load`.
1014
- * Given an array of event strings, setting content is considered to be
1015
- * successful after all events have been fired. Events can be either:<br/>
1016
- * - `load` : consider setting content to be finished when the `load` event is
1017
- * fired.<br/>
1018
- * - `domcontentloaded` : consider setting content to be finished when the
1019
- * `DOMContentLoaded` event is fired.<br/>
1020
- * - `networkidle0` : consider setting content to be finished when there are no
1021
- * more than 0 network connections for at least `500` ms.<br/>
1022
- * - `networkidle2` : consider setting content to be finished when there are no
1023
- * more than 2 network connections for at least `500` ms.
1024
- */
1025
- setContent(html: string, options?: WaitForOptions): Promise<void>;
1026
- /**
1027
- * @param url - URL to navigate page to. The URL should include scheme, e.g.
1028
- * `https://`
1029
- * @param options - Navigation Parameter
1030
- * @returns Promise which resolves to the main resource response. In case of
1031
- * multiple redirects, the navigation will resolve with the response of the
1032
- * last redirect.
1033
- * @remarks
1034
- * The argument `options` might have the following properties:
1035
- *
1036
- * - `timeout` : Maximum navigation time in milliseconds, defaults to 30
1037
- * seconds, pass 0 to disable timeout. The default value can be changed by
1038
- * using the
1039
- * {@link Page.setDefaultNavigationTimeout |
1040
- * page.setDefaultNavigationTimeout(timeout)}
1041
- * or {@link Page.setDefaultTimeout | page.setDefaultTimeout(timeout)}
1042
- * methods.
1043
- *
1044
- * - `waitUntil`:When to consider navigation succeeded, defaults to `load`.
1045
- * Given an array of event strings, navigation is considered to be successful
1046
- * after all events have been fired. Events can be either:<br/>
1047
- * - `load` : consider navigation to be finished when the load event is
1048
- * fired.<br/>
1049
- * - `domcontentloaded` : consider navigation to be finished when the
1050
- * DOMContentLoaded event is fired.<br/>
1051
- * - `networkidle0` : consider navigation to be finished when there are no
1052
- * more than 0 network connections for at least `500` ms.<br/>
1053
- * - `networkidle2` : consider navigation to be finished when there are no
1054
- * more than 2 network connections for at least `500` ms.
1055
- *
1056
- * - `referer` : Referer header value. If provided it will take preference
1057
- * over the referer header value set by
1058
- * {@link Page.setExtraHTTPHeaders |page.setExtraHTTPHeaders()}.
1059
- *
1060
- * `page.goto` will throw an error if:
1061
- * - there's an SSL error (e.g. in case of self-signed certificates).
1062
- * - target URL is invalid.
1063
- * - the timeout is exceeded during navigation.
1064
- * - the remote server does not respond or is unreachable.
1065
- * - the main resource failed to load.
1066
- *
1067
- * `page.goto` will not throw an error when any valid HTTP status code is
1068
- * returned by the remote server, including 404 "Not Found" and 500
1069
- * "Internal Server Error". The status code for such responses can be
1070
- * retrieved by calling response.status().
1071
- *
1072
- * NOTE: `page.goto` either throws an error or returns a main resource
1073
- * response. The only exceptions are navigation to about:blank or navigation
1074
- * to the same URL with a different hash, which would succeed and return null.
1075
- *
1076
- * NOTE: Headless mode doesn't support navigation to a PDF document. See the
1077
- * {@link https://bugs.chromium.org/p/chromium/issues/detail?id=761295
1078
- * | upstream issue}.
1079
- *
1080
- * Shortcut for {@link Frame.goto | page.mainFrame().goto(url, options)}.
1081
- */
1082
- goto(url: string, options?: WaitForOptions & {
1083
- referer?: string;
1084
- }): Promise<HTTPResponse>;
1085
- /**
1086
- * @param options - Navigation parameters which might have the following
1087
- * properties:
1088
- * @returns Promise which resolves to the main resource response. In case of
1089
- * multiple redirects, the navigation will resolve with the response of the
1090
- * last redirect.
1091
- * @remarks
1092
- * The argument `options` might have the following properties:
1093
- *
1094
- * - `timeout` : Maximum navigation time in milliseconds, defaults to 30
1095
- * seconds, pass 0 to disable timeout. The default value can be changed by
1096
- * using the
1097
- * {@link Page.setDefaultNavigationTimeout |
1098
- * page.setDefaultNavigationTimeout(timeout)}
1099
- * or {@link Page.setDefaultTimeout | page.setDefaultTimeout(timeout)}
1100
- * methods.
1101
- *
1102
- * - `waitUntil`: When to consider navigation succeeded, defaults to `load`.
1103
- * Given an array of event strings, navigation is considered to be
1104
- * successful after all events have been fired. Events can be either:<br/>
1105
- * - `load` : consider navigation to be finished when the load event is fired.<br/>
1106
- * - `domcontentloaded` : consider navigation to be finished when the
1107
- * DOMContentLoaded event is fired.<br/>
1108
- * - `networkidle0` : consider navigation to be finished when there are no
1109
- * more than 0 network connections for at least `500` ms.<br/>
1110
- * - `networkidle2` : consider navigation to be finished when there are no
1111
- * more than 2 network connections for at least `500` ms.
1112
- */
1113
- reload(options?: WaitForOptions): Promise<HTTPResponse | null>;
1114
- /**
1115
- * This resolves when the page navigates to a new URL or reloads. It is useful
1116
- * when you run code that will indirectly cause the page to navigate. Consider
1117
- * this example:
1118
- * ```js
1119
- * const [response] = await Promise.all([
1120
- * page.waitForNavigation(), // The promise resolves after navigation has finished
1121
- * page.click('a.my-link'), // Clicking the link will indirectly cause a navigation
1122
- * ]);
1123
- * ```
1124
- *
1125
- * @param options - Navigation parameters which might have the following properties:
1126
- * @returns Promise which resolves to the main resource response. In case of
1127
- * multiple redirects, the navigation will resolve with the response of the
1128
- * last redirect. In case of navigation to a different anchor or navigation
1129
- * due to History API usage, the navigation will resolve with `null`.
1130
- * @remarks
1131
- * NOTE: Usage of the
1132
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/History_API | History API}
1133
- * to change the URL is considered a navigation.
1134
- *
1135
- * Shortcut for
1136
- * {@link Frame.waitForNavigation | page.mainFrame().waitForNavigation(options)}.
1137
- */
1138
- waitForNavigation(options?: WaitForOptions): Promise<HTTPResponse | null>;
1139
- private _sessionClosePromise;
1140
- /**
1141
- * @param urlOrPredicate - A URL or predicate to wait for
1142
- * @param options - Optional waiting parameters
1143
- * @returns Promise which resolves to the matched response
1144
- * @example
1145
- * ```js
1146
- * const firstResponse = await page.waitForResponse(
1147
- * 'https://example.com/resource'
1148
- * );
1149
- * const finalResponse = await page.waitForResponse(
1150
- * (response) =>
1151
- * response.url() === 'https://example.com' && response.status() === 200
1152
- * );
1153
- * const finalResponse = await page.waitForResponse(async (response) => {
1154
- * return (await response.text()).includes('<html>');
1155
- * });
1156
- * return finalResponse.ok();
1157
- * ```
1158
- * @remarks
1159
- * Optional Waiting Parameters have:
1160
- *
1161
- * - `timeout`: Maximum wait time in milliseconds, defaults to `30` seconds, pass
1162
- * `0` to disable the timeout. The default value can be changed by using the
1163
- * {@link Page.setDefaultTimeout} method.
1164
- */
1165
- waitForRequest(urlOrPredicate: string | ((req: HTTPRequest) => boolean | Promise<boolean>), options?: {
1166
- timeout?: number;
1167
- }): Promise<HTTPRequest>;
1168
- /**
1169
- * @param urlOrPredicate - A URL or predicate to wait for.
1170
- * @param options - Optional waiting parameters
1171
- * @returns Promise which resolves to the matched response.
1172
- * @example
1173
- * ```js
1174
- * const firstResponse = await page.waitForResponse(
1175
- * 'https://example.com/resource'
1176
- * );
1177
- * const finalResponse = await page.waitForResponse(
1178
- * (response) =>
1179
- * response.url() === 'https://example.com' && response.status() === 200
1180
- * );
1181
- * const finalResponse = await page.waitForResponse(async (response) => {
1182
- * return (await response.text()).includes('<html>');
1183
- * });
1184
- * return finalResponse.ok();
1185
- * ```
1186
- * @remarks
1187
- * Optional Parameter have:
1188
- *
1189
- * - `timeout`: Maximum wait time in milliseconds, defaults to `30` seconds,
1190
- * pass `0` to disable the timeout. The default value can be changed by using
1191
- * the {@link Page.setDefaultTimeout} method.
1192
- */
1193
- waitForResponse(urlOrPredicate: string | ((res: HTTPResponse) => boolean | Promise<boolean>), options?: {
1194
- timeout?: number;
1195
- }): Promise<HTTPResponse>;
1196
- /**
1197
- * This method navigate to the previous page in history.
1198
- * @param options - Navigation parameters
1199
- * @returns Promise which resolves to the main resource response. In case of
1200
- * multiple redirects, the navigation will resolve with the response of the
1201
- * last redirect. If can not go back, resolves to `null`.
1202
- * @remarks
1203
- * The argument `options` might have the following properties:
1204
- *
1205
- * - `timeout` : Maximum navigation time in milliseconds, defaults to 30
1206
- * seconds, pass 0 to disable timeout. The default value can be changed by
1207
- * using the
1208
- * {@link Page.setDefaultNavigationTimeout
1209
- * | page.setDefaultNavigationTimeout(timeout)}
1210
- * or {@link Page.setDefaultTimeout | page.setDefaultTimeout(timeout)}
1211
- * methods.
1212
- *
1213
- * - `waitUntil` : When to consider navigation succeeded, defaults to `load`.
1214
- * Given an array of event strings, navigation is considered to be
1215
- * successful after all events have been fired. Events can be either:<br/>
1216
- * - `load` : consider navigation to be finished when the load event is fired.<br/>
1217
- * - `domcontentloaded` : consider navigation to be finished when the
1218
- * DOMContentLoaded event is fired.<br/>
1219
- * - `networkidle0` : consider navigation to be finished when there are no
1220
- * more than 0 network connections for at least `500` ms.<br/>
1221
- * - `networkidle2` : consider navigation to be finished when there are no
1222
- * more than 2 network connections for at least `500` ms.
1223
- */
1224
- goBack(options?: WaitForOptions): Promise<HTTPResponse | null>;
1225
- /**
1226
- * This method navigate to the next page in history.
1227
- * @param options - Navigation Parameter
1228
- * @returns Promise which resolves to the main resource response. In case of
1229
- * multiple redirects, the navigation will resolve with the response of the
1230
- * last redirect. If can not go forward, resolves to `null`.
1231
- * @remarks
1232
- * The argument `options` might have the following properties:
1233
- *
1234
- * - `timeout` : Maximum navigation time in milliseconds, defaults to 30
1235
- * seconds, pass 0 to disable timeout. The default value can be changed by
1236
- * using the
1237
- * {@link Page.setDefaultNavigationTimeout
1238
- * | page.setDefaultNavigationTimeout(timeout)}
1239
- * or {@link Page.setDefaultTimeout | page.setDefaultTimeout(timeout)}
1240
- * methods.
1241
- *
1242
- * - `waitUntil`: When to consider navigation succeeded, defaults to `load`.
1243
- * Given an array of event strings, navigation is considered to be
1244
- * successful after all events have been fired. Events can be either:<br/>
1245
- * - `load` : consider navigation to be finished when the load event is fired.<br/>
1246
- * - `domcontentloaded` : consider navigation to be finished when the
1247
- * DOMContentLoaded event is fired.<br/>
1248
- * - `networkidle0` : consider navigation to be finished when there are no
1249
- * more than 0 network connections for at least `500` ms.<br/>
1250
- * - `networkidle2` : consider navigation to be finished when there are no
1251
- * more than 2 network connections for at least `500` ms.
1252
- */
1253
- goForward(options?: WaitForOptions): Promise<HTTPResponse | null>;
1254
- private _go;
1255
- /**
1256
- * Brings page to front (activates tab).
1257
- */
1258
- bringToFront(): Promise<void>;
1259
- /**
1260
- * Emulates given device metrics and user agent. This method is a shortcut for
1261
- * calling two methods: {@link Page.setUserAgent} and {@link Page.setViewport}
1262
- * To aid emulation, Puppeteer provides a list of device descriptors that can
1263
- * be obtained via the {@link Puppeteer.devices} `page.emulate` will resize
1264
- * the page. A lot of websites don't expect phones to change size, so you
1265
- * should emulate before navigating to the page.
1266
- * @example
1267
- * ```js
1268
- * const puppeteer = require('puppeteer');
1269
- * const iPhone = puppeteer.devices['iPhone 6'];
1270
- * (async () => {
1271
- * const browser = await puppeteer.launch();
1272
- * const page = await browser.newPage();
1273
- * await page.emulate(iPhone);
1274
- * await page.goto('https://www.google.com');
1275
- * // other actions...
1276
- * await browser.close();
1277
- * })();
1278
- * ```
1279
- * @remarks List of all available devices is available in the source code:
1280
- * {@link https://github.com/puppeteer/puppeteer/blob/main/src/common/DeviceDescriptors.ts | src/common/DeviceDescriptors.ts}.
1281
- */
1282
- emulate(options: {
1283
- viewport: Viewport;
1284
- userAgent: string;
1285
- }): Promise<void>;
1286
- /**
1287
- * @param enabled - Whether or not to enable JavaScript on the page.
1288
- * @returns
1289
- * @remarks
1290
- * NOTE: changing this value won't affect scripts that have already been run.
1291
- * It will take full effect on the next navigation.
1292
- */
1293
- setJavaScriptEnabled(enabled: boolean): Promise<void>;
1294
- /**
1295
- * Toggles bypassing page's Content-Security-Policy.
1296
- * @param enabled - sets bypassing of page's Content-Security-Policy.
1297
- * @remarks
1298
- * NOTE: CSP bypassing happens at the moment of CSP initialization rather than
1299
- * evaluation. Usually, this means that `page.setBypassCSP` should be called
1300
- * before navigating to the domain.
1301
- */
1302
- setBypassCSP(enabled: boolean): Promise<void>;
1303
- /**
1304
- * @param type - Changes the CSS media type of the page. The only allowed
1305
- * values are `screen`, `print` and `null`. Passing `null` disables CSS media
1306
- * emulation.
1307
- * @example
1308
- * ```
1309
- * await page.evaluate(() => matchMedia('screen').matches);
1310
- * // true
1311
- * await page.evaluate(() => matchMedia('print').matches);
1312
- * // false
1313
- *
1314
- * await page.emulateMediaType('print');
1315
- * await page.evaluate(() => matchMedia('screen').matches);
1316
- * // false
1317
- * await page.evaluate(() => matchMedia('print').matches);
1318
- * // → true
1319
- *
1320
- * await page.emulateMediaType(null);
1321
- * await page.evaluate(() => matchMedia('screen').matches);
1322
- * // → true
1323
- * await page.evaluate(() => matchMedia('print').matches);
1324
- * // → false
1325
- * ```
1326
- */
1327
- emulateMediaType(type?: string): Promise<void>;
1328
- emulateCPUThrottling(factor: number | null): Promise<void>;
1329
- /**
1330
- * @param features - `<?Array<Object>>` Given an array of media feature
1331
- * objects, emulates CSS media features on the page. Each media feature object
1332
- * must have the following properties:
1333
- * @example
1334
- * ```js
1335
- * await page.emulateMediaFeatures([
1336
- * { name: 'prefers-color-scheme', value: 'dark' },
1337
- * ]);
1338
- * await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches);
1339
- * // true
1340
- * await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches);
1341
- * // false
1342
- *
1343
- * await page.emulateMediaFeatures([
1344
- * { name: 'prefers-reduced-motion', value: 'reduce' },
1345
- * ]);
1346
- * await page.evaluate(
1347
- * () => matchMedia('(prefers-reduced-motion: reduce)').matches
1348
- * );
1349
- * // → true
1350
- * await page.evaluate(
1351
- * () => matchMedia('(prefers-reduced-motion: no-preference)').matches
1352
- * );
1353
- * // → false
1354
- *
1355
- * await page.emulateMediaFeatures([
1356
- * { name: 'prefers-color-scheme', value: 'dark' },
1357
- * { name: 'prefers-reduced-motion', value: 'reduce' },
1358
- * ]);
1359
- * await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches);
1360
- * // → true
1361
- * await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches);
1362
- * // false
1363
- * await page.evaluate(
1364
- * () => matchMedia('(prefers-reduced-motion: reduce)').matches
1365
- * );
1366
- * // → true
1367
- * await page.evaluate(
1368
- * () => matchMedia('(prefers-reduced-motion: no-preference)').matches
1369
- * );
1370
- * // false
1371
- *
1372
- * await page.emulateMediaFeatures([{ name: 'color-gamut', value: 'p3' }]);
1373
- * await page.evaluate(() => matchMedia('(color-gamut: srgb)').matches);
1374
- * // → true
1375
- * await page.evaluate(() => matchMedia('(color-gamut: p3)').matches);
1376
- * // true
1377
- * await page.evaluate(() => matchMedia('(color-gamut: rec2020)').matches);
1378
- * // → false
1379
- * ```
1380
- */
1381
- emulateMediaFeatures(features?: MediaFeature[]): Promise<void>;
1382
- /**
1383
- * @param timezoneId - Changes the timezone of the page. See
1384
- * {@link https://source.chromium.org/chromium/chromium/deps/icu.git/+/faee8bc70570192d82d2978a71e2a615788597d1:source/data/misc/metaZones.txt | ICU’s metaZones.txt}
1385
- * for a list of supported timezone IDs. Passing
1386
- * `null` disables timezone emulation.
1387
- */
1388
- emulateTimezone(timezoneId?: string): Promise<void>;
1389
- /**
1390
- * Emulates the idle state.
1391
- * If no arguments set, clears idle state emulation.
1392
- *
1393
- * @example
1394
- * ```js
1395
- * // set idle emulation
1396
- * await page.emulateIdleState({isUserActive: true, isScreenUnlocked: false});
1397
- *
1398
- * // do some checks here
1399
- * ...
1400
- *
1401
- * // clear idle emulation
1402
- * await page.emulateIdleState();
1403
- * ```
1404
- *
1405
- * @param overrides - Mock idle state. If not set, clears idle overrides
1406
- */
1407
- emulateIdleState(overrides?: {
1408
- isUserActive: boolean;
1409
- isScreenUnlocked: boolean;
1410
- }): Promise<void>;
1411
- /**
1412
- * Simulates the given vision deficiency on the page.
1413
- *
1414
- * @example
1415
- * ```js
1416
- * const puppeteer = require('puppeteer');
1417
- *
1418
- * (async () => {
1419
- * const browser = await puppeteer.launch();
1420
- * const page = await browser.newPage();
1421
- * await page.goto('https://v8.dev/blog/10-years');
1422
- *
1423
- * await page.emulateVisionDeficiency('achromatopsia');
1424
- * await page.screenshot({ path: 'achromatopsia.png' });
1425
- *
1426
- * await page.emulateVisionDeficiency('deuteranopia');
1427
- * await page.screenshot({ path: 'deuteranopia.png' });
1428
- *
1429
- * await page.emulateVisionDeficiency('blurredVision');
1430
- * await page.screenshot({ path: 'blurred-vision.png' });
1431
- *
1432
- * await browser.close();
1433
- * })();
1434
- * ```
1435
- *
1436
- * @param type - the type of deficiency to simulate, or `'none'` to reset.
1437
- */
1438
- emulateVisionDeficiency(type?: Protocol.Emulation.SetEmulatedVisionDeficiencyRequest['type']): Promise<void>;
1439
- /**
1440
- * `page.setViewport` will resize the page. A lot of websites don't expect
1441
- * phones to change size, so you should set the viewport before navigating to
1442
- * the page.
1443
- *
1444
- * In the case of multiple pages in a single browser, each page can have its
1445
- * own viewport size.
1446
- * @example
1447
- * ```js
1448
- * const page = await browser.newPage();
1449
- * await page.setViewport({
1450
- * width: 640,
1451
- * height: 480,
1452
- * deviceScaleFactor: 1,
1453
- * });
1454
- * await page.goto('https://example.com');
1455
- * ```
1456
- *
1457
- * @param viewport -
1458
- * @remarks
1459
- * Argument viewport have following properties:
1460
- *
1461
- * - `width`: page width in pixels. required
1462
- *
1463
- * - `height`: page height in pixels. required
1464
- *
1465
- * - `deviceScaleFactor`: Specify device scale factor (can be thought of as
1466
- * DPR). Defaults to `1`.
1467
- *
1468
- * - `isMobile`: Whether the meta viewport tag is taken into account. Defaults
1469
- * to `false`.
1470
- *
1471
- * - `hasTouch`: Specifies if viewport supports touch events. Defaults to `false`
1472
- *
1473
- * - `isLandScape`: Specifies if viewport is in landscape mode. Defaults to false.
1474
- *
1475
- * NOTE: in certain cases, setting viewport will reload the page in order to
1476
- * set the isMobile or hasTouch properties.
1477
- */
1478
- setViewport(viewport: Viewport): Promise<void>;
1479
- /**
1480
- * @returns
1481
- *
1482
- * - `width`: page's width in pixels
1483
- *
1484
- * - `height`: page's height in pixels
1485
- *
1486
- * - `deviceScalarFactor`: Specify device scale factor (can be though of as
1487
- * dpr). Defaults to `1`.
1488
- *
1489
- * - `isMobile`: Whether the meta viewport tag is taken into account. Defaults
1490
- * to `false`.
1491
- *
1492
- * - `hasTouch`: Specifies if viewport supports touch events. Defaults to
1493
- * `false`.
1494
- *
1495
- * - `isLandScape`: Specifies if viewport is in landscape mode. Defaults to
1496
- * `false`.
1497
- */
1498
- viewport(): Viewport | null;
1499
- /**
1500
- * @remarks
1501
- *
1502
- * Evaluates a function in the page's context and returns the result.
1503
- *
1504
- * If the function passed to `page.evaluteHandle` returns a Promise, the
1505
- * function will wait for the promise to resolve and return its value.
1506
- *
1507
- * @example
1508
- *
1509
- * ```js
1510
- * const result = await frame.evaluate(() => {
1511
- * return Promise.resolve(8 * 7);
1512
- * });
1513
- * console.log(result); // prints "56"
1514
- * ```
1515
- *
1516
- * You can pass a string instead of a function (although functions are
1517
- * recommended as they are easier to debug and use with TypeScript):
1518
- *
1519
- * @example
1520
- * ```
1521
- * const aHandle = await page.evaluate('1 + 2');
1522
- * ```
1523
- *
1524
- * To get the best TypeScript experience, you should pass in as the
1525
- * generic the type of `pageFunction`:
1526
- *
1527
- * ```
1528
- * const aHandle = await page.evaluate<() => number>(() => 2);
1529
- * ```
1530
- *
1531
- * @example
1532
- *
1533
- * {@link ElementHandle} instances (including {@link JSHandle}s) can be passed
1534
- * as arguments to the `pageFunction`:
1535
- *
1536
- * ```
1537
- * const bodyHandle = await page.$('body');
1538
- * const html = await page.evaluate(body => body.innerHTML, bodyHandle);
1539
- * await bodyHandle.dispose();
1540
- * ```
1541
- *
1542
- * @param pageFunction - a function that is run within the page
1543
- * @param args - arguments to be passed to the pageFunction
1544
- *
1545
- * @returns the return value of `pageFunction`.
1546
- */
1547
- evaluate<T extends EvaluateFn>(pageFunction: T, ...args: SerializableOrJSHandle[]): Promise<UnwrapPromiseLike<EvaluateFnReturnType<T>>>;
1548
- /**
1549
- * Adds a function which would be invoked in one of the following scenarios:
1550
- *
1551
- * - whenever the page is navigated
1552
- *
1553
- * - whenever the child frame is attached or navigated. In this case, the
1554
- * function is invoked in the context of the newly attached frame.
1555
- *
1556
- * The function is invoked after the document was created but before any of
1557
- * its scripts were run. This is useful to amend the JavaScript environment,
1558
- * e.g. to seed `Math.random`.
1559
- * @param pageFunction - Function to be evaluated in browser context
1560
- * @param args - Arguments to pass to `pageFunction`
1561
- * @example
1562
- * An example of overriding the navigator.languages property before the page loads:
1563
- * ```js
1564
- * // preload.js
1565
- *
1566
- * // overwrite the `languages` property to use a custom getter
1567
- * Object.defineProperty(navigator, 'languages', {
1568
- * get: function () {
1569
- * return ['en-US', 'en', 'bn'];
1570
- * },
1571
- * });
1572
- *
1573
- * // In your puppeteer script, assuming the preload.js file is
1574
- * in same folder of our script
1575
- * const preloadFile = fs.readFileSync('./preload.js', 'utf8');
1576
- * await page.evaluateOnNewDocument(preloadFile);
1577
- * ```
1578
- */
1579
- evaluateOnNewDocument(pageFunction: Function | string, ...args: unknown[]): Promise<void>;
1580
- /**
1581
- * Toggles ignoring cache for each request based on the enabled state. By
1582
- * default, caching is enabled.
1583
- * @param enabled - sets the `enabled` state of cache
1584
- */
1585
- setCacheEnabled(enabled?: boolean): Promise<void>;
1586
- /**
1587
- * @remarks
1588
- * Options object which might have the following properties:
1589
- *
1590
- * - `path` : The file path to save the image to. The screenshot type
1591
- * will be inferred from file extension. If `path` is a relative path, then
1592
- * it is resolved relative to
1593
- * {@link https://nodejs.org/api/process.html#process_process_cwd
1594
- * | current working directory}.
1595
- * If no path is provided, the image won't be saved to the disk.
1596
- *
1597
- * - `type` : Specify screenshot type, can be either `jpeg` or `png`.
1598
- * Defaults to 'png'.
1599
- *
1600
- * - `quality` : The quality of the image, between 0-100. Not
1601
- * applicable to `png` images.
1602
- *
1603
- * - `fullPage` : When true, takes a screenshot of the full
1604
- * scrollable page. Defaults to `false`
1605
- *
1606
- * - `clip` : An object which specifies clipping region of the page.
1607
- * Should have the following fields:<br/>
1608
- * - `x` : x-coordinate of top-left corner of clip area.<br/>
1609
- * - `y` : y-coordinate of top-left corner of clip area.<br/>
1610
- * - `width` : width of clipping area.<br/>
1611
- * - `height` : height of clipping area.
1612
- *
1613
- * - `omitBackground` : Hides default white background and allows
1614
- * capturing screenshots with transparency. Defaults to `false`
1615
- *
1616
- * - `encoding` : The encoding of the image, can be either base64 or
1617
- * binary. Defaults to `binary`.
1618
- *
1619
- *
1620
- * NOTE: Screenshots take at least 1/6 second on OS X. See
1621
- * {@link https://crbug.com/741689} for discussion.
1622
- * @returns Promise which resolves to buffer or a base64 string (depending on
1623
- * the value of `encoding`) with captured screenshot.
1624
- */
1625
- screenshot(options?: ScreenshotOptions): Promise<Buffer | string | void>;
1626
- private _screenshotTask;
1627
- /**
1628
- * Generatees a PDF of the page with the `print` CSS media type.
1629
- * @remarks
1630
- *
1631
- * NOTE: PDF generation is only supported in Chrome headless mode.
1632
- *
1633
- * To generate a PDF with the `screen` media type, call
1634
- * {@link Page.emulateMediaType | `page.emulateMediaType('screen')`} before
1635
- * calling `page.pdf()`.
1636
- *
1637
- * By default, `page.pdf()` generates a pdf with modified colors for printing.
1638
- * Use the
1639
- * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-print-color-adjust | `-webkit-print-color-adjust`}
1640
- * property to force rendering of exact colors.
1641
- *
1642
- *
1643
- * @param options - options for generating the PDF.
1644
- */
1645
- createPDFStream(options?: PDFOptions): Promise<Readable>;
1646
- /**
1647
- * @param options -
1648
- * @returns
1649
- */
1650
- pdf(options?: PDFOptions): Promise<Buffer>;
1651
- /**
1652
- * @returns The page's title
1653
- * @remarks
1654
- * Shortcut for {@link Frame.title | page.mainFrame().title()}.
1655
- */
1656
- title(): Promise<string>;
1657
- close(options?: {
1658
- runBeforeUnload?: boolean;
1659
- }): Promise<void>;
1660
- /**
1661
- * Indicates that the page has been closed.
1662
- * @returns
1663
- */
1664
- isClosed(): boolean;
1665
- get mouse(): Mouse;
1666
- /**
1667
- * This method fetches an element with `selector`, scrolls it into view if
1668
- * needed, and then uses {@link Page.mouse} to click in the center of the
1669
- * element. If there's no element matching `selector`, the method throws an
1670
- * error.
1671
- * @remarks Bear in mind that if `click()` triggers a navigation event and
1672
- * there's a separate `page.waitForNavigation()` promise to be resolved, you
1673
- * may end up with a race condition that yields unexpected results. The
1674
- * correct pattern for click and wait for navigation is the following:
1675
- * ```js
1676
- * const [response] = await Promise.all([
1677
- * page.waitForNavigation(waitOptions),
1678
- * page.click(selector, clickOptions),
1679
- * ]);
1680
- * ```
1681
- * Shortcut for {@link Frame.click | page.mainFrame().click(selector[, options]) }.
1682
- * @param selector - A `selector` to search for element to click. If there are
1683
- * multiple elements satisfying the `selector`, the first will be clicked
1684
- * @param options - `Object`
1685
- * @returns Promise which resolves when the element matching `selector` is
1686
- * successfully clicked. The Promise will be rejected if there is no element
1687
- * matching `selector`.
1688
- */
1689
- click(selector: string, options?: {
1690
- delay?: number;
1691
- button?: MouseButton;
1692
- clickCount?: number;
1693
- }): Promise<void>;
1694
- /**
1695
- * This method fetches an element with `selector` and focuses it. If there's no
1696
- * element matching `selector`, the method throws an error.
1697
- * @param selector - A
1698
- * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | selector }
1699
- * of an element to focus. If there are multiple elements satisfying the
1700
- * selector, the first will be focused.
1701
- * @returns Promise which resolves when the element matching selector is
1702
- * successfully focused. The promise will be rejected if there is no element
1703
- * matching selector.
1704
- * @remarks
1705
- * Shortcut for {@link Frame.focus | page.mainFrame().focus(selector)}.
1706
- */
1707
- focus(selector: string): Promise<void>;
1708
- /**
1709
- * This method fetches an element with `selector`, scrolls it into view if
1710
- * needed, and then uses {@link Page.mouse} to hover over the center of the element.
1711
- * If there's no element matching `selector`, the method throws an error.
1712
- * @param selector - A
1713
- * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | selector}
1714
- * to search for element to hover. If there are multiple elements satisfying
1715
- * the selector, the first will be hovered.
1716
- * @returns Promise which resolves when the element matching `selector` is
1717
- * successfully hovered. Promise gets rejected if there's no element matching
1718
- * `selector`.
1719
- * @remarks
1720
- * Shortcut for {@link Page.hover | page.mainFrame().hover(selector)}.
1721
- */
1722
- hover(selector: string): Promise<void>;
1723
- /**
1724
- * Triggers a `change` and `input` event once all the provided options have been
1725
- * selected. If there's no `<select>` element matching `selector`, the method
1726
- * throws an error.
1727
- *
1728
- * @example
1729
- * ```js
1730
- * page.select('select#colors', 'blue'); // single selection
1731
- * page.select('select#colors', 'red', 'green', 'blue'); // multiple selections
1732
- * ```
1733
- * @param selector - A
1734
- * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | Selector}
1735
- * to query the page for
1736
- * @param values - Values of options to select. If the `<select>` has the
1737
- * `multiple` attribute, all values are considered, otherwise only the first one
1738
- * is taken into account.
1739
- * @returns
1740
- *
1741
- * @remarks
1742
- * Shortcut for {@link Frame.select | page.mainFrame().select()}
1743
- */
1744
- select(selector: string, ...values: string[]): Promise<string[]>;
1745
- /**
1746
- * This method fetches an element with `selector`, scrolls it into view if
1747
- * needed, and then uses {@link Page.touchscreen} to tap in the center of the element.
1748
- * If there's no element matching `selector`, the method throws an error.
1749
- * @param selector - A
1750
- * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | Selector}
1751
- * to search for element to tap. If there are multiple elements satisfying the
1752
- * selector, the first will be tapped.
1753
- * @returns
1754
- * @remarks
1755
- * Shortcut for {@link Frame.tap | page.mainFrame().tap(selector)}.
1756
- */
1757
- tap(selector: string): Promise<void>;
1758
- /**
1759
- * Sends a `keydown`, `keypress/input`, and `keyup` event for each character
1760
- * in the text.
1761
- *
1762
- * To press a special key, like `Control` or `ArrowDown`, use {@link Keyboard.press}.
1763
- * @example
1764
- * ```
1765
- * await page.type('#mytextarea', 'Hello');
1766
- * // Types instantly
1767
- * await page.type('#mytextarea', 'World', { delay: 100 });
1768
- * // Types slower, like a user
1769
- * ```
1770
- * @param selector - A
1771
- * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | selector}
1772
- * of an element to type into. If there are multiple elements satisfying the
1773
- * selector, the first will be used.
1774
- * @param text - A text to type into a focused element.
1775
- * @param options - have property `delay` which is the Time to wait between
1776
- * key presses in milliseconds. Defaults to `0`.
1777
- * @returns
1778
- * @remarks
1779
- */
1780
- type(selector: string, text: string, options?: {
1781
- delay: number;
1782
- }): Promise<void>;
1783
- /**
1784
- * @remarks
1785
- *
1786
- * This method behaves differently depending on the first parameter. If it's a
1787
- * `string`, it will be treated as a `selector` or `xpath` (if the string
1788
- * starts with `//`). This method then is a shortcut for
1789
- * {@link Page.waitForSelector} or {@link Page.waitForXPath}.
1790
- *
1791
- * If the first argument is a function this method is a shortcut for
1792
- * {@link Page.waitForFunction}.
1793
- *
1794
- * If the first argument is a `number`, it's treated as a timeout in
1795
- * milliseconds and the method returns a promise which resolves after the
1796
- * timeout.
1797
- *
1798
- * @param selectorOrFunctionOrTimeout - a selector, predicate or timeout to
1799
- * wait for.
1800
- * @param options - optional waiting parameters.
1801
- * @param args - arguments to pass to `pageFunction`.
1802
- *
1803
- * @deprecated Don't use this method directly. Instead use the more explicit
1804
- * methods available: {@link Page.waitForSelector},
1805
- * {@link Page.waitForXPath}, {@link Page.waitForFunction} or
1806
- * {@link Page.waitForTimeout}.
1807
- */
1808
- waitFor(selectorOrFunctionOrTimeout: string | number | Function, options?: {
1809
- visible?: boolean;
1810
- hidden?: boolean;
1811
- timeout?: number;
1812
- polling?: string | number;
1813
- }, ...args: SerializableOrJSHandle[]): Promise<JSHandle>;
1814
- /**
1815
- * Causes your script to wait for the given number of milliseconds.
1816
- *
1817
- * @remarks
1818
- *
1819
- * It's generally recommended to not wait for a number of seconds, but instead
1820
- * use {@link Page.waitForSelector}, {@link Page.waitForXPath} or
1821
- * {@link Page.waitForFunction} to wait for exactly the conditions you want.
1822
- *
1823
- * @example
1824
- *
1825
- * Wait for 1 second:
1826
- *
1827
- * ```
1828
- * await page.waitForTimeout(1000);
1829
- * ```
1830
- *
1831
- * @param milliseconds - the number of milliseconds to wait.
1832
- */
1833
- waitForTimeout(milliseconds: number): Promise<void>;
1834
- /**
1835
- * Wait for the `selector` to appear in page. If at the moment of calling the
1836
- * method the `selector` already exists, the method will return immediately. If
1837
- * the `selector` doesn't appear after the `timeout` milliseconds of waiting, the
1838
- * function will throw.
1839
- *
1840
- * This method works across navigations:
1841
- * ```js
1842
- * const puppeteer = require('puppeteer');
1843
- * (async () => {
1844
- * const browser = await puppeteer.launch();
1845
- * const page = await browser.newPage();
1846
- * let currentURL;
1847
- * page
1848
- * .waitForSelector('img')
1849
- * .then(() => console.log('First URL with image: ' + currentURL));
1850
- * for (currentURL of [
1851
- * 'https://example.com',
1852
- * 'https://google.com',
1853
- * 'https://bbc.com',
1854
- * ]) {
1855
- * await page.goto(currentURL);
1856
- * }
1857
- * await browser.close();
1858
- * })();
1859
- * ```
1860
- * @param selector - A
1861
- * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | selector}
1862
- * of an element to wait for
1863
- * @param options - Optional waiting parameters
1864
- * @returns Promise which resolves when element specified by selector string
1865
- * is added to DOM. Resolves to `null` if waiting for hidden: `true` and
1866
- * selector is not found in DOM.
1867
- * @remarks
1868
- * The optional Parameter in Arguments `options` are :
1869
- *
1870
- * - `Visible`: A boolean wait for element to be present in DOM and to be
1871
- * visible, i.e. to not have `display: none` or `visibility: hidden` CSS
1872
- * properties. Defaults to `false`.
1873
- *
1874
- * - `hidden`: ait for element to not be found in the DOM or to be hidden,
1875
- * i.e. have `display: none` or `visibility: hidden` CSS properties. Defaults to
1876
- * `false`.
1877
- *
1878
- * - `timeout`: maximum time to wait for in milliseconds. Defaults to `30000`
1879
- * (30 seconds). Pass `0` to disable timeout. The default value can be changed
1880
- * by using the {@link Page.setDefaultTimeout} method.
1881
- */
1882
- waitForSelector(selector: string, options?: {
1883
- visible?: boolean;
1884
- hidden?: boolean;
1885
- timeout?: number;
1886
- }): Promise<ElementHandle | null>;
1887
- /**
1888
- * Wait for the `xpath` to appear in page. If at the moment of calling the
1889
- * method the `xpath` already exists, the method will return immediately. If
1890
- * the `xpath` doesn't appear after the `timeout` milliseconds of waiting, the
1891
- * function will throw.
1892
- *
1893
- * This method works across navigation
1894
- * ```js
1895
- * const puppeteer = require('puppeteer');
1896
- * (async () => {
1897
- * const browser = await puppeteer.launch();
1898
- * const page = await browser.newPage();
1899
- * let currentURL;
1900
- * page
1901
- * .waitForXPath('//img')
1902
- * .then(() => console.log('First URL with image: ' + currentURL));
1903
- * for (currentURL of [
1904
- * 'https://example.com',
1905
- * 'https://google.com',
1906
- * 'https://bbc.com',
1907
- * ]) {
1908
- * await page.goto(currentURL);
1909
- * }
1910
- * await browser.close();
1911
- * })();
1912
- * ```
1913
- * @param xpath - A
1914
- * {@link https://developer.mozilla.org/en-US/docs/Web/XPath | xpath} of an
1915
- * element to wait for
1916
- * @param options - Optional waiting parameters
1917
- * @returns Promise which resolves when element specified by xpath string is
1918
- * added to DOM. Resolves to `null` if waiting for `hidden: true` and xpath is
1919
- * not found in DOM.
1920
- * @remarks
1921
- * The optional Argument `options` have properties:
1922
- *
1923
- * - `visible`: A boolean to wait for element to be present in DOM and to be
1924
- * visible, i.e. to not have `display: none` or `visibility: hidden` CSS
1925
- * properties. Defaults to `false`.
1926
- *
1927
- * - `hidden`: A boolean wait for element to not be found in the DOM or to be
1928
- * hidden, i.e. have `display: none` or `visibility: hidden` CSS properties.
1929
- * Defaults to `false`.
1930
- *
1931
- * - `timeout`: A number which is maximum time to wait for in milliseconds.
1932
- * Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default
1933
- * value can be changed by using the {@link Page.setDefaultTimeout} method.
1934
- */
1935
- waitForXPath(xpath: string, options?: {
1936
- visible?: boolean;
1937
- hidden?: boolean;
1938
- timeout?: number;
1939
- }): Promise<ElementHandle | null>;
1940
- /**
1941
- * The `waitForFunction` can be used to observe viewport size change:
1942
- *
1943
- * ```
1944
- * const puppeteer = require('puppeteer');
1945
- * (async () => {
1946
- * const browser = await puppeteer.launch();
1947
- * const page = await browser.newPage();
1948
- * const watchDog = page.waitForFunction('window.innerWidth < 100');
1949
- * await page.setViewport({ width: 50, height: 50 });
1950
- * await watchDog;
1951
- * await browser.close();
1952
- * })();
1953
- * ```
1954
- * To pass arguments from node.js to the predicate of `page.waitForFunction` function:
1955
- * ```
1956
- * const selector = '.foo';
1957
- * await page.waitForFunction(
1958
- * (selector) => !!document.querySelector(selector),
1959
- * {},
1960
- * selector
1961
- * );
1962
- * ```
1963
- * The predicate of `page.waitForFunction` can be asynchronous too:
1964
- * ```
1965
- * const username = 'github-username';
1966
- * await page.waitForFunction(
1967
- * async (username) => {
1968
- * const githubResponse = await fetch(
1969
- * `https://api.github.com/users/${username}`
1970
- * );
1971
- * const githubUser = await githubResponse.json();
1972
- * // show the avatar
1973
- * const img = document.createElement('img');
1974
- * img.src = githubUser.avatar_url;
1975
- * // wait 3 seconds
1976
- * await new Promise((resolve, reject) => setTimeout(resolve, 3000));
1977
- * img.remove();
1978
- * },
1979
- * {},
1980
- * username
1981
- * );
1982
- * ```
1983
- * @param pageFunction - Function to be evaluated in browser context
1984
- * @param options - Optional waiting parameters
1985
- * @param args - Arguments to pass to `pageFunction`
1986
- * @returns Promise which resolves when the `pageFunction` returns a truthy
1987
- * value. It resolves to a JSHandle of the truthy value.
1988
- *
1989
- * The optional waiting parameter can be:
1990
- *
1991
- * - `Polling`: An interval at which the `pageFunction` is executed, defaults to
1992
- * `raf`. If `polling` is a number, then it is treated as an interval in
1993
- * milliseconds at which the function would be executed. If polling is a
1994
- * string, then it can be one of the following values:<br/>
1995
- * - `raf`: to constantly execute `pageFunction` in `requestAnimationFrame`
1996
- * callback. This is the tightest polling mode which is suitable to
1997
- * observe styling changes.<br/>
1998
- * - `mutation`: to execute pageFunction on every DOM mutation.
1999
- *
2000
- * - `timeout`: maximum time to wait for in milliseconds. Defaults to `30000`
2001
- * (30 seconds). Pass `0` to disable timeout. The default value can be changed
2002
- * by using the
2003
- * {@link Page.setDefaultTimeout | page.setDefaultTimeout(timeout)} method.
2004
- *
2005
- */
2006
- waitForFunction(pageFunction: Function | string, options?: {
2007
- timeout?: number;
2008
- polling?: string | number;
2009
- }, ...args: SerializableOrJSHandle[]): Promise<JSHandle>;
2010
- }
1
+ /**
2
+ * Copyright 2017 Google Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /// <reference types="node" />
17
+ import type { Readable } from 'stream';
18
+ import { EventEmitter } from './EventEmitter.js';
19
+ import { CDPSession } from './Connection.js';
20
+ import { Dialog } from './Dialog.js';
21
+ import { Frame } from './FrameManager.js';
22
+ import { Keyboard, Mouse, Touchscreen, MouseButton } from './Input.js';
23
+ import { Tracing } from './Tracing.js';
24
+ import { Coverage } from './Coverage.js';
25
+ import { WebWorker } from './WebWorker.js';
26
+ import { Browser, BrowserContext } from './Browser.js';
27
+ import { Target } from './Target.js';
28
+ import { JSHandle, ElementHandle } from './JSHandle.js';
29
+ import { Viewport } from './PuppeteerViewport.js';
30
+ import { Credentials, NetworkConditions } from './NetworkManager.js';
31
+ import { HTTPRequest } from './HTTPRequest.js';
32
+ import { HTTPResponse } from './HTTPResponse.js';
33
+ import { Accessibility } from './Accessibility.js';
34
+ import { FileChooser } from './FileChooser.js';
35
+ import { ConsoleMessage } from './ConsoleMessage.js';
36
+ import { PuppeteerLifeCycleEvent } from './LifecycleWatcher.js';
37
+ import { Protocol } from 'devtools-protocol';
38
+ import { SerializableOrJSHandle, EvaluateHandleFn, WrapElementHandle, EvaluateFn, EvaluateFnReturnType, UnwrapPromiseLike } from './EvalTypes.js';
39
+ import { PDFOptions } from './PDFOptions.js';
40
+ import { TaskQueue } from './TaskQueue.js';
41
+ /**
42
+ * @public
43
+ */
44
+ export interface Metrics {
45
+ Timestamp?: number;
46
+ Documents?: number;
47
+ Frames?: number;
48
+ JSEventListeners?: number;
49
+ Nodes?: number;
50
+ LayoutCount?: number;
51
+ RecalcStyleCount?: number;
52
+ LayoutDuration?: number;
53
+ RecalcStyleDuration?: number;
54
+ ScriptDuration?: number;
55
+ TaskDuration?: number;
56
+ JSHeapUsedSize?: number;
57
+ JSHeapTotalSize?: number;
58
+ }
59
+ /**
60
+ * @public
61
+ */
62
+ export interface WaitTimeoutOptions {
63
+ /**
64
+ * Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to
65
+ * disable the timeout.
66
+ *
67
+ * @remarks
68
+ * The default value can be changed by using the
69
+ * {@link Page.setDefaultTimeout} method.
70
+ */
71
+ timeout?: number;
72
+ }
73
+ /**
74
+ * @public
75
+ */
76
+ export interface WaitForOptions {
77
+ /**
78
+ * Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to
79
+ * disable the timeout.
80
+ *
81
+ * @remarks
82
+ * The default value can be changed by using the
83
+ * {@link Page.setDefaultTimeout} or {@link Page.setDefaultNavigationTimeout}
84
+ * methods.
85
+ */
86
+ timeout?: number;
87
+ waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[];
88
+ }
89
+ /**
90
+ * @public
91
+ */
92
+ export interface GeolocationOptions {
93
+ /**
94
+ * Latitude between -90 and 90.
95
+ */
96
+ longitude: number;
97
+ /**
98
+ * Longitude between -180 and 180.
99
+ */
100
+ latitude: number;
101
+ /**
102
+ * Optional non-negative accuracy value.
103
+ */
104
+ accuracy?: number;
105
+ }
106
+ /**
107
+ * @public
108
+ */
109
+ export interface MediaFeature {
110
+ name: string;
111
+ value: string;
112
+ }
113
+ /**
114
+ * @public
115
+ */
116
+ export interface ScreenshotClip {
117
+ x: number;
118
+ y: number;
119
+ width: number;
120
+ height: number;
121
+ }
122
+ /**
123
+ * @public
124
+ */
125
+ export interface ScreenshotOptions {
126
+ /**
127
+ * @defaultValue 'png'
128
+ */
129
+ type?: 'png' | 'jpeg' | 'webp';
130
+ /**
131
+ * The file path to save the image to. The screenshot type will be inferred
132
+ * from file extension. If path is a relative path, then it is resolved
133
+ * relative to current working directory. If no path is provided, the image
134
+ * won't be saved to the disk.
135
+ */
136
+ path?: string;
137
+ /**
138
+ * When true, takes a screenshot of the full page.
139
+ * @defaultValue false
140
+ */
141
+ fullPage?: boolean;
142
+ /**
143
+ * An object which specifies the clipping region of the page.
144
+ */
145
+ clip?: ScreenshotClip;
146
+ /**
147
+ * Quality of the image, between 0-100. Not applicable to `png` images.
148
+ */
149
+ quality?: number;
150
+ /**
151
+ * Hides default white background and allows capturing screenshots with transparency.
152
+ * @defaultValue false
153
+ */
154
+ omitBackground?: boolean;
155
+ /**
156
+ * Encoding of the image.
157
+ * @defaultValue 'binary'
158
+ */
159
+ encoding?: 'base64' | 'binary';
160
+ /**
161
+ * If you need a screenshot bigger than the Viewport
162
+ * @defaultValue true
163
+ */
164
+ captureBeyondViewport?: boolean;
165
+ }
166
+ /**
167
+ * All the events that a page instance may emit.
168
+ *
169
+ * @public
170
+ */
171
+ export declare const enum PageEmittedEvents {
172
+ /** Emitted when the page closes.
173
+ * @eventProperty
174
+ */
175
+ Close = "close",
176
+ /**
177
+ * Emitted when JavaScript within the page calls one of console API methods,
178
+ * e.g. `console.log` or `console.dir`. Also emitted if the page throws an
179
+ * error or a warning.
180
+ *
181
+ * @remarks
182
+ *
183
+ * A `console` event provides a {@link ConsoleMessage} representing the
184
+ * console message that was logged.
185
+ *
186
+ * @example
187
+ * An example of handling `console` event:
188
+ * ```js
189
+ * page.on('console', msg => {
190
+ * for (let i = 0; i < msg.args().length; ++i)
191
+ * console.log(`${i}: ${msg.args()[i]}`);
192
+ * });
193
+ * page.evaluate(() => console.log('hello', 5, {foo: 'bar'}));
194
+ * ```
195
+ */
196
+ Console = "console",
197
+ /**
198
+ * Emitted when a JavaScript dialog appears, such as `alert`, `prompt`,
199
+ * `confirm` or `beforeunload`. Puppeteer can respond to the dialog via
200
+ * {@link Dialog.accept} or {@link Dialog.dismiss}.
201
+ */
202
+ Dialog = "dialog",
203
+ /**
204
+ * Emitted when the JavaScript
205
+ * {@link https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded | DOMContentLoaded } event is dispatched.
206
+ */
207
+ DOMContentLoaded = "domcontentloaded",
208
+ /**
209
+ * Emitted when the page crashes. Will contain an `Error`.
210
+ */
211
+ Error = "error",
212
+ /** Emitted when a frame is attached. Will contain a {@link Frame}. */
213
+ FrameAttached = "frameattached",
214
+ /** Emitted when a frame is detached. Will contain a {@link Frame}. */
215
+ FrameDetached = "framedetached",
216
+ /** Emitted when a frame is navigated to a new URL. Will contain a {@link Frame}. */
217
+ FrameNavigated = "framenavigated",
218
+ /**
219
+ * Emitted when the JavaScript
220
+ * {@link https://developer.mozilla.org/en-US/docs/Web/Events/load | load}
221
+ * event is dispatched.
222
+ */
223
+ Load = "load",
224
+ /**
225
+ * Emitted when the JavaScript code makes a call to `console.timeStamp`. For
226
+ * the list of metrics see {@link Page.metrics | page.metrics}.
227
+ *
228
+ * @remarks
229
+ * Contains an object with two properties:
230
+ * - `title`: the title passed to `console.timeStamp`
231
+ * - `metrics`: objec containing metrics as key/value pairs. The values will
232
+ * be `number`s.
233
+ */
234
+ Metrics = "metrics",
235
+ /**
236
+ * Emitted when an uncaught exception happens within the page.
237
+ * Contains an `Error`.
238
+ */
239
+ PageError = "pageerror",
240
+ /**
241
+ * Emitted when the page opens a new tab or window.
242
+ *
243
+ * Contains a {@link Page} corresponding to the popup window.
244
+ *
245
+ * @example
246
+ *
247
+ * ```js
248
+ * const [popup] = await Promise.all([
249
+ * new Promise(resolve => page.once('popup', resolve)),
250
+ * page.click('a[target=_blank]'),
251
+ * ]);
252
+ * ```
253
+ *
254
+ * ```js
255
+ * const [popup] = await Promise.all([
256
+ * new Promise(resolve => page.once('popup', resolve)),
257
+ * page.evaluate(() => window.open('https://example.com')),
258
+ * ]);
259
+ * ```
260
+ */
261
+ Popup = "popup",
262
+ /**
263
+ * Emitted when a page issues a request and contains a {@link HTTPRequest}.
264
+ *
265
+ * @remarks
266
+ * The object is readonly. See {@link Page.setRequestInterception} for intercepting
267
+ * and mutating requests.
268
+ */
269
+ Request = "request",
270
+ /**
271
+ * Emitted when a request ended up loading from cache. Contains a {@link HTTPRequest}.
272
+ *
273
+ * @remarks
274
+ * For certain requests, might contain undefined.
275
+ * {@link https://crbug.com/750469}
276
+ */
277
+ RequestServedFromCache = "requestservedfromcache",
278
+ /**
279
+ * Emitted when a request fails, for example by timing out.
280
+ *
281
+ * Contains a {@link HTTPRequest}.
282
+ *
283
+ * @remarks
284
+ *
285
+ * NOTE: HTTP Error responses, such as 404 or 503, are still successful
286
+ * responses from HTTP standpoint, so request will complete with
287
+ * `requestfinished` event and not with `requestfailed`.
288
+ */
289
+ RequestFailed = "requestfailed",
290
+ /**
291
+ * Emitted when a request finishes successfully. Contains a {@link HTTPRequest}.
292
+ */
293
+ RequestFinished = "requestfinished",
294
+ /**
295
+ * Emitted when a response is received. Contains a {@link HTTPResponse}.
296
+ */
297
+ Response = "response",
298
+ /**
299
+ * Emitted when a dedicated
300
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API | WebWorker}
301
+ * is spawned by the page.
302
+ */
303
+ WorkerCreated = "workercreated",
304
+ /**
305
+ * Emitted when a dedicated
306
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API | WebWorker}
307
+ * is destroyed by the page.
308
+ */
309
+ WorkerDestroyed = "workerdestroyed"
310
+ }
311
+ /**
312
+ * Denotes the objects received by callback functions for page events.
313
+ *
314
+ * See {@link PageEmittedEvents} for more detail on the events and when they are
315
+ * emitted.
316
+ * @public
317
+ */
318
+ export interface PageEventObject {
319
+ close: never;
320
+ console: ConsoleMessage;
321
+ dialog: Dialog;
322
+ domcontentloaded: never;
323
+ error: Error;
324
+ frameattached: Frame;
325
+ framedetached: Frame;
326
+ framenavigated: Frame;
327
+ load: never;
328
+ metrics: {
329
+ title: string;
330
+ metrics: Metrics;
331
+ };
332
+ pageerror: Error;
333
+ popup: Page;
334
+ request: HTTPRequest;
335
+ response: HTTPResponse;
336
+ requestfailed: HTTPRequest;
337
+ requestfinished: HTTPRequest;
338
+ requestservedfromcache: HTTPRequest;
339
+ workercreated: WebWorker;
340
+ workerdestroyed: WebWorker;
341
+ }
342
+ /**
343
+ * Page provides methods to interact with a single tab or
344
+ * {@link https://developer.chrome.com/extensions/background_pages | extension background page} in Chromium.
345
+ *
346
+ * @remarks
347
+ *
348
+ * One Browser instance might have multiple Page instances.
349
+ *
350
+ * @example
351
+ * This example creates a page, navigates it to a URL, and then * saves a screenshot:
352
+ * ```js
353
+ * const puppeteer = require('puppeteer');
354
+ *
355
+ * (async () => {
356
+ * const browser = await puppeteer.launch();
357
+ * const page = await browser.newPage();
358
+ * await page.goto('https://example.com');
359
+ * await page.screenshot({path: 'screenshot.png'});
360
+ * await browser.close();
361
+ * })();
362
+ * ```
363
+ *
364
+ * The Page class extends from Puppeteer's {@link EventEmitter} class and will
365
+ * emit various events which are documented in the {@link PageEmittedEvents} enum.
366
+ *
367
+ * @example
368
+ * This example logs a message for a single page `load` event:
369
+ * ```js
370
+ * page.once('load', () => console.log('Page loaded!'));
371
+ * ```
372
+ *
373
+ * To unsubscribe from events use the `off` method:
374
+ *
375
+ * ```js
376
+ * function logRequest(interceptedRequest) {
377
+ * console.log('A request was made:', interceptedRequest.url());
378
+ * }
379
+ * page.on('request', logRequest);
380
+ * // Sometime later...
381
+ * page.off('request', logRequest);
382
+ * ```
383
+ * @public
384
+ */
385
+ export declare class Page extends EventEmitter {
386
+ /**
387
+ * @internal
388
+ */
389
+ static create(client: CDPSession, target: Target, ignoreHTTPSErrors: boolean, defaultViewport: Viewport | null, screenshotTaskQueue: TaskQueue): Promise<Page>;
390
+ private _closed;
391
+ private _client;
392
+ private _target;
393
+ private _keyboard;
394
+ private _mouse;
395
+ private _timeoutSettings;
396
+ private _touchscreen;
397
+ private _accessibility;
398
+ private _frameManager;
399
+ private _emulationManager;
400
+ private _tracing;
401
+ private _pageBindings;
402
+ private _coverage;
403
+ private _javascriptEnabled;
404
+ private _viewport;
405
+ private _screenshotTaskQueue;
406
+ private _workers;
407
+ private _fileChooserInterceptors;
408
+ private _disconnectPromise?;
409
+ private _userDragInterceptionEnabled;
410
+ private _handlerMap;
411
+ /**
412
+ * @internal
413
+ */
414
+ constructor(client: CDPSession, target: Target, ignoreHTTPSErrors: boolean, screenshotTaskQueue: TaskQueue);
415
+ private _initialize;
416
+ private _onFileChooser;
417
+ /**
418
+ * @returns `true` if drag events are being intercepted, `false` otherwise.
419
+ */
420
+ isDragInterceptionEnabled(): boolean;
421
+ /**
422
+ * @returns `true` if the page has JavaScript enabled, `false` otherwise.
423
+ */
424
+ isJavaScriptEnabled(): boolean;
425
+ /**
426
+ * Listen to page events.
427
+ */
428
+ on<K extends keyof PageEventObject>(eventName: K, handler: (event: PageEventObject[K]) => void): EventEmitter;
429
+ once<K extends keyof PageEventObject>(eventName: K, handler: (event: PageEventObject[K]) => void): EventEmitter;
430
+ off<K extends keyof PageEventObject>(eventName: K, handler: (event: PageEventObject[K]) => void): EventEmitter;
431
+ /**
432
+ * This method is typically coupled with an action that triggers file
433
+ * choosing. The following example clicks a button that issues a file chooser
434
+ * and then responds with `/tmp/myfile.pdf` as if a user has selected this file.
435
+ *
436
+ * ```js
437
+ * const [fileChooser] = await Promise.all([
438
+ * page.waitForFileChooser(),
439
+ * page.click('#upload-file-button'),
440
+ * // some button that triggers file selection
441
+ * ]);
442
+ * await fileChooser.accept(['/tmp/myfile.pdf']);
443
+ * ```
444
+ *
445
+ * NOTE: This must be called before the file chooser is launched. It will not
446
+ * return a currently active file chooser.
447
+ * @param options - Optional waiting parameters
448
+ * @returns Resolves after a page requests a file picker.
449
+ * @remarks
450
+ * NOTE: In non-headless Chromium, this method results in the native file picker
451
+ * dialog `not showing up` for the user.
452
+ */
453
+ waitForFileChooser(options?: WaitTimeoutOptions): Promise<FileChooser>;
454
+ /**
455
+ * Sets the page's geolocation.
456
+ * @remarks
457
+ * NOTE: Consider using {@link BrowserContext.overridePermissions} to grant
458
+ * permissions for the page to read its geolocation.
459
+ * @example
460
+ * ```js
461
+ * await page.setGeolocation({latitude: 59.95, longitude: 30.31667});
462
+ * ```
463
+ */
464
+ setGeolocation(options: GeolocationOptions): Promise<void>;
465
+ /**
466
+ * @returns A target this page was created from.
467
+ */
468
+ target(): Target;
469
+ /**
470
+ * Get the CDP session client the page belongs to.
471
+ * @internal
472
+ */
473
+ client(): CDPSession;
474
+ /**
475
+ * Get the browser the page belongs to.
476
+ */
477
+ browser(): Browser;
478
+ /**
479
+ * Get the browser context that the page belongs to.
480
+ */
481
+ browserContext(): BrowserContext;
482
+ private _onTargetCrashed;
483
+ private _onLogEntryAdded;
484
+ /**
485
+ * @returns The page's main frame.
486
+ * @remarks
487
+ * Page is guaranteed to have a main frame which persists during navigations.
488
+ */
489
+ mainFrame(): Frame;
490
+ get keyboard(): Keyboard;
491
+ get touchscreen(): Touchscreen;
492
+ get coverage(): Coverage;
493
+ get tracing(): Tracing;
494
+ get accessibility(): Accessibility;
495
+ /**
496
+ * @returns An array of all frames attached to the page.
497
+ */
498
+ frames(): Frame[];
499
+ /**
500
+ * @returns all of the dedicated
501
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API |
502
+ * WebWorkers}
503
+ * associated with the page.
504
+ * @remarks
505
+ * NOTE: This does not contain ServiceWorkers
506
+ */
507
+ workers(): WebWorker[];
508
+ /**
509
+ * @param value - Whether to enable request interception.
510
+ *
511
+ * @remarks
512
+ * Activating request interception enables {@link HTTPRequest.abort},
513
+ * {@link HTTPRequest.continue} and {@link HTTPRequest.respond} methods. This
514
+ * provides the capability to modify network requests that are made by a page.
515
+ *
516
+ * Once request interception is enabled, every request will stall unless it's
517
+ * continued, responded or aborted; or completed using the browser cache.
518
+ *
519
+ * @example
520
+ * An example of a naïve request interceptor that aborts all image requests:
521
+ * ```js
522
+ * const puppeteer = require('puppeteer');
523
+ * (async () => {
524
+ * const browser = await puppeteer.launch();
525
+ * const page = await browser.newPage();
526
+ * await page.setRequestInterception(true);
527
+ * page.on('request', interceptedRequest => {
528
+ * if (interceptedRequest.url().endsWith('.png') ||
529
+ * interceptedRequest.url().endsWith('.jpg'))
530
+ * interceptedRequest.abort();
531
+ * else
532
+ * interceptedRequest.continue();
533
+ * });
534
+ * await page.goto('https://example.com');
535
+ * await browser.close();
536
+ * })();
537
+ * ```
538
+ * NOTE: Enabling request interception disables page caching.
539
+ */
540
+ setRequestInterception(value: boolean): Promise<void>;
541
+ /**
542
+ * @param enabled - Whether to enable drag interception.
543
+ *
544
+ * @remarks
545
+ * Activating drag interception enables the `Input.drag`,
546
+ * methods This provides the capability to capture drag events emitted
547
+ * on the page, which can then be used to simulate drag-and-drop.
548
+ */
549
+ setDragInterception(enabled: boolean): Promise<void>;
550
+ /**
551
+ * @param enabled - When `true`, enables offline mode for the page.
552
+ * @remarks
553
+ * NOTE: while this method sets the network connection to offline, it does
554
+ * not change the parameters used in [page.emulateNetworkConditions(networkConditions)]
555
+ * (#pageemulatenetworkconditionsnetworkconditions)
556
+ */
557
+ setOfflineMode(enabled: boolean): Promise<void>;
558
+ /**
559
+ * @param networkConditions - Passing `null` disables network condition emulation.
560
+ * @example
561
+ * ```js
562
+ * const puppeteer = require('puppeteer');
563
+ * const slow3G = puppeteer.networkConditions['Slow 3G'];
564
+ *
565
+ * (async () => {
566
+ * const browser = await puppeteer.launch();
567
+ * const page = await browser.newPage();
568
+ * await page.emulateNetworkConditions(slow3G);
569
+ * await page.goto('https://www.google.com');
570
+ * // other actions...
571
+ * await browser.close();
572
+ * })();
573
+ * ```
574
+ * @remarks
575
+ * NOTE: This does not affect WebSockets and WebRTC PeerConnections (see
576
+ * https://crbug.com/563644). To set the page offline, you can use
577
+ * [page.setOfflineMode(enabled)](#pagesetofflinemodeenabled).
578
+ */
579
+ emulateNetworkConditions(networkConditions: NetworkConditions | null): Promise<void>;
580
+ /**
581
+ * This setting will change the default maximum navigation time for the
582
+ * following methods and related shortcuts:
583
+ *
584
+ * - {@link Page.goBack | page.goBack(options)}
585
+ *
586
+ * - {@link Page.goForward | page.goForward(options)}
587
+ *
588
+ * - {@link Page.goto | page.goto(url,options)}
589
+ *
590
+ * - {@link Page.reload | page.reload(options)}
591
+ *
592
+ * - {@link Page.setContent | page.setContent(html,options)}
593
+ *
594
+ * - {@link Page.waitForNavigation | page.waitForNavigation(options)}
595
+ * @param timeout - Maximum navigation time in milliseconds.
596
+ */
597
+ setDefaultNavigationTimeout(timeout: number): void;
598
+ /**
599
+ * @param timeout - Maximum time in milliseconds.
600
+ */
601
+ setDefaultTimeout(timeout: number): void;
602
+ /**
603
+ * Runs `document.querySelector` within the page. If no element matches the
604
+ * selector, the return value resolves to `null`.
605
+ *
606
+ * @remarks
607
+ * Shortcut for {@link Frame.$ | Page.mainFrame().$(selector) }.
608
+ *
609
+ * @param selector - A `selector` to query page for
610
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | selector}
611
+ * to query page for.
612
+ */
613
+ $<T extends Element = Element>(selector: string): Promise<ElementHandle<T> | null>;
614
+ /**
615
+ * @remarks
616
+ *
617
+ * The only difference between {@link Page.evaluate | page.evaluate} and
618
+ * `page.evaluateHandle` is that `evaluateHandle` will return the value
619
+ * wrapped in an in-page object.
620
+ *
621
+ * If the function passed to `page.evaluteHandle` returns a Promise, the
622
+ * function will wait for the promise to resolve and return its value.
623
+ *
624
+ * You can pass a string instead of a function (although functions are
625
+ * recommended as they are easier to debug and use with TypeScript):
626
+ *
627
+ * @example
628
+ * ```
629
+ * const aHandle = await page.evaluateHandle('document')
630
+ * ```
631
+ *
632
+ * @example
633
+ * {@link JSHandle} instances can be passed as arguments to the `pageFunction`:
634
+ * ```
635
+ * const aHandle = await page.evaluateHandle(() => document.body);
636
+ * const resultHandle = await page.evaluateHandle(body => body.innerHTML, aHandle);
637
+ * console.log(await resultHandle.jsonValue());
638
+ * await resultHandle.dispose();
639
+ * ```
640
+ *
641
+ * Most of the time this function returns a {@link JSHandle},
642
+ * but if `pageFunction` returns a reference to an element,
643
+ * you instead get an {@link ElementHandle} back:
644
+ *
645
+ * @example
646
+ * ```
647
+ * const button = await page.evaluateHandle(() => document.querySelector('button'));
648
+ * // can call `click` because `button` is an `ElementHandle`
649
+ * await button.click();
650
+ * ```
651
+ *
652
+ * The TypeScript definitions assume that `evaluateHandle` returns
653
+ * a `JSHandle`, but if you know it's going to return an
654
+ * `ElementHandle`, pass it as the generic argument:
655
+ *
656
+ * ```
657
+ * const button = await page.evaluateHandle<ElementHandle>(...);
658
+ * ```
659
+ *
660
+ * @param pageFunction - a function that is run within the page
661
+ * @param args - arguments to be passed to the pageFunction
662
+ */
663
+ evaluateHandle<HandlerType extends JSHandle = JSHandle>(pageFunction: EvaluateHandleFn, ...args: SerializableOrJSHandle[]): Promise<HandlerType>;
664
+ /**
665
+ * This method iterates the JavaScript heap and finds all objects with the
666
+ * given prototype.
667
+ *
668
+ * @remarks
669
+ * Shortcut for
670
+ * {@link ExecutionContext.queryObjects |
671
+ * page.mainFrame().executionContext().queryObjects(prototypeHandle)}.
672
+ *
673
+ * @example
674
+ *
675
+ * ```js
676
+ * // Create a Map object
677
+ * await page.evaluate(() => window.map = new Map());
678
+ * // Get a handle to the Map object prototype
679
+ * const mapPrototype = await page.evaluateHandle(() => Map.prototype);
680
+ * // Query all map instances into an array
681
+ * const mapInstances = await page.queryObjects(mapPrototype);
682
+ * // Count amount of map objects in heap
683
+ * const count = await page.evaluate(maps => maps.length, mapInstances);
684
+ * await mapInstances.dispose();
685
+ * await mapPrototype.dispose();
686
+ * ```
687
+ * @param prototypeHandle - a handle to the object prototype.
688
+ * @returns Promise which resolves to a handle to an array of objects with
689
+ * this prototype.
690
+ */
691
+ queryObjects(prototypeHandle: JSHandle): Promise<JSHandle>;
692
+ /**
693
+ * This method runs `document.querySelector` within the page and passes the
694
+ * result as the first argument to the `pageFunction`.
695
+ *
696
+ * @remarks
697
+ *
698
+ * If no element is found matching `selector`, the method will throw an error.
699
+ *
700
+ * If `pageFunction` returns a promise `$eval` will wait for the promise to
701
+ * resolve and then return its value.
702
+ *
703
+ * @example
704
+ *
705
+ * ```
706
+ * const searchValue = await page.$eval('#search', el => el.value);
707
+ * const preloadHref = await page.$eval('link[rel=preload]', el => el.href);
708
+ * const html = await page.$eval('.main-container', el => el.outerHTML);
709
+ * ```
710
+ *
711
+ * If you are using TypeScript, you may have to provide an explicit type to the
712
+ * first argument of the `pageFunction`.
713
+ * By default it is typed as `Element`, but you may need to provide a more
714
+ * specific sub-type:
715
+ *
716
+ * @example
717
+ *
718
+ * ```
719
+ * // if you don't provide HTMLInputElement here, TS will error
720
+ * // as `value` is not on `Element`
721
+ * const searchValue = await page.$eval('#search', (el: HTMLInputElement) => el.value);
722
+ * ```
723
+ *
724
+ * The compiler should be able to infer the return type
725
+ * from the `pageFunction` you provide. If it is unable to, you can use the generic
726
+ * type to tell the compiler what return type you expect from `$eval`:
727
+ *
728
+ * @example
729
+ *
730
+ * ```
731
+ * // The compiler can infer the return type in this case, but if it can't
732
+ * // or if you want to be more explicit, provide it as the generic type.
733
+ * const searchValue = await page.$eval<string>(
734
+ * '#search', (el: HTMLInputElement) => el.value
735
+ * );
736
+ * ```
737
+ *
738
+ * @param selector - the
739
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | selector}
740
+ * to query for
741
+ * @param pageFunction - the function to be evaluated in the page context.
742
+ * Will be passed the result of `document.querySelector(selector)` as its
743
+ * first argument.
744
+ * @param args - any additional arguments to pass through to `pageFunction`.
745
+ *
746
+ * @returns The result of calling `pageFunction`. If it returns an element it
747
+ * is wrapped in an {@link ElementHandle}, else the raw value itself is
748
+ * returned.
749
+ */
750
+ $eval<ReturnType>(selector: string, pageFunction: (element: Element, ...args: unknown[]) => ReturnType | Promise<ReturnType>, ...args: SerializableOrJSHandle[]): Promise<WrapElementHandle<ReturnType>>;
751
+ /**
752
+ * This method runs `Array.from(document.querySelectorAll(selector))` within
753
+ * the page and passes the result as the first argument to the `pageFunction`.
754
+ *
755
+ * @remarks
756
+ *
757
+ * If `pageFunction` returns a promise `$$eval` will wait for the promise to
758
+ * resolve and then return its value.
759
+ *
760
+ * @example
761
+ *
762
+ * ```
763
+ * // get the amount of divs on the page
764
+ * const divCount = await page.$$eval('div', divs => divs.length);
765
+ *
766
+ * // get the text content of all the `.options` elements:
767
+ * const options = await page.$$eval('div > span.options', options => {
768
+ * return options.map(option => option.textContent)
769
+ * });
770
+ * ```
771
+ *
772
+ * If you are using TypeScript, you may have to provide an explicit type to the
773
+ * first argument of the `pageFunction`.
774
+ * By default it is typed as `Element[]`, but you may need to provide a more
775
+ * specific sub-type:
776
+ *
777
+ * @example
778
+ *
779
+ * ```
780
+ * // if you don't provide HTMLInputElement here, TS will error
781
+ * // as `value` is not on `Element`
782
+ * await page.$$eval('input', (elements: HTMLInputElement[]) => {
783
+ * return elements.map(e => e.value);
784
+ * });
785
+ * ```
786
+ *
787
+ * The compiler should be able to infer the return type
788
+ * from the `pageFunction` you provide. If it is unable to, you can use the generic
789
+ * type to tell the compiler what return type you expect from `$$eval`:
790
+ *
791
+ * @example
792
+ *
793
+ * ```
794
+ * // The compiler can infer the return type in this case, but if it can't
795
+ * // or if you want to be more explicit, provide it as the generic type.
796
+ * const allInputValues = await page.$$eval<string[]>(
797
+ * 'input', (elements: HTMLInputElement[]) => elements.map(e => e.textContent)
798
+ * );
799
+ * ```
800
+ *
801
+ * @param selector - the
802
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | selector}
803
+ * to query for
804
+ * @param pageFunction - the function to be evaluated in the page context. Will
805
+ * be passed the result of `Array.from(document.querySelectorAll(selector))`
806
+ * as its first argument.
807
+ * @param args - any additional arguments to pass through to `pageFunction`.
808
+ *
809
+ * @returns The result of calling `pageFunction`. If it returns an element it
810
+ * is wrapped in an {@link ElementHandle}, else the raw value itself is
811
+ * returned.
812
+ */
813
+ $$eval<ReturnType>(selector: string, pageFunction: (elements: Element[], ...args: unknown[]) => ReturnType | Promise<ReturnType>, ...args: SerializableOrJSHandle[]): Promise<WrapElementHandle<ReturnType>>;
814
+ /**
815
+ * The method runs `document.querySelectorAll` within the page. If no elements
816
+ * match the selector, the return value resolves to `[]`.
817
+ * @remarks
818
+ * Shortcut for {@link Frame.$$ | Page.mainFrame().$$(selector) }.
819
+ * @param selector - A `selector` to query page for
820
+ */
821
+ $$<T extends Element = Element>(selector: string): Promise<Array<ElementHandle<T>>>;
822
+ /**
823
+ * The method evaluates the XPath expression relative to the page document as
824
+ * its context node. If there are no such elements, the method resolves to an
825
+ * empty array.
826
+ * @remarks
827
+ * Shortcut for {@link Frame.$x | Page.mainFrame().$x(expression) }.
828
+ * @param expression - Expression to evaluate
829
+ */
830
+ $x(expression: string): Promise<ElementHandle[]>;
831
+ /**
832
+ * If no URLs are specified, this method returns cookies for the current page
833
+ * URL. If URLs are specified, only cookies for those URLs are returned.
834
+ */
835
+ cookies(...urls: string[]): Promise<Protocol.Network.Cookie[]>;
836
+ deleteCookie(...cookies: Protocol.Network.DeleteCookiesRequest[]): Promise<void>;
837
+ /**
838
+ * @example
839
+ * ```js
840
+ * await page.setCookie(cookieObject1, cookieObject2);
841
+ * ```
842
+ */
843
+ setCookie(...cookies: Protocol.Network.CookieParam[]): Promise<void>;
844
+ /**
845
+ * Adds a `<script>` tag into the page with the desired URL or content.
846
+ * @remarks
847
+ * Shortcut for {@link Frame.addScriptTag | page.mainFrame().addScriptTag(options) }.
848
+ * @returns Promise which resolves to the added tag when the script's onload fires or
849
+ * when the script content was injected into frame.
850
+ */
851
+ addScriptTag(options: {
852
+ url?: string;
853
+ path?: string;
854
+ content?: string;
855
+ type?: string;
856
+ id?: string;
857
+ }): Promise<ElementHandle>;
858
+ /**
859
+ * Adds a `<link rel="stylesheet">` tag into the page with the desired URL or a
860
+ * `<style type="text/css">` tag with the content.
861
+ * @returns Promise which resolves to the added tag when the stylesheet's
862
+ * onload fires or when the CSS content was injected into frame.
863
+ */
864
+ addStyleTag(options: {
865
+ url?: string;
866
+ path?: string;
867
+ content?: string;
868
+ }): Promise<ElementHandle>;
869
+ /**
870
+ * The method adds a function called `name` on the page's `window` object. When
871
+ * called, the function executes `puppeteerFunction` in node.js and returns a
872
+ * `Promise` which resolves to the return value of `puppeteerFunction`.
873
+ *
874
+ * If the puppeteerFunction returns a `Promise`, it will be awaited.
875
+ *
876
+ * NOTE: Functions installed via `page.exposeFunction` survive navigations.
877
+ * @param name - Name of the function on the window object
878
+ * @param puppeteerFunction - Callback function which will be called in
879
+ * Puppeteer's context.
880
+ * @example
881
+ * An example of adding an `md5` function into the page:
882
+ * ```js
883
+ * const puppeteer = require('puppeteer');
884
+ * const crypto = require('crypto');
885
+ *
886
+ * (async () => {
887
+ * const browser = await puppeteer.launch();
888
+ * const page = await browser.newPage();
889
+ * page.on('console', (msg) => console.log(msg.text()));
890
+ * await page.exposeFunction('md5', (text) =>
891
+ * crypto.createHash('md5').update(text).digest('hex')
892
+ * );
893
+ * await page.evaluate(async () => {
894
+ * // use window.md5 to compute hashes
895
+ * const myString = 'PUPPETEER';
896
+ * const myHash = await window.md5(myString);
897
+ * console.log(`md5 of ${myString} is ${myHash}`);
898
+ * });
899
+ * await browser.close();
900
+ * })();
901
+ * ```
902
+ * An example of adding a `window.readfile` function into the page:
903
+ * ```js
904
+ * const puppeteer = require('puppeteer');
905
+ * const fs = require('fs');
906
+ *
907
+ * (async () => {
908
+ * const browser = await puppeteer.launch();
909
+ * const page = await browser.newPage();
910
+ * page.on('console', (msg) => console.log(msg.text()));
911
+ * await page.exposeFunction('readfile', async (filePath) => {
912
+ * return new Promise((resolve, reject) => {
913
+ * fs.readFile(filePath, 'utf8', (err, text) => {
914
+ * if (err) reject(err);
915
+ * else resolve(text);
916
+ * });
917
+ * });
918
+ * });
919
+ * await page.evaluate(async () => {
920
+ * // use window.readfile to read contents of a file
921
+ * const content = await window.readfile('/etc/hosts');
922
+ * console.log(content);
923
+ * });
924
+ * await browser.close();
925
+ * })();
926
+ * ```
927
+ */
928
+ exposeFunction(name: string, puppeteerFunction: Function | {
929
+ default: Function;
930
+ }): Promise<void>;
931
+ /**
932
+ * Provide credentials for `HTTP authentication`.
933
+ * @remarks To disable authentication, pass `null`.
934
+ */
935
+ authenticate(credentials: Credentials): Promise<void>;
936
+ /**
937
+ * The extra HTTP headers will be sent with every request the page initiates.
938
+ * NOTE: All HTTP header names are lowercased. (HTTP headers are
939
+ * case-insensitive, so this shouldn’t impact your server code.)
940
+ * NOTE: page.setExtraHTTPHeaders does not guarantee the order of headers in
941
+ * the outgoing requests.
942
+ * @param headers - An object containing additional HTTP headers to be sent
943
+ * with every request. All header values must be strings.
944
+ * @returns
945
+ */
946
+ setExtraHTTPHeaders(headers: Record<string, string>): Promise<void>;
947
+ /**
948
+ * @param userAgent - Specific user agent to use in this page
949
+ * @param userAgentData - Specific user agent client hint data to use in this
950
+ * page
951
+ * @returns Promise which resolves when the user agent is set.
952
+ */
953
+ setUserAgent(userAgent: string, userAgentMetadata?: Protocol.Emulation.UserAgentMetadata): Promise<void>;
954
+ /**
955
+ * @returns Object containing metrics as key/value pairs.
956
+ *
957
+ * - `Timestamp` : The timestamp when the metrics sample was taken.
958
+ *
959
+ * - `Documents` : Number of documents in the page.
960
+ *
961
+ * - `Frames` : Number of frames in the page.
962
+ *
963
+ * - `JSEventListeners` : Number of events in the page.
964
+ *
965
+ * - `Nodes` : Number of DOM nodes in the page.
966
+ *
967
+ * - `LayoutCount` : Total number of full or partial page layout.
968
+ *
969
+ * - `RecalcStyleCount` : Total number of page style recalculations.
970
+ *
971
+ * - `LayoutDuration` : Combined durations of all page layouts.
972
+ *
973
+ * - `RecalcStyleDuration` : Combined duration of all page style
974
+ * recalculations.
975
+ *
976
+ * - `ScriptDuration` : Combined duration of JavaScript execution.
977
+ *
978
+ * - `TaskDuration` : Combined duration of all tasks performed by the browser.
979
+ *
980
+ *
981
+ * - `JSHeapUsedSize` : Used JavaScript heap size.
982
+ *
983
+ * - `JSHeapTotalSize` : Total JavaScript heap size.
984
+ * @remarks
985
+ * NOTE: All timestamps are in monotonic time: monotonically increasing time
986
+ * in seconds since an arbitrary point in the past.
987
+ */
988
+ metrics(): Promise<Metrics>;
989
+ private _emitMetrics;
990
+ private _buildMetricsObject;
991
+ private _handleException;
992
+ private _onConsoleAPI;
993
+ private _onBindingCalled;
994
+ private _addConsoleMessage;
995
+ private _onDialog;
996
+ /**
997
+ * Resets default white background
998
+ */
999
+ private _resetDefaultBackgroundColor;
1000
+ /**
1001
+ * Hides default white background
1002
+ */
1003
+ private _setTransparentBackgroundColor;
1004
+ /**
1005
+ *
1006
+ * @returns
1007
+ * @remarks Shortcut for
1008
+ * {@link Frame.url | page.mainFrame().url()}.
1009
+ */
1010
+ url(): string;
1011
+ content(): Promise<string>;
1012
+ /**
1013
+ * @param html - HTML markup to assign to the page.
1014
+ * @param options - Parameters that has some properties.
1015
+ * @remarks
1016
+ * The parameter `options` might have the following options.
1017
+ *
1018
+ * - `timeout` : Maximum time in milliseconds for resources to load, defaults
1019
+ * to 30 seconds, pass `0` to disable timeout. The default value can be
1020
+ * changed by using the
1021
+ * {@link Page.setDefaultNavigationTimeout |
1022
+ * page.setDefaultNavigationTimeout(timeout)}
1023
+ * or {@link Page.setDefaultTimeout | page.setDefaultTimeout(timeout)}
1024
+ * methods.
1025
+ *
1026
+ * - `waitUntil`: When to consider setting markup succeeded, defaults to `load`.
1027
+ * Given an array of event strings, setting content is considered to be
1028
+ * successful after all events have been fired. Events can be either:<br/>
1029
+ * - `load` : consider setting content to be finished when the `load` event is
1030
+ * fired.<br/>
1031
+ * - `domcontentloaded` : consider setting content to be finished when the
1032
+ * `DOMContentLoaded` event is fired.<br/>
1033
+ * - `networkidle0` : consider setting content to be finished when there are no
1034
+ * more than 0 network connections for at least `500` ms.<br/>
1035
+ * - `networkidle2` : consider setting content to be finished when there are no
1036
+ * more than 2 network connections for at least `500` ms.
1037
+ */
1038
+ setContent(html: string, options?: WaitForOptions): Promise<void>;
1039
+ /**
1040
+ * @param url - URL to navigate page to. The URL should include scheme, e.g.
1041
+ * `https://`
1042
+ * @param options - Navigation Parameter
1043
+ * @returns Promise which resolves to the main resource response. In case of
1044
+ * multiple redirects, the navigation will resolve with the response of the
1045
+ * last redirect.
1046
+ * @remarks
1047
+ * The argument `options` might have the following properties:
1048
+ *
1049
+ * - `timeout` : Maximum navigation time in milliseconds, defaults to 30
1050
+ * seconds, pass 0 to disable timeout. The default value can be changed by
1051
+ * using the
1052
+ * {@link Page.setDefaultNavigationTimeout |
1053
+ * page.setDefaultNavigationTimeout(timeout)}
1054
+ * or {@link Page.setDefaultTimeout | page.setDefaultTimeout(timeout)}
1055
+ * methods.
1056
+ *
1057
+ * - `waitUntil`:When to consider navigation succeeded, defaults to `load`.
1058
+ * Given an array of event strings, navigation is considered to be successful
1059
+ * after all events have been fired. Events can be either:<br/>
1060
+ * - `load` : consider navigation to be finished when the load event is
1061
+ * fired.<br/>
1062
+ * - `domcontentloaded` : consider navigation to be finished when the
1063
+ * DOMContentLoaded event is fired.<br/>
1064
+ * - `networkidle0` : consider navigation to be finished when there are no
1065
+ * more than 0 network connections for at least `500` ms.<br/>
1066
+ * - `networkidle2` : consider navigation to be finished when there are no
1067
+ * more than 2 network connections for at least `500` ms.
1068
+ *
1069
+ * - `referer` : Referer header value. If provided it will take preference
1070
+ * over the referer header value set by
1071
+ * {@link Page.setExtraHTTPHeaders |page.setExtraHTTPHeaders()}.
1072
+ *
1073
+ * `page.goto` will throw an error if:
1074
+ * - there's an SSL error (e.g. in case of self-signed certificates).
1075
+ * - target URL is invalid.
1076
+ * - the timeout is exceeded during navigation.
1077
+ * - the remote server does not respond or is unreachable.
1078
+ * - the main resource failed to load.
1079
+ *
1080
+ * `page.goto` will not throw an error when any valid HTTP status code is
1081
+ * returned by the remote server, including 404 "Not Found" and 500
1082
+ * "Internal Server Error". The status code for such responses can be
1083
+ * retrieved by calling response.status().
1084
+ *
1085
+ * NOTE: `page.goto` either throws an error or returns a main resource
1086
+ * response. The only exceptions are navigation to about:blank or navigation
1087
+ * to the same URL with a different hash, which would succeed and return null.
1088
+ *
1089
+ * NOTE: Headless mode doesn't support navigation to a PDF document. See the
1090
+ * {@link https://bugs.chromium.org/p/chromium/issues/detail?id=761295
1091
+ * | upstream issue}.
1092
+ *
1093
+ * Shortcut for {@link Frame.goto | page.mainFrame().goto(url, options)}.
1094
+ */
1095
+ goto(url: string, options?: WaitForOptions & {
1096
+ referer?: string;
1097
+ }): Promise<HTTPResponse>;
1098
+ /**
1099
+ * @param options - Navigation parameters which might have the following
1100
+ * properties:
1101
+ * @returns Promise which resolves to the main resource response. In case of
1102
+ * multiple redirects, the navigation will resolve with the response of the
1103
+ * last redirect.
1104
+ * @remarks
1105
+ * The argument `options` might have the following properties:
1106
+ *
1107
+ * - `timeout` : Maximum navigation time in milliseconds, defaults to 30
1108
+ * seconds, pass 0 to disable timeout. The default value can be changed by
1109
+ * using the
1110
+ * {@link Page.setDefaultNavigationTimeout |
1111
+ * page.setDefaultNavigationTimeout(timeout)}
1112
+ * or {@link Page.setDefaultTimeout | page.setDefaultTimeout(timeout)}
1113
+ * methods.
1114
+ *
1115
+ * - `waitUntil`: When to consider navigation succeeded, defaults to `load`.
1116
+ * Given an array of event strings, navigation is considered to be
1117
+ * successful after all events have been fired. Events can be either:<br/>
1118
+ * - `load` : consider navigation to be finished when the load event is fired.<br/>
1119
+ * - `domcontentloaded` : consider navigation to be finished when the
1120
+ * DOMContentLoaded event is fired.<br/>
1121
+ * - `networkidle0` : consider navigation to be finished when there are no
1122
+ * more than 0 network connections for at least `500` ms.<br/>
1123
+ * - `networkidle2` : consider navigation to be finished when there are no
1124
+ * more than 2 network connections for at least `500` ms.
1125
+ */
1126
+ reload(options?: WaitForOptions): Promise<HTTPResponse | null>;
1127
+ /**
1128
+ * This resolves when the page navigates to a new URL or reloads. It is useful
1129
+ * when you run code that will indirectly cause the page to navigate. Consider
1130
+ * this example:
1131
+ * ```js
1132
+ * const [response] = await Promise.all([
1133
+ * page.waitForNavigation(), // The promise resolves after navigation has finished
1134
+ * page.click('a.my-link'), // Clicking the link will indirectly cause a navigation
1135
+ * ]);
1136
+ * ```
1137
+ *
1138
+ * @param options - Navigation parameters which might have the following properties:
1139
+ * @returns Promise which resolves to the main resource response. In case of
1140
+ * multiple redirects, the navigation will resolve with the response of the
1141
+ * last redirect. In case of navigation to a different anchor or navigation
1142
+ * due to History API usage, the navigation will resolve with `null`.
1143
+ * @remarks
1144
+ * NOTE: Usage of the
1145
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/History_API | History API}
1146
+ * to change the URL is considered a navigation.
1147
+ *
1148
+ * Shortcut for
1149
+ * {@link Frame.waitForNavigation | page.mainFrame().waitForNavigation(options)}.
1150
+ */
1151
+ waitForNavigation(options?: WaitForOptions): Promise<HTTPResponse | null>;
1152
+ private _sessionClosePromise;
1153
+ /**
1154
+ * @param urlOrPredicate - A URL or predicate to wait for
1155
+ * @param options - Optional waiting parameters
1156
+ * @returns Promise which resolves to the matched response
1157
+ * @example
1158
+ * ```js
1159
+ * const firstResponse = await page.waitForResponse(
1160
+ * 'https://example.com/resource'
1161
+ * );
1162
+ * const finalResponse = await page.waitForResponse(
1163
+ * (response) =>
1164
+ * response.url() === 'https://example.com' && response.status() === 200
1165
+ * );
1166
+ * const finalResponse = await page.waitForResponse(async (response) => {
1167
+ * return (await response.text()).includes('<html>');
1168
+ * });
1169
+ * return finalResponse.ok();
1170
+ * ```
1171
+ * @remarks
1172
+ * Optional Waiting Parameters have:
1173
+ *
1174
+ * - `timeout`: Maximum wait time in milliseconds, defaults to `30` seconds, pass
1175
+ * `0` to disable the timeout. The default value can be changed by using the
1176
+ * {@link Page.setDefaultTimeout} method.
1177
+ */
1178
+ waitForRequest(urlOrPredicate: string | ((req: HTTPRequest) => boolean | Promise<boolean>), options?: {
1179
+ timeout?: number;
1180
+ }): Promise<HTTPRequest>;
1181
+ /**
1182
+ * @param urlOrPredicate - A URL or predicate to wait for.
1183
+ * @param options - Optional waiting parameters
1184
+ * @returns Promise which resolves to the matched response.
1185
+ * @example
1186
+ * ```js
1187
+ * const firstResponse = await page.waitForResponse(
1188
+ * 'https://example.com/resource'
1189
+ * );
1190
+ * const finalResponse = await page.waitForResponse(
1191
+ * (response) =>
1192
+ * response.url() === 'https://example.com' && response.status() === 200
1193
+ * );
1194
+ * const finalResponse = await page.waitForResponse(async (response) => {
1195
+ * return (await response.text()).includes('<html>');
1196
+ * });
1197
+ * return finalResponse.ok();
1198
+ * ```
1199
+ * @remarks
1200
+ * Optional Parameter have:
1201
+ *
1202
+ * - `timeout`: Maximum wait time in milliseconds, defaults to `30` seconds,
1203
+ * pass `0` to disable the timeout. The default value can be changed by using
1204
+ * the {@link Page.setDefaultTimeout} method.
1205
+ */
1206
+ waitForResponse(urlOrPredicate: string | ((res: HTTPResponse) => boolean | Promise<boolean>), options?: {
1207
+ timeout?: number;
1208
+ }): Promise<HTTPResponse>;
1209
+ /**
1210
+ * @param options - Optional waiting parameters
1211
+ * @returns Promise which resolves when network is idle
1212
+ */
1213
+ waitForNetworkIdle(options?: {
1214
+ idleTime?: number;
1215
+ timeout?: number;
1216
+ }): Promise<void>;
1217
+ /**
1218
+ * @param urlOrPredicate - A URL or predicate to wait for.
1219
+ * @param options - Optional waiting parameters
1220
+ * @returns Promise which resolves to the matched frame.
1221
+ * @example
1222
+ * ```js
1223
+ * const frame = await page.waitForFrame(async (frame) => {
1224
+ * return frame.name() === 'Test';
1225
+ * });
1226
+ * ```
1227
+ * @remarks
1228
+ * Optional Parameter have:
1229
+ *
1230
+ * - `timeout`: Maximum wait time in milliseconds, defaults to `30` seconds,
1231
+ * pass `0` to disable the timeout. The default value can be changed by using
1232
+ * the {@link Page.setDefaultTimeout} method.
1233
+ */
1234
+ waitForFrame(urlOrPredicate: string | ((frame: Frame) => boolean | Promise<boolean>), options?: {
1235
+ timeout?: number;
1236
+ }): Promise<Frame>;
1237
+ /**
1238
+ * This method navigate to the previous page in history.
1239
+ * @param options - Navigation parameters
1240
+ * @returns Promise which resolves to the main resource response. In case of
1241
+ * multiple redirects, the navigation will resolve with the response of the
1242
+ * last redirect. If can not go back, resolves to `null`.
1243
+ * @remarks
1244
+ * The argument `options` might have the following properties:
1245
+ *
1246
+ * - `timeout` : Maximum navigation time in milliseconds, defaults to 30
1247
+ * seconds, pass 0 to disable timeout. The default value can be changed by
1248
+ * using the
1249
+ * {@link Page.setDefaultNavigationTimeout
1250
+ * | page.setDefaultNavigationTimeout(timeout)}
1251
+ * or {@link Page.setDefaultTimeout | page.setDefaultTimeout(timeout)}
1252
+ * methods.
1253
+ *
1254
+ * - `waitUntil` : When to consider navigation succeeded, defaults to `load`.
1255
+ * Given an array of event strings, navigation is considered to be
1256
+ * successful after all events have been fired. Events can be either:<br/>
1257
+ * - `load` : consider navigation to be finished when the load event is fired.<br/>
1258
+ * - `domcontentloaded` : consider navigation to be finished when the
1259
+ * DOMContentLoaded event is fired.<br/>
1260
+ * - `networkidle0` : consider navigation to be finished when there are no
1261
+ * more than 0 network connections for at least `500` ms.<br/>
1262
+ * - `networkidle2` : consider navigation to be finished when there are no
1263
+ * more than 2 network connections for at least `500` ms.
1264
+ */
1265
+ goBack(options?: WaitForOptions): Promise<HTTPResponse | null>;
1266
+ /**
1267
+ * This method navigate to the next page in history.
1268
+ * @param options - Navigation Parameter
1269
+ * @returns Promise which resolves to the main resource response. In case of
1270
+ * multiple redirects, the navigation will resolve with the response of the
1271
+ * last redirect. If can not go forward, resolves to `null`.
1272
+ * @remarks
1273
+ * The argument `options` might have the following properties:
1274
+ *
1275
+ * - `timeout` : Maximum navigation time in milliseconds, defaults to 30
1276
+ * seconds, pass 0 to disable timeout. The default value can be changed by
1277
+ * using the
1278
+ * {@link Page.setDefaultNavigationTimeout
1279
+ * | page.setDefaultNavigationTimeout(timeout)}
1280
+ * or {@link Page.setDefaultTimeout | page.setDefaultTimeout(timeout)}
1281
+ * methods.
1282
+ *
1283
+ * - `waitUntil`: When to consider navigation succeeded, defaults to `load`.
1284
+ * Given an array of event strings, navigation is considered to be
1285
+ * successful after all events have been fired. Events can be either:<br/>
1286
+ * - `load` : consider navigation to be finished when the load event is fired.<br/>
1287
+ * - `domcontentloaded` : consider navigation to be finished when the
1288
+ * DOMContentLoaded event is fired.<br/>
1289
+ * - `networkidle0` : consider navigation to be finished when there are no
1290
+ * more than 0 network connections for at least `500` ms.<br/>
1291
+ * - `networkidle2` : consider navigation to be finished when there are no
1292
+ * more than 2 network connections for at least `500` ms.
1293
+ */
1294
+ goForward(options?: WaitForOptions): Promise<HTTPResponse | null>;
1295
+ private _go;
1296
+ /**
1297
+ * Brings page to front (activates tab).
1298
+ */
1299
+ bringToFront(): Promise<void>;
1300
+ /**
1301
+ * Emulates given device metrics and user agent. This method is a shortcut for
1302
+ * calling two methods: {@link Page.setUserAgent} and {@link Page.setViewport}
1303
+ * To aid emulation, Puppeteer provides a list of device descriptors that can
1304
+ * be obtained via the {@link Puppeteer.devices} `page.emulate` will resize
1305
+ * the page. A lot of websites don't expect phones to change size, so you
1306
+ * should emulate before navigating to the page.
1307
+ * @example
1308
+ * ```js
1309
+ * const puppeteer = require('puppeteer');
1310
+ * const iPhone = puppeteer.devices['iPhone 6'];
1311
+ * (async () => {
1312
+ * const browser = await puppeteer.launch();
1313
+ * const page = await browser.newPage();
1314
+ * await page.emulate(iPhone);
1315
+ * await page.goto('https://www.google.com');
1316
+ * // other actions...
1317
+ * await browser.close();
1318
+ * })();
1319
+ * ```
1320
+ * @remarks List of all available devices is available in the source code:
1321
+ * {@link https://github.com/puppeteer/puppeteer/blob/main/src/common/DeviceDescriptors.ts | src/common/DeviceDescriptors.ts}.
1322
+ */
1323
+ emulate(options: {
1324
+ viewport: Viewport;
1325
+ userAgent: string;
1326
+ }): Promise<void>;
1327
+ /**
1328
+ * @param enabled - Whether or not to enable JavaScript on the page.
1329
+ * @returns
1330
+ * @remarks
1331
+ * NOTE: changing this value won't affect scripts that have already been run.
1332
+ * It will take full effect on the next navigation.
1333
+ */
1334
+ setJavaScriptEnabled(enabled: boolean): Promise<void>;
1335
+ /**
1336
+ * Toggles bypassing page's Content-Security-Policy.
1337
+ * @param enabled - sets bypassing of page's Content-Security-Policy.
1338
+ * @remarks
1339
+ * NOTE: CSP bypassing happens at the moment of CSP initialization rather than
1340
+ * evaluation. Usually, this means that `page.setBypassCSP` should be called
1341
+ * before navigating to the domain.
1342
+ */
1343
+ setBypassCSP(enabled: boolean): Promise<void>;
1344
+ /**
1345
+ * @param type - Changes the CSS media type of the page. The only allowed
1346
+ * values are `screen`, `print` and `null`. Passing `null` disables CSS media
1347
+ * emulation.
1348
+ * @example
1349
+ * ```
1350
+ * await page.evaluate(() => matchMedia('screen').matches);
1351
+ * // true
1352
+ * await page.evaluate(() => matchMedia('print').matches);
1353
+ * // → false
1354
+ *
1355
+ * await page.emulateMediaType('print');
1356
+ * await page.evaluate(() => matchMedia('screen').matches);
1357
+ * // false
1358
+ * await page.evaluate(() => matchMedia('print').matches);
1359
+ * // true
1360
+ *
1361
+ * await page.emulateMediaType(null);
1362
+ * await page.evaluate(() => matchMedia('screen').matches);
1363
+ * // → true
1364
+ * await page.evaluate(() => matchMedia('print').matches);
1365
+ * // → false
1366
+ * ```
1367
+ */
1368
+ emulateMediaType(type?: string): Promise<void>;
1369
+ /**
1370
+ * Enables CPU throttling to emulate slow CPUs.
1371
+ * @param factor - slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).
1372
+ */
1373
+ emulateCPUThrottling(factor: number | null): Promise<void>;
1374
+ /**
1375
+ * @param features - `<?Array<Object>>` Given an array of media feature
1376
+ * objects, emulates CSS media features on the page. Each media feature object
1377
+ * must have the following properties:
1378
+ * @example
1379
+ * ```js
1380
+ * await page.emulateMediaFeatures([
1381
+ * { name: 'prefers-color-scheme', value: 'dark' },
1382
+ * ]);
1383
+ * await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches);
1384
+ * // true
1385
+ * await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches);
1386
+ * // false
1387
+ *
1388
+ * await page.emulateMediaFeatures([
1389
+ * { name: 'prefers-reduced-motion', value: 'reduce' },
1390
+ * ]);
1391
+ * await page.evaluate(
1392
+ * () => matchMedia('(prefers-reduced-motion: reduce)').matches
1393
+ * );
1394
+ * // → true
1395
+ * await page.evaluate(
1396
+ * () => matchMedia('(prefers-reduced-motion: no-preference)').matches
1397
+ * );
1398
+ * // false
1399
+ *
1400
+ * await page.emulateMediaFeatures([
1401
+ * { name: 'prefers-color-scheme', value: 'dark' },
1402
+ * { name: 'prefers-reduced-motion', value: 'reduce' },
1403
+ * ]);
1404
+ * await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches);
1405
+ * // true
1406
+ * await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches);
1407
+ * // → false
1408
+ * await page.evaluate(
1409
+ * () => matchMedia('(prefers-reduced-motion: reduce)').matches
1410
+ * );
1411
+ * // → true
1412
+ * await page.evaluate(
1413
+ * () => matchMedia('(prefers-reduced-motion: no-preference)').matches
1414
+ * );
1415
+ * // → false
1416
+ *
1417
+ * await page.emulateMediaFeatures([{ name: 'color-gamut', value: 'p3' }]);
1418
+ * await page.evaluate(() => matchMedia('(color-gamut: srgb)').matches);
1419
+ * // true
1420
+ * await page.evaluate(() => matchMedia('(color-gamut: p3)').matches);
1421
+ * // → true
1422
+ * await page.evaluate(() => matchMedia('(color-gamut: rec2020)').matches);
1423
+ * // → false
1424
+ * ```
1425
+ */
1426
+ emulateMediaFeatures(features?: MediaFeature[]): Promise<void>;
1427
+ /**
1428
+ * @param timezoneId - Changes the timezone of the page. See
1429
+ * {@link https://source.chromium.org/chromium/chromium/deps/icu.git/+/faee8bc70570192d82d2978a71e2a615788597d1:source/data/misc/metaZones.txt | ICU’s metaZones.txt}
1430
+ * for a list of supported timezone IDs. Passing
1431
+ * `null` disables timezone emulation.
1432
+ */
1433
+ emulateTimezone(timezoneId?: string): Promise<void>;
1434
+ /**
1435
+ * Emulates the idle state.
1436
+ * If no arguments set, clears idle state emulation.
1437
+ *
1438
+ * @example
1439
+ * ```js
1440
+ * // set idle emulation
1441
+ * await page.emulateIdleState({isUserActive: true, isScreenUnlocked: false});
1442
+ *
1443
+ * // do some checks here
1444
+ * ...
1445
+ *
1446
+ * // clear idle emulation
1447
+ * await page.emulateIdleState();
1448
+ * ```
1449
+ *
1450
+ * @param overrides - Mock idle state. If not set, clears idle overrides
1451
+ */
1452
+ emulateIdleState(overrides?: {
1453
+ isUserActive: boolean;
1454
+ isScreenUnlocked: boolean;
1455
+ }): Promise<void>;
1456
+ /**
1457
+ * Simulates the given vision deficiency on the page.
1458
+ *
1459
+ * @example
1460
+ * ```js
1461
+ * const puppeteer = require('puppeteer');
1462
+ *
1463
+ * (async () => {
1464
+ * const browser = await puppeteer.launch();
1465
+ * const page = await browser.newPage();
1466
+ * await page.goto('https://v8.dev/blog/10-years');
1467
+ *
1468
+ * await page.emulateVisionDeficiency('achromatopsia');
1469
+ * await page.screenshot({ path: 'achromatopsia.png' });
1470
+ *
1471
+ * await page.emulateVisionDeficiency('deuteranopia');
1472
+ * await page.screenshot({ path: 'deuteranopia.png' });
1473
+ *
1474
+ * await page.emulateVisionDeficiency('blurredVision');
1475
+ * await page.screenshot({ path: 'blurred-vision.png' });
1476
+ *
1477
+ * await browser.close();
1478
+ * })();
1479
+ * ```
1480
+ *
1481
+ * @param type - the type of deficiency to simulate, or `'none'` to reset.
1482
+ */
1483
+ emulateVisionDeficiency(type?: Protocol.Emulation.SetEmulatedVisionDeficiencyRequest['type']): Promise<void>;
1484
+ /**
1485
+ * `page.setViewport` will resize the page. A lot of websites don't expect
1486
+ * phones to change size, so you should set the viewport before navigating to
1487
+ * the page.
1488
+ *
1489
+ * In the case of multiple pages in a single browser, each page can have its
1490
+ * own viewport size.
1491
+ * @example
1492
+ * ```js
1493
+ * const page = await browser.newPage();
1494
+ * await page.setViewport({
1495
+ * width: 640,
1496
+ * height: 480,
1497
+ * deviceScaleFactor: 1,
1498
+ * });
1499
+ * await page.goto('https://example.com');
1500
+ * ```
1501
+ *
1502
+ * @param viewport -
1503
+ * @remarks
1504
+ * Argument viewport have following properties:
1505
+ *
1506
+ * - `width`: page width in pixels. required
1507
+ *
1508
+ * - `height`: page height in pixels. required
1509
+ *
1510
+ * - `deviceScaleFactor`: Specify device scale factor (can be thought of as
1511
+ * DPR). Defaults to `1`.
1512
+ *
1513
+ * - `isMobile`: Whether the meta viewport tag is taken into account. Defaults
1514
+ * to `false`.
1515
+ *
1516
+ * - `hasTouch`: Specifies if viewport supports touch events. Defaults to `false`
1517
+ *
1518
+ * - `isLandScape`: Specifies if viewport is in landscape mode. Defaults to false.
1519
+ *
1520
+ * NOTE: in certain cases, setting viewport will reload the page in order to
1521
+ * set the isMobile or hasTouch properties.
1522
+ */
1523
+ setViewport(viewport: Viewport): Promise<void>;
1524
+ /**
1525
+ * @returns
1526
+ *
1527
+ * - `width`: page's width in pixels
1528
+ *
1529
+ * - `height`: page's height in pixels
1530
+ *
1531
+ * - `deviceScalarFactor`: Specify device scale factor (can be though of as
1532
+ * dpr). Defaults to `1`.
1533
+ *
1534
+ * - `isMobile`: Whether the meta viewport tag is taken into account. Defaults
1535
+ * to `false`.
1536
+ *
1537
+ * - `hasTouch`: Specifies if viewport supports touch events. Defaults to
1538
+ * `false`.
1539
+ *
1540
+ * - `isLandScape`: Specifies if viewport is in landscape mode. Defaults to
1541
+ * `false`.
1542
+ */
1543
+ viewport(): Viewport | null;
1544
+ /**
1545
+ * @remarks
1546
+ *
1547
+ * Evaluates a function in the page's context and returns the result.
1548
+ *
1549
+ * If the function passed to `page.evaluteHandle` returns a Promise, the
1550
+ * function will wait for the promise to resolve and return its value.
1551
+ *
1552
+ * @example
1553
+ *
1554
+ * ```js
1555
+ * const result = await frame.evaluate(() => {
1556
+ * return Promise.resolve(8 * 7);
1557
+ * });
1558
+ * console.log(result); // prints "56"
1559
+ * ```
1560
+ *
1561
+ * You can pass a string instead of a function (although functions are
1562
+ * recommended as they are easier to debug and use with TypeScript):
1563
+ *
1564
+ * @example
1565
+ * ```
1566
+ * const aHandle = await page.evaluate('1 + 2');
1567
+ * ```
1568
+ *
1569
+ * To get the best TypeScript experience, you should pass in as the
1570
+ * generic the type of `pageFunction`:
1571
+ *
1572
+ * ```
1573
+ * const aHandle = await page.evaluate<() => number>(() => 2);
1574
+ * ```
1575
+ *
1576
+ * @example
1577
+ *
1578
+ * {@link ElementHandle} instances (including {@link JSHandle}s) can be passed
1579
+ * as arguments to the `pageFunction`:
1580
+ *
1581
+ * ```
1582
+ * const bodyHandle = await page.$('body');
1583
+ * const html = await page.evaluate(body => body.innerHTML, bodyHandle);
1584
+ * await bodyHandle.dispose();
1585
+ * ```
1586
+ *
1587
+ * @param pageFunction - a function that is run within the page
1588
+ * @param args - arguments to be passed to the pageFunction
1589
+ *
1590
+ * @returns the return value of `pageFunction`.
1591
+ */
1592
+ evaluate<T extends EvaluateFn>(pageFunction: T, ...args: SerializableOrJSHandle[]): Promise<UnwrapPromiseLike<EvaluateFnReturnType<T>>>;
1593
+ /**
1594
+ * Adds a function which would be invoked in one of the following scenarios:
1595
+ *
1596
+ * - whenever the page is navigated
1597
+ *
1598
+ * - whenever the child frame is attached or navigated. In this case, the
1599
+ * function is invoked in the context of the newly attached frame.
1600
+ *
1601
+ * The function is invoked after the document was created but before any of
1602
+ * its scripts were run. This is useful to amend the JavaScript environment,
1603
+ * e.g. to seed `Math.random`.
1604
+ * @param pageFunction - Function to be evaluated in browser context
1605
+ * @param args - Arguments to pass to `pageFunction`
1606
+ * @example
1607
+ * An example of overriding the navigator.languages property before the page loads:
1608
+ * ```js
1609
+ * // preload.js
1610
+ *
1611
+ * // overwrite the `languages` property to use a custom getter
1612
+ * Object.defineProperty(navigator, 'languages', {
1613
+ * get: function () {
1614
+ * return ['en-US', 'en', 'bn'];
1615
+ * },
1616
+ * });
1617
+ *
1618
+ * // In your puppeteer script, assuming the preload.js file is
1619
+ * in same folder of our script
1620
+ * const preloadFile = fs.readFileSync('./preload.js', 'utf8');
1621
+ * await page.evaluateOnNewDocument(preloadFile);
1622
+ * ```
1623
+ */
1624
+ evaluateOnNewDocument(pageFunction: Function | string, ...args: unknown[]): Promise<void>;
1625
+ /**
1626
+ * Toggles ignoring cache for each request based on the enabled state. By
1627
+ * default, caching is enabled.
1628
+ * @param enabled - sets the `enabled` state of cache
1629
+ */
1630
+ setCacheEnabled(enabled?: boolean): Promise<void>;
1631
+ /**
1632
+ * @remarks
1633
+ * Options object which might have the following properties:
1634
+ *
1635
+ * - `path` : The file path to save the image to. The screenshot type
1636
+ * will be inferred from file extension. If `path` is a relative path, then
1637
+ * it is resolved relative to
1638
+ * {@link https://nodejs.org/api/process.html#process_process_cwd
1639
+ * | current working directory}.
1640
+ * If no path is provided, the image won't be saved to the disk.
1641
+ *
1642
+ * - `type` : Specify screenshot type, can be either `jpeg` or `png`.
1643
+ * Defaults to 'png'.
1644
+ *
1645
+ * - `quality` : The quality of the image, between 0-100. Not
1646
+ * applicable to `png` images.
1647
+ *
1648
+ * - `fullPage` : When true, takes a screenshot of the full
1649
+ * scrollable page. Defaults to `false`
1650
+ *
1651
+ * - `clip` : An object which specifies clipping region of the page.
1652
+ * Should have the following fields:<br/>
1653
+ * - `x` : x-coordinate of top-left corner of clip area.<br/>
1654
+ * - `y` : y-coordinate of top-left corner of clip area.<br/>
1655
+ * - `width` : width of clipping area.<br/>
1656
+ * - `height` : height of clipping area.
1657
+ *
1658
+ * - `omitBackground` : Hides default white background and allows
1659
+ * capturing screenshots with transparency. Defaults to `false`
1660
+ *
1661
+ * - `encoding` : The encoding of the image, can be either base64 or
1662
+ * binary. Defaults to `binary`.
1663
+ *
1664
+ *
1665
+ * NOTE: Screenshots take at least 1/6 second on OS X. See
1666
+ * {@link https://crbug.com/741689} for discussion.
1667
+ * @returns Promise which resolves to buffer or a base64 string (depending on
1668
+ * the value of `encoding`) with captured screenshot.
1669
+ */
1670
+ screenshot(options?: ScreenshotOptions): Promise<Buffer | string>;
1671
+ private _screenshotTask;
1672
+ /**
1673
+ * Generatees a PDF of the page with the `print` CSS media type.
1674
+ * @remarks
1675
+ *
1676
+ * NOTE: PDF generation is only supported in Chrome headless mode.
1677
+ *
1678
+ * To generate a PDF with the `screen` media type, call
1679
+ * {@link Page.emulateMediaType | `page.emulateMediaType('screen')`} before
1680
+ * calling `page.pdf()`.
1681
+ *
1682
+ * By default, `page.pdf()` generates a pdf with modified colors for printing.
1683
+ * Use the
1684
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-print-color-adjust | `-webkit-print-color-adjust`}
1685
+ * property to force rendering of exact colors.
1686
+ *
1687
+ *
1688
+ * @param options - options for generating the PDF.
1689
+ */
1690
+ createPDFStream(options?: PDFOptions): Promise<Readable>;
1691
+ /**
1692
+ * @param options -
1693
+ * @returns
1694
+ */
1695
+ pdf(options?: PDFOptions): Promise<Buffer>;
1696
+ /**
1697
+ * @returns The page's title
1698
+ * @remarks
1699
+ * Shortcut for {@link Frame.title | page.mainFrame().title()}.
1700
+ */
1701
+ title(): Promise<string>;
1702
+ close(options?: {
1703
+ runBeforeUnload?: boolean;
1704
+ }): Promise<void>;
1705
+ /**
1706
+ * Indicates that the page has been closed.
1707
+ * @returns
1708
+ */
1709
+ isClosed(): boolean;
1710
+ get mouse(): Mouse;
1711
+ /**
1712
+ * This method fetches an element with `selector`, scrolls it into view if
1713
+ * needed, and then uses {@link Page.mouse} to click in the center of the
1714
+ * element. If there's no element matching `selector`, the method throws an
1715
+ * error.
1716
+ * @remarks Bear in mind that if `click()` triggers a navigation event and
1717
+ * there's a separate `page.waitForNavigation()` promise to be resolved, you
1718
+ * may end up with a race condition that yields unexpected results. The
1719
+ * correct pattern for click and wait for navigation is the following:
1720
+ * ```js
1721
+ * const [response] = await Promise.all([
1722
+ * page.waitForNavigation(waitOptions),
1723
+ * page.click(selector, clickOptions),
1724
+ * ]);
1725
+ * ```
1726
+ * Shortcut for {@link Frame.click | page.mainFrame().click(selector[, options]) }.
1727
+ * @param selector - A `selector` to search for element to click. If there are
1728
+ * multiple elements satisfying the `selector`, the first will be clicked
1729
+ * @param options - `Object`
1730
+ * @returns Promise which resolves when the element matching `selector` is
1731
+ * successfully clicked. The Promise will be rejected if there is no element
1732
+ * matching `selector`.
1733
+ */
1734
+ click(selector: string, options?: {
1735
+ delay?: number;
1736
+ button?: MouseButton;
1737
+ clickCount?: number;
1738
+ }): Promise<void>;
1739
+ /**
1740
+ * This method fetches an element with `selector` and focuses it. If there's no
1741
+ * element matching `selector`, the method throws an error.
1742
+ * @param selector - A
1743
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | selector }
1744
+ * of an element to focus. If there are multiple elements satisfying the
1745
+ * selector, the first will be focused.
1746
+ * @returns Promise which resolves when the element matching selector is
1747
+ * successfully focused. The promise will be rejected if there is no element
1748
+ * matching selector.
1749
+ * @remarks
1750
+ * Shortcut for {@link Frame.focus | page.mainFrame().focus(selector)}.
1751
+ */
1752
+ focus(selector: string): Promise<void>;
1753
+ /**
1754
+ * This method fetches an element with `selector`, scrolls it into view if
1755
+ * needed, and then uses {@link Page.mouse} to hover over the center of the element.
1756
+ * If there's no element matching `selector`, the method throws an error.
1757
+ * @param selector - A
1758
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | selector}
1759
+ * to search for element to hover. If there are multiple elements satisfying
1760
+ * the selector, the first will be hovered.
1761
+ * @returns Promise which resolves when the element matching `selector` is
1762
+ * successfully hovered. Promise gets rejected if there's no element matching
1763
+ * `selector`.
1764
+ * @remarks
1765
+ * Shortcut for {@link Page.hover | page.mainFrame().hover(selector)}.
1766
+ */
1767
+ hover(selector: string): Promise<void>;
1768
+ /**
1769
+ * Triggers a `change` and `input` event once all the provided options have been
1770
+ * selected. If there's no `<select>` element matching `selector`, the method
1771
+ * throws an error.
1772
+ *
1773
+ * @example
1774
+ * ```js
1775
+ * page.select('select#colors', 'blue'); // single selection
1776
+ * page.select('select#colors', 'red', 'green', 'blue'); // multiple selections
1777
+ * ```
1778
+ * @param selector - A
1779
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | Selector}
1780
+ * to query the page for
1781
+ * @param values - Values of options to select. If the `<select>` has the
1782
+ * `multiple` attribute, all values are considered, otherwise only the first one
1783
+ * is taken into account.
1784
+ * @returns
1785
+ *
1786
+ * @remarks
1787
+ * Shortcut for {@link Frame.select | page.mainFrame().select()}
1788
+ */
1789
+ select(selector: string, ...values: string[]): Promise<string[]>;
1790
+ /**
1791
+ * This method fetches an element with `selector`, scrolls it into view if
1792
+ * needed, and then uses {@link Page.touchscreen} to tap in the center of the element.
1793
+ * If there's no element matching `selector`, the method throws an error.
1794
+ * @param selector - A
1795
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | Selector}
1796
+ * to search for element to tap. If there are multiple elements satisfying the
1797
+ * selector, the first will be tapped.
1798
+ * @returns
1799
+ * @remarks
1800
+ * Shortcut for {@link Frame.tap | page.mainFrame().tap(selector)}.
1801
+ */
1802
+ tap(selector: string): Promise<void>;
1803
+ /**
1804
+ * Sends a `keydown`, `keypress/input`, and `keyup` event for each character
1805
+ * in the text.
1806
+ *
1807
+ * To press a special key, like `Control` or `ArrowDown`, use {@link Keyboard.press}.
1808
+ * @example
1809
+ * ```
1810
+ * await page.type('#mytextarea', 'Hello');
1811
+ * // Types instantly
1812
+ * await page.type('#mytextarea', 'World', { delay: 100 });
1813
+ * // Types slower, like a user
1814
+ * ```
1815
+ * @param selector - A
1816
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | selector}
1817
+ * of an element to type into. If there are multiple elements satisfying the
1818
+ * selector, the first will be used.
1819
+ * @param text - A text to type into a focused element.
1820
+ * @param options - have property `delay` which is the Time to wait between
1821
+ * key presses in milliseconds. Defaults to `0`.
1822
+ * @returns
1823
+ * @remarks
1824
+ */
1825
+ type(selector: string, text: string, options?: {
1826
+ delay: number;
1827
+ }): Promise<void>;
1828
+ /**
1829
+ * @remarks
1830
+ *
1831
+ * This method behaves differently depending on the first parameter. If it's a
1832
+ * `string`, it will be treated as a `selector` or `xpath` (if the string
1833
+ * starts with `//`). This method then is a shortcut for
1834
+ * {@link Page.waitForSelector} or {@link Page.waitForXPath}.
1835
+ *
1836
+ * If the first argument is a function this method is a shortcut for
1837
+ * {@link Page.waitForFunction}.
1838
+ *
1839
+ * If the first argument is a `number`, it's treated as a timeout in
1840
+ * milliseconds and the method returns a promise which resolves after the
1841
+ * timeout.
1842
+ *
1843
+ * @param selectorOrFunctionOrTimeout - a selector, predicate or timeout to
1844
+ * wait for.
1845
+ * @param options - optional waiting parameters.
1846
+ * @param args - arguments to pass to `pageFunction`.
1847
+ *
1848
+ * @deprecated Don't use this method directly. Instead use the more explicit
1849
+ * methods available: {@link Page.waitForSelector},
1850
+ * {@link Page.waitForXPath}, {@link Page.waitForFunction} or
1851
+ * {@link Page.waitForTimeout}.
1852
+ */
1853
+ waitFor(selectorOrFunctionOrTimeout: string | number | Function, options?: {
1854
+ visible?: boolean;
1855
+ hidden?: boolean;
1856
+ timeout?: number;
1857
+ polling?: string | number;
1858
+ }, ...args: SerializableOrJSHandle[]): Promise<JSHandle>;
1859
+ /**
1860
+ * Causes your script to wait for the given number of milliseconds.
1861
+ *
1862
+ * @remarks
1863
+ *
1864
+ * It's generally recommended to not wait for a number of seconds, but instead
1865
+ * use {@link Page.waitForSelector}, {@link Page.waitForXPath} or
1866
+ * {@link Page.waitForFunction} to wait for exactly the conditions you want.
1867
+ *
1868
+ * @example
1869
+ *
1870
+ * Wait for 1 second:
1871
+ *
1872
+ * ```
1873
+ * await page.waitForTimeout(1000);
1874
+ * ```
1875
+ *
1876
+ * @param milliseconds - the number of milliseconds to wait.
1877
+ */
1878
+ waitForTimeout(milliseconds: number): Promise<void>;
1879
+ /**
1880
+ * Wait for the `selector` to appear in page. If at the moment of calling the
1881
+ * method the `selector` already exists, the method will return immediately. If
1882
+ * the `selector` doesn't appear after the `timeout` milliseconds of waiting, the
1883
+ * function will throw.
1884
+ *
1885
+ * This method works across navigations:
1886
+ * ```js
1887
+ * const puppeteer = require('puppeteer');
1888
+ * (async () => {
1889
+ * const browser = await puppeteer.launch();
1890
+ * const page = await browser.newPage();
1891
+ * let currentURL;
1892
+ * page
1893
+ * .waitForSelector('img')
1894
+ * .then(() => console.log('First URL with image: ' + currentURL));
1895
+ * for (currentURL of [
1896
+ * 'https://example.com',
1897
+ * 'https://google.com',
1898
+ * 'https://bbc.com',
1899
+ * ]) {
1900
+ * await page.goto(currentURL);
1901
+ * }
1902
+ * await browser.close();
1903
+ * })();
1904
+ * ```
1905
+ * @param selector - A
1906
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | selector}
1907
+ * of an element to wait for
1908
+ * @param options - Optional waiting parameters
1909
+ * @returns Promise which resolves when element specified by selector string
1910
+ * is added to DOM. Resolves to `null` if waiting for hidden: `true` and
1911
+ * selector is not found in DOM.
1912
+ * @remarks
1913
+ * The optional Parameter in Arguments `options` are :
1914
+ *
1915
+ * - `Visible`: A boolean wait for element to be present in DOM and to be
1916
+ * visible, i.e. to not have `display: none` or `visibility: hidden` CSS
1917
+ * properties. Defaults to `false`.
1918
+ *
1919
+ * - `hidden`: ait for element to not be found in the DOM or to be hidden,
1920
+ * i.e. have `display: none` or `visibility: hidden` CSS properties. Defaults to
1921
+ * `false`.
1922
+ *
1923
+ * - `timeout`: maximum time to wait for in milliseconds. Defaults to `30000`
1924
+ * (30 seconds). Pass `0` to disable timeout. The default value can be changed
1925
+ * by using the {@link Page.setDefaultTimeout} method.
1926
+ */
1927
+ waitForSelector(selector: string, options?: {
1928
+ visible?: boolean;
1929
+ hidden?: boolean;
1930
+ timeout?: number;
1931
+ }): Promise<ElementHandle | null>;
1932
+ /**
1933
+ * Wait for the `xpath` to appear in page. If at the moment of calling the
1934
+ * method the `xpath` already exists, the method will return immediately. If
1935
+ * the `xpath` doesn't appear after the `timeout` milliseconds of waiting, the
1936
+ * function will throw.
1937
+ *
1938
+ * This method works across navigation
1939
+ * ```js
1940
+ * const puppeteer = require('puppeteer');
1941
+ * (async () => {
1942
+ * const browser = await puppeteer.launch();
1943
+ * const page = await browser.newPage();
1944
+ * let currentURL;
1945
+ * page
1946
+ * .waitForXPath('//img')
1947
+ * .then(() => console.log('First URL with image: ' + currentURL));
1948
+ * for (currentURL of [
1949
+ * 'https://example.com',
1950
+ * 'https://google.com',
1951
+ * 'https://bbc.com',
1952
+ * ]) {
1953
+ * await page.goto(currentURL);
1954
+ * }
1955
+ * await browser.close();
1956
+ * })();
1957
+ * ```
1958
+ * @param xpath - A
1959
+ * {@link https://developer.mozilla.org/en-US/docs/Web/XPath | xpath} of an
1960
+ * element to wait for
1961
+ * @param options - Optional waiting parameters
1962
+ * @returns Promise which resolves when element specified by xpath string is
1963
+ * added to DOM. Resolves to `null` if waiting for `hidden: true` and xpath is
1964
+ * not found in DOM.
1965
+ * @remarks
1966
+ * The optional Argument `options` have properties:
1967
+ *
1968
+ * - `visible`: A boolean to wait for element to be present in DOM and to be
1969
+ * visible, i.e. to not have `display: none` or `visibility: hidden` CSS
1970
+ * properties. Defaults to `false`.
1971
+ *
1972
+ * - `hidden`: A boolean wait for element to not be found in the DOM or to be
1973
+ * hidden, i.e. have `display: none` or `visibility: hidden` CSS properties.
1974
+ * Defaults to `false`.
1975
+ *
1976
+ * - `timeout`: A number which is maximum time to wait for in milliseconds.
1977
+ * Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default
1978
+ * value can be changed by using the {@link Page.setDefaultTimeout} method.
1979
+ */
1980
+ waitForXPath(xpath: string, options?: {
1981
+ visible?: boolean;
1982
+ hidden?: boolean;
1983
+ timeout?: number;
1984
+ }): Promise<ElementHandle | null>;
1985
+ /**
1986
+ * The `waitForFunction` can be used to observe viewport size change:
1987
+ *
1988
+ * ```
1989
+ * const puppeteer = require('puppeteer');
1990
+ * (async () => {
1991
+ * const browser = await puppeteer.launch();
1992
+ * const page = await browser.newPage();
1993
+ * const watchDog = page.waitForFunction('window.innerWidth < 100');
1994
+ * await page.setViewport({ width: 50, height: 50 });
1995
+ * await watchDog;
1996
+ * await browser.close();
1997
+ * })();
1998
+ * ```
1999
+ * To pass arguments from node.js to the predicate of `page.waitForFunction` function:
2000
+ * ```
2001
+ * const selector = '.foo';
2002
+ * await page.waitForFunction(
2003
+ * (selector) => !!document.querySelector(selector),
2004
+ * {},
2005
+ * selector
2006
+ * );
2007
+ * ```
2008
+ * The predicate of `page.waitForFunction` can be asynchronous too:
2009
+ * ```
2010
+ * const username = 'github-username';
2011
+ * await page.waitForFunction(
2012
+ * async (username) => {
2013
+ * const githubResponse = await fetch(
2014
+ * `https://api.github.com/users/${username}`
2015
+ * );
2016
+ * const githubUser = await githubResponse.json();
2017
+ * // show the avatar
2018
+ * const img = document.createElement('img');
2019
+ * img.src = githubUser.avatar_url;
2020
+ * // wait 3 seconds
2021
+ * await new Promise((resolve, reject) => setTimeout(resolve, 3000));
2022
+ * img.remove();
2023
+ * },
2024
+ * {},
2025
+ * username
2026
+ * );
2027
+ * ```
2028
+ * @param pageFunction - Function to be evaluated in browser context
2029
+ * @param options - Optional waiting parameters
2030
+ * @param args - Arguments to pass to `pageFunction`
2031
+ * @returns Promise which resolves when the `pageFunction` returns a truthy
2032
+ * value. It resolves to a JSHandle of the truthy value.
2033
+ *
2034
+ * The optional waiting parameter can be:
2035
+ *
2036
+ * - `Polling`: An interval at which the `pageFunction` is executed, defaults to
2037
+ * `raf`. If `polling` is a number, then it is treated as an interval in
2038
+ * milliseconds at which the function would be executed. If polling is a
2039
+ * string, then it can be one of the following values:<br/>
2040
+ * - `raf`: to constantly execute `pageFunction` in `requestAnimationFrame`
2041
+ * callback. This is the tightest polling mode which is suitable to
2042
+ * observe styling changes.<br/>
2043
+ * - `mutation`: to execute pageFunction on every DOM mutation.
2044
+ *
2045
+ * - `timeout`: maximum time to wait for in milliseconds. Defaults to `30000`
2046
+ * (30 seconds). Pass `0` to disable timeout. The default value can be changed
2047
+ * by using the
2048
+ * {@link Page.setDefaultTimeout | page.setDefaultTimeout(timeout)} method.
2049
+ *
2050
+ */
2051
+ waitForFunction(pageFunction: Function | string, options?: {
2052
+ timeout?: number;
2053
+ polling?: string | number;
2054
+ }, ...args: SerializableOrJSHandle[]): Promise<JSHandle>;
2055
+ }
2011
2056
  //# sourceMappingURL=Page.d.ts.map