webdriverio 7.17.0 → 7.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (358) hide show
  1. package/build/commands/browser/$$.d.ts +50 -0
  2. package/build/commands/browser/$$.d.ts.map +1 -0
  3. package/build/commands/browser/$$.js +57 -0
  4. package/build/commands/browser/$.d.ts +77 -0
  5. package/build/commands/browser/$.d.ts.map +1 -0
  6. package/build/commands/browser/$.js +91 -0
  7. package/build/commands/browser/addCommand.d.ts +37 -0
  8. package/build/commands/browser/addCommand.d.ts.map +1 -0
  9. package/build/commands/browser/addCommand.js +37 -0
  10. package/build/commands/browser/call.d.ts +42 -0
  11. package/build/commands/browser/call.d.ts.map +1 -0
  12. package/build/commands/browser/call.js +49 -0
  13. package/build/commands/browser/custom$$.d.ts +26 -0
  14. package/build/commands/browser/custom$$.d.ts.map +1 -0
  15. package/build/commands/browser/custom$$.js +47 -0
  16. package/build/commands/browser/custom$.d.ts +25 -0
  17. package/build/commands/browser/custom$.d.ts.map +1 -0
  18. package/build/commands/browser/custom$.js +47 -0
  19. package/build/commands/browser/debug.d.ts +32 -0
  20. package/build/commands/browser/debug.d.ts.map +1 -0
  21. package/build/commands/browser/debug.js +108 -0
  22. package/build/commands/browser/deleteCookies.d.ts +45 -0
  23. package/build/commands/browser/deleteCookies.d.ts.map +1 -0
  24. package/build/commands/browser/deleteCookies.js +56 -0
  25. package/build/commands/browser/execute.d.ts +37 -0
  26. package/build/commands/browser/execute.d.ts.map +1 -0
  27. package/build/commands/browser/execute.js +55 -0
  28. package/build/commands/browser/executeAsync.d.ts +45 -0
  29. package/build/commands/browser/executeAsync.d.ts.map +1 -0
  30. package/build/commands/browser/executeAsync.js +63 -0
  31. package/build/commands/browser/getCookies.d.ts +34 -0
  32. package/build/commands/browser/getCookies.d.ts.map +1 -0
  33. package/build/commands/browser/getCookies.js +46 -0
  34. package/build/commands/browser/getPuppeteer.d.ts +38 -0
  35. package/build/commands/browser/getPuppeteer.d.ts.map +1 -0
  36. package/build/commands/browser/getPuppeteer.js +119 -0
  37. package/build/commands/browser/getWindowSize.d.ts +25 -0
  38. package/build/commands/browser/getWindowSize.d.ts.map +1 -0
  39. package/build/commands/browser/getWindowSize.js +30 -0
  40. package/build/commands/browser/keys.d.ts +28 -0
  41. package/build/commands/browser/keys.d.ts.map +1 -0
  42. package/build/commands/browser/keys.js +64 -0
  43. package/build/commands/browser/mock.d.ts +111 -0
  44. package/build/commands/browser/mock.d.ts.map +1 -0
  45. package/build/commands/browser/mock.js +164 -0
  46. package/build/commands/browser/mockClearAll.d.ts +28 -0
  47. package/build/commands/browser/mockClearAll.d.ts.map +1 -0
  48. package/build/commands/browser/mockClearAll.js +43 -0
  49. package/build/commands/browser/mockRestoreAll.d.ts +26 -0
  50. package/build/commands/browser/mockRestoreAll.d.ts.map +1 -0
  51. package/build/commands/browser/mockRestoreAll.js +41 -0
  52. package/build/commands/browser/newWindow.d.ts +41 -0
  53. package/build/commands/browser/newWindow.d.ts.map +1 -0
  54. package/build/commands/browser/newWindow.js +83 -0
  55. package/build/commands/browser/overwriteCommand.d.ts +32 -0
  56. package/build/commands/browser/overwriteCommand.d.ts.map +1 -0
  57. package/build/commands/browser/overwriteCommand.js +32 -0
  58. package/build/commands/browser/pause.d.ts +23 -0
  59. package/build/commands/browser/pause.d.ts.map +1 -0
  60. package/build/commands/browser/pause.js +27 -0
  61. package/build/commands/browser/react$$.d.ts +36 -0
  62. package/build/commands/browser/react$$.d.ts.map +1 -0
  63. package/build/commands/browser/react$$.js +51 -0
  64. package/build/commands/browser/react$.d.ts +46 -0
  65. package/build/commands/browser/react$.d.ts.map +1 -0
  66. package/build/commands/browser/react$.js +59 -0
  67. package/build/commands/browser/reloadSession.d.ts +23 -0
  68. package/build/commands/browser/reloadSession.d.ts.map +1 -0
  69. package/build/commands/browser/reloadSession.js +58 -0
  70. package/build/commands/browser/savePDF.d.ts +46 -0
  71. package/build/commands/browser/savePDF.d.ts.map +1 -0
  72. package/build/commands/browser/savePDF.js +51 -0
  73. package/build/commands/browser/saveRecordingScreen.d.ts +28 -0
  74. package/build/commands/browser/saveRecordingScreen.d.ts.map +1 -0
  75. package/build/commands/browser/saveRecordingScreen.js +47 -0
  76. package/build/commands/browser/saveScreenshot.d.ts +22 -0
  77. package/build/commands/browser/saveScreenshot.d.ts.map +1 -0
  78. package/build/commands/browser/saveScreenshot.js +41 -0
  79. package/build/commands/browser/setCookies.d.ts +57 -0
  80. package/build/commands/browser/setCookies.d.ts.map +1 -0
  81. package/build/commands/browser/setCookies.js +66 -0
  82. package/build/commands/browser/setTimeout.d.ts +31 -0
  83. package/build/commands/browser/setTimeout.d.ts.map +1 -0
  84. package/build/commands/browser/setTimeout.js +61 -0
  85. package/build/commands/browser/setWindowSize.d.ts +20 -0
  86. package/build/commands/browser/setWindowSize.d.ts.map +1 -0
  87. package/build/commands/browser/setWindowSize.js +43 -0
  88. package/build/commands/browser/switchWindow.d.ts +30 -0
  89. package/build/commands/browser/switchWindow.d.ts.map +1 -0
  90. package/build/commands/browser/switchWindow.js +73 -0
  91. package/build/commands/browser/throttle.d.ts +3 -0
  92. package/build/commands/browser/throttle.d.ts.map +1 -0
  93. package/build/commands/browser/throttle.js +144 -0
  94. package/build/commands/browser/touchAction.d.ts +61 -0
  95. package/build/commands/browser/touchAction.d.ts.map +1 -0
  96. package/build/commands/browser/touchAction.js +65 -0
  97. package/build/commands/browser/uploadFile.d.ts +32 -0
  98. package/build/commands/browser/uploadFile.d.ts.map +1 -0
  99. package/build/commands/browser/uploadFile.js +63 -0
  100. package/build/commands/browser/url.d.ts +38 -0
  101. package/build/commands/browser/url.d.ts.map +1 -0
  102. package/build/commands/browser/url.js +49 -0
  103. package/build/commands/browser/waitUntil.d.ts +44 -0
  104. package/build/commands/browser/waitUntil.d.ts.map +1 -0
  105. package/build/commands/browser/waitUntil.js +73 -0
  106. package/build/commands/browser.d.ts +70 -0
  107. package/build/commands/browser.d.ts.map +1 -0
  108. package/build/commands/browser.js +44 -0
  109. package/build/commands/constant.d.ts +19 -0
  110. package/build/commands/constant.d.ts.map +1 -0
  111. package/build/commands/constant.js +91 -0
  112. package/build/commands/element/$$.d.ts +46 -0
  113. package/build/commands/element/$$.d.ts.map +1 -0
  114. package/build/commands/element/$$.js +50 -0
  115. package/build/commands/element/$.d.ts +72 -0
  116. package/build/commands/element/$.d.ts.map +1 -0
  117. package/build/commands/element/$.js +76 -0
  118. package/build/commands/element/addValue.d.ts +33 -0
  119. package/build/commands/element/addValue.d.ts.map +1 -0
  120. package/build/commands/element/addValue.js +48 -0
  121. package/build/commands/element/clearValue.d.ts +28 -0
  122. package/build/commands/element/clearValue.d.ts.map +1 -0
  123. package/build/commands/element/clearValue.js +32 -0
  124. package/build/commands/element/click.d.ts +73 -0
  125. package/build/commands/element/click.d.ts.map +1 -0
  126. package/build/commands/element/click.js +134 -0
  127. package/build/commands/element/custom$$.d.ts +28 -0
  128. package/build/commands/element/custom$$.d.ts.map +1 -0
  129. package/build/commands/element/custom$$.js +57 -0
  130. package/build/commands/element/custom$.d.ts +27 -0
  131. package/build/commands/element/custom$.d.ts.map +1 -0
  132. package/build/commands/element/custom$.js +57 -0
  133. package/build/commands/element/doubleClick.d.ts +25 -0
  134. package/build/commands/element/doubleClick.d.ts.map +1 -0
  135. package/build/commands/element/doubleClick.js +51 -0
  136. package/build/commands/element/dragAndDrop.d.ts +41 -0
  137. package/build/commands/element/dragAndDrop.d.ts.map +1 -0
  138. package/build/commands/element/dragAndDrop.js +98 -0
  139. package/build/commands/element/getAttribute.d.ts +28 -0
  140. package/build/commands/element/getAttribute.d.ts.map +1 -0
  141. package/build/commands/element/getAttribute.js +32 -0
  142. package/build/commands/element/getCSSProperty.d.ts +71 -0
  143. package/build/commands/element/getCSSProperty.d.ts.map +1 -0
  144. package/build/commands/element/getCSSProperty.js +108 -0
  145. package/build/commands/element/getComputedLabel.d.ts +20 -0
  146. package/build/commands/element/getComputedLabel.d.ts.map +1 -0
  147. package/build/commands/element/getComputedLabel.js +24 -0
  148. package/build/commands/element/getComputedRole.d.ts +20 -0
  149. package/build/commands/element/getComputedRole.d.ts.map +1 -0
  150. package/build/commands/element/getComputedRole.js +24 -0
  151. package/build/commands/element/getHTML.d.ts +32 -0
  152. package/build/commands/element/getHTML.d.ts.map +1 -0
  153. package/build/commands/element/getHTML.js +46 -0
  154. package/build/commands/element/getLocation.d.ts +6 -0
  155. package/build/commands/element/getLocation.d.ts.map +1 -0
  156. package/build/commands/element/getLocation.js +46 -0
  157. package/build/commands/element/getProperty.d.ts +53 -0
  158. package/build/commands/element/getProperty.d.ts.map +1 -0
  159. package/build/commands/element/getProperty.js +31 -0
  160. package/build/commands/element/getSize.d.ts +6 -0
  161. package/build/commands/element/getSize.d.ts.map +1 -0
  162. package/build/commands/element/getSize.js +47 -0
  163. package/build/commands/element/getTagName.d.ts +25 -0
  164. package/build/commands/element/getTagName.d.ts.map +1 -0
  165. package/build/commands/element/getTagName.js +29 -0
  166. package/build/commands/element/getText.d.ts +42 -0
  167. package/build/commands/element/getText.d.ts.map +1 -0
  168. package/build/commands/element/getText.js +46 -0
  169. package/build/commands/element/getValue.d.ts +25 -0
  170. package/build/commands/element/getValue.d.ts.map +1 -0
  171. package/build/commands/element/getValue.js +33 -0
  172. package/build/commands/element/isClickable.d.ts +40 -0
  173. package/build/commands/element/isClickable.d.ts.map +1 -0
  174. package/build/commands/element/isClickable.js +57 -0
  175. package/build/commands/element/isDisplayed.d.ts +50 -0
  176. package/build/commands/element/isDisplayed.d.ts.map +1 -0
  177. package/build/commands/element/isDisplayed.js +85 -0
  178. package/build/commands/element/isDisplayedInViewport.d.ts +38 -0
  179. package/build/commands/element/isDisplayedInViewport.d.ts.map +1 -0
  180. package/build/commands/element/isDisplayedInViewport.js +55 -0
  181. package/build/commands/element/isEnabled.d.ts +34 -0
  182. package/build/commands/element/isEnabled.d.ts.map +1 -0
  183. package/build/commands/element/isEnabled.js +38 -0
  184. package/build/commands/element/isEqual.d.ts +24 -0
  185. package/build/commands/element/isEqual.d.ts.map +1 -0
  186. package/build/commands/element/isEqual.js +52 -0
  187. package/build/commands/element/isExisting.d.ts +49 -0
  188. package/build/commands/element/isExisting.d.ts.map +1 -0
  189. package/build/commands/element/isExisting.js +65 -0
  190. package/build/commands/element/isFocused.d.ts +28 -0
  191. package/build/commands/element/isFocused.d.ts.map +1 -0
  192. package/build/commands/element/isFocused.js +42 -0
  193. package/build/commands/element/isSelected.d.ts +31 -0
  194. package/build/commands/element/isSelected.d.ts.map +1 -0
  195. package/build/commands/element/isSelected.js +35 -0
  196. package/build/commands/element/moveTo.d.ts +21 -0
  197. package/build/commands/element/moveTo.d.ts.map +1 -0
  198. package/build/commands/element/moveTo.js +39 -0
  199. package/build/commands/element/nextElement.d.ts +25 -0
  200. package/build/commands/element/nextElement.d.ts.map +1 -0
  201. package/build/commands/element/nextElement.js +31 -0
  202. package/build/commands/element/parentElement.d.ts +25 -0
  203. package/build/commands/element/parentElement.d.ts.map +1 -0
  204. package/build/commands/element/parentElement.js +31 -0
  205. package/build/commands/element/previousElement.d.ts +25 -0
  206. package/build/commands/element/previousElement.d.ts.map +1 -0
  207. package/build/commands/element/previousElement.js +31 -0
  208. package/build/commands/element/react$$.d.ts +36 -0
  209. package/build/commands/element/react$$.d.ts.map +1 -0
  210. package/build/commands/element/react$$.js +51 -0
  211. package/build/commands/element/react$.d.ts +46 -0
  212. package/build/commands/element/react$.d.ts.map +1 -0
  213. package/build/commands/element/react$.js +59 -0
  214. package/build/commands/element/saveScreenshot.d.ts +21 -0
  215. package/build/commands/element/saveScreenshot.d.ts.map +1 -0
  216. package/build/commands/element/saveScreenshot.js +40 -0
  217. package/build/commands/element/scrollIntoView.d.ts +21 -0
  218. package/build/commands/element/scrollIntoView.d.ts.map +1 -0
  219. package/build/commands/element/scrollIntoView.js +31 -0
  220. package/build/commands/element/selectByAttribute.d.ts +37 -0
  221. package/build/commands/element/selectByAttribute.d.ts.map +1 -0
  222. package/build/commands/element/selectByAttribute.js +59 -0
  223. package/build/commands/element/selectByIndex.d.ts +31 -0
  224. package/build/commands/element/selectByIndex.d.ts.map +1 -0
  225. package/build/commands/element/selectByIndex.js +55 -0
  226. package/build/commands/element/selectByVisibleText.d.ts +31 -0
  227. package/build/commands/element/selectByVisibleText.d.ts.map +1 -0
  228. package/build/commands/element/selectByVisibleText.js +66 -0
  229. package/build/commands/element/setValue.d.ts +29 -0
  230. package/build/commands/element/setValue.d.ts.map +1 -0
  231. package/build/commands/element/setValue.js +33 -0
  232. package/build/commands/element/shadow$$.d.ts +22 -0
  233. package/build/commands/element/shadow$$.d.ts.map +1 -0
  234. package/build/commands/element/shadow$$.js +27 -0
  235. package/build/commands/element/shadow$.d.ts +22 -0
  236. package/build/commands/element/shadow$.d.ts.map +1 -0
  237. package/build/commands/element/shadow$.js +27 -0
  238. package/build/commands/element/touchAction.d.ts +54 -0
  239. package/build/commands/element/touchAction.d.ts.map +1 -0
  240. package/build/commands/element/touchAction.js +58 -0
  241. package/build/commands/element/waitForClickable.d.ts +34 -0
  242. package/build/commands/element/waitForClickable.d.ts.map +1 -0
  243. package/build/commands/element/waitForClickable.js +37 -0
  244. package/build/commands/element/waitForDisplayed.d.ts +44 -0
  245. package/build/commands/element/waitForDisplayed.d.ts.map +1 -0
  246. package/build/commands/element/waitForDisplayed.js +47 -0
  247. package/build/commands/element/waitForEnabled.d.ts +46 -0
  248. package/build/commands/element/waitForEnabled.d.ts.map +1 -0
  249. package/build/commands/element/waitForEnabled.js +55 -0
  250. package/build/commands/element/waitForExist.d.ts +46 -0
  251. package/build/commands/element/waitForExist.d.ts.map +1 -0
  252. package/build/commands/element/waitForExist.js +49 -0
  253. package/build/commands/element/waitUntil.d.ts +49 -0
  254. package/build/commands/element/waitUntil.d.ts.map +1 -0
  255. package/build/commands/element/waitUntil.js +53 -0
  256. package/build/commands/element.d.ts +100 -0
  257. package/build/commands/element.d.ts.map +1 -0
  258. package/build/commands/element.js +63 -0
  259. package/build/commands/mock/abort.d.ts +19 -0
  260. package/build/commands/mock/abort.d.ts.map +1 -0
  261. package/build/commands/mock/abort.js +20 -0
  262. package/build/commands/mock/abortOnce.d.ts +27 -0
  263. package/build/commands/mock/abortOnce.d.ts.map +1 -0
  264. package/build/commands/mock/abortOnce.js +28 -0
  265. package/build/commands/mock/clear.d.ts +18 -0
  266. package/build/commands/mock/clear.d.ts.map +1 -0
  267. package/build/commands/mock/clear.js +19 -0
  268. package/build/commands/mock/respond.d.ts +54 -0
  269. package/build/commands/mock/respond.d.ts.map +1 -0
  270. package/build/commands/mock/respond.js +55 -0
  271. package/build/commands/mock/respondOnce.d.ts +55 -0
  272. package/build/commands/mock/respondOnce.d.ts.map +1 -0
  273. package/build/commands/mock/respondOnce.js +56 -0
  274. package/build/commands/mock/restore.d.ts +18 -0
  275. package/build/commands/mock/restore.d.ts.map +1 -0
  276. package/build/commands/mock/restore.js +19 -0
  277. package/build/constants.d.ts +14 -0
  278. package/build/constants.d.ts.map +1 -0
  279. package/build/constants.js +287 -0
  280. package/build/index.d.ts +45 -0
  281. package/build/index.d.ts.map +1 -0
  282. package/build/index.js +175 -0
  283. package/build/middlewares.d.ts +12 -0
  284. package/build/middlewares.d.ts.map +1 -0
  285. package/build/middlewares.js +65 -0
  286. package/build/multiremote.d.ts +71 -0
  287. package/build/multiremote.d.ts.map +1 -0
  288. package/build/multiremote.js +160 -0
  289. package/build/protocol-stub.d.ts +16 -0
  290. package/build/protocol-stub.d.ts.map +1 -0
  291. package/build/protocol-stub.js +77 -0
  292. package/build/scripts/getHTML.d.ts +9 -0
  293. package/build/scripts/getHTML.d.ts.map +1 -0
  294. package/build/scripts/getHTML.js +13 -0
  295. package/build/scripts/getProperty.d.ts +43 -0
  296. package/build/scripts/getProperty.d.ts.map +1 -0
  297. package/build/scripts/getProperty.js +12 -0
  298. package/build/scripts/isElementClickable.d.ts +7 -0
  299. package/build/scripts/isElementClickable.d.ts.map +1 -0
  300. package/build/scripts/isElementClickable.js +121 -0
  301. package/build/scripts/isElementDisplayed.d.ts +7 -0
  302. package/build/scripts/isElementDisplayed.d.ts.map +1 -0
  303. package/build/scripts/isElementDisplayed.js +216 -0
  304. package/build/scripts/isElementInViewport.d.ts +10 -0
  305. package/build/scripts/isElementInViewport.d.ts.map +1 -0
  306. package/build/scripts/isElementInViewport.js +22 -0
  307. package/build/scripts/isFocused.d.ts +7 -0
  308. package/build/scripts/isFocused.d.ts.map +1 -0
  309. package/build/scripts/isFocused.js +11 -0
  310. package/build/scripts/newWindow.d.ts +10 -0
  311. package/build/scripts/newWindow.d.ts.map +1 -0
  312. package/build/scripts/newWindow.js +14 -0
  313. package/build/scripts/resq.d.ts +6 -0
  314. package/build/scripts/resq.d.ts.map +1 -0
  315. package/build/scripts/resq.js +58 -0
  316. package/build/scripts/shadowFnFactory.d.ts +2 -0
  317. package/build/scripts/shadowFnFactory.d.ts.map +1 -0
  318. package/build/scripts/shadowFnFactory.js +17 -0
  319. package/build/types.d.ts +402 -0
  320. package/build/types.d.ts.map +1 -0
  321. package/build/types.js +2 -0
  322. package/build/utils/SevereServiceError.d.ts +7 -0
  323. package/build/utils/SevereServiceError.d.ts.map +1 -0
  324. package/build/utils/SevereServiceError.js +12 -0
  325. package/build/utils/Timer.d.ts +33 -0
  326. package/build/utils/Timer.d.ts.map +1 -0
  327. package/build/utils/Timer.js +126 -0
  328. package/build/utils/detectBackend.d.ts +23 -0
  329. package/build/utils/detectBackend.d.ts.map +1 -0
  330. package/build/utils/detectBackend.js +119 -0
  331. package/build/utils/findStrategy.d.ts +10 -0
  332. package/build/utils/findStrategy.d.ts.map +1 -0
  333. package/build/utils/findStrategy.js +267 -0
  334. package/build/utils/getElementObject.d.ts +17 -0
  335. package/build/utils/getElementObject.d.ts.map +1 -0
  336. package/build/utils/getElementObject.js +107 -0
  337. package/build/utils/implicitWait.d.ts +7 -0
  338. package/build/utils/implicitWait.d.ts.map +1 -0
  339. package/build/utils/implicitWait.js +39 -0
  340. package/build/utils/index.d.ts +102 -0
  341. package/build/utils/index.d.ts.map +1 -0
  342. package/build/utils/index.js +543 -0
  343. package/build/utils/interception/devtools.d.ts +61 -0
  344. package/build/utils/interception/devtools.d.ts.map +1 -0
  345. package/build/utils/interception/devtools.js +247 -0
  346. package/build/utils/interception/index.d.ts +26 -0
  347. package/build/utils/interception/index.d.ts.map +1 -0
  348. package/build/utils/interception/index.js +49 -0
  349. package/build/utils/interception/types.d.ts +94 -0
  350. package/build/utils/interception/types.d.ts.map +1 -0
  351. package/build/utils/interception/types.js +2 -0
  352. package/build/utils/interception/webdriver.d.ts +48 -0
  353. package/build/utils/interception/webdriver.d.ts.map +1 -0
  354. package/build/utils/interception/webdriver.js +75 -0
  355. package/build/utils/refetchElement.d.ts +6 -0
  356. package/build/utils/refetchElement.d.ts.map +1 -0
  357. package/build/utils/refetchElement.js +32 -0
  358. package/package.json +11 -11
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const puppeteer_core_1 = __importDefault(require("puppeteer-core"));
7
+ const logger_1 = __importDefault(require("@wdio/logger"));
8
+ const constants_1 = require("../../constants");
9
+ const log = (0, logger_1.default)('webdriverio');
10
+ /**
11
+ * Get the [Puppeteer Browser instance](https://pptr.dev/#?product=Puppeteer&version=v5.1.0&show=api-class-browser)
12
+ * to run commands with Puppeteer. Note that all Puppeteer commands are
13
+ * asynchronous by default so in order to interchange between sync and async
14
+ * execution make sure to wrap your Puppeteer calls within a `browser.call`
15
+ * commands as shown in the example.
16
+ *
17
+ * :::info
18
+ *
19
+ * Note that using Puppeteer requires support for Chrome DevTools protocol and e.g.
20
+ * can not be used when running automated tests in the cloud. Find out more in the
21
+ * [Automation Protocols](/docs/automationProtocols) section.
22
+ *
23
+ * :::
24
+ *
25
+ * <example>
26
+ :getPuppeteer.test.js
27
+ it('should allow me to use Puppeteer', async () => {
28
+ // WebDriver command
29
+ await browser.url('https://webdriver.io')
30
+
31
+ const puppeteerBrowser = await browser.getPuppeteer()
32
+ // switch to Puppeteer
33
+ const metrics = await browser.call(async () => {
34
+ const pages = await puppeteerBrowser.pages()
35
+ pages[0].setGeolocation({ latitude: 59.95, longitude: 30.31667 })
36
+ return pages[0].metrics()
37
+ })
38
+
39
+ console.log(metrics.LayoutCount) // returns LayoutCount value
40
+ })
41
+ * </example>
42
+ *
43
+ * @return {PuppeteerBrowser} initiated puppeteer instance connected to the browser
44
+ */
45
+ async function getPuppeteer() {
46
+ var _a, _b, _c, _d, _e;
47
+ /**
48
+ * check if we already connected Puppeteer and if so return
49
+ * that instance
50
+ */
51
+ if ((_a = this.puppeteer) === null || _a === void 0 ? void 0 : _a.isConnected()) {
52
+ log.debug('Reusing existing puppeteer session');
53
+ return this.puppeteer;
54
+ }
55
+ const caps = this.capabilities.alwaysMatch || this.capabilities;
56
+ /**
57
+ * attach to a Selenium 4 CDP Session if it's returned in the capabilities
58
+ */
59
+ const cdpEndpoint = caps['se:cdp'];
60
+ if (cdpEndpoint) {
61
+ this.puppeteer = await puppeteer_core_1.default.connect({
62
+ browserWSEndpoint: cdpEndpoint,
63
+ defaultViewport: null
64
+ });
65
+ return this.puppeteer;
66
+ }
67
+ /**
68
+ * attach to a Selenoid\Moon CDP Session if there are Aerokube vendor capabilities
69
+ */
70
+ const requestedCapabilities = ((_b = this.requestedCapabilities) === null || _b === void 0 ? void 0 : _b.alwaysMatch) || this.requestedCapabilities;
71
+ const isAerokubeSession = requestedCapabilities['selenoid:options'] || requestedCapabilities['moon:options'];
72
+ if (isAerokubeSession) {
73
+ const { hostname, port } = this.options;
74
+ this.puppeteer = await puppeteer_core_1.default.connect({
75
+ browserWSEndpoint: `ws://${hostname}:${port}/devtools/${this.sessionId}`,
76
+ defaultViewport: null
77
+ });
78
+ return this.puppeteer;
79
+ }
80
+ /**
81
+ * attach to Chromium debugger session
82
+ */
83
+ const chromiumOptions = caps['goog:chromeOptions'] || caps['ms:edgeOptions'];
84
+ if (chromiumOptions && chromiumOptions.debuggerAddress) {
85
+ this.puppeteer = await puppeteer_core_1.default.connect({
86
+ browserURL: `http://${chromiumOptions.debuggerAddress}`,
87
+ defaultViewport: null
88
+ });
89
+ return this.puppeteer;
90
+ }
91
+ /**
92
+ * attach to Firefox debugger session
93
+ */
94
+ if (((_c = caps.browserName) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === 'firefox') {
95
+ if (!caps.browserVersion) {
96
+ throw new Error('Can\'t find "browserVersion" in capabilities');
97
+ }
98
+ const majorVersion = parseInt(caps.browserVersion.split('.').shift() || '', 10);
99
+ if (majorVersion >= 79) {
100
+ const reqCaps = this.requestedCapabilities.alwaysMatch || this.requestedCapabilities;
101
+ const ffOptions = caps['moz:firefoxOptions'];
102
+ const ffArgs = (_d = reqCaps['moz:firefoxOptions']) === null || _d === void 0 ? void 0 : _d.args;
103
+ const rdPort = ffOptions && ffOptions.debuggerAddress
104
+ ? ffOptions.debuggerAddress
105
+ : (_e = ffArgs === null || ffArgs === void 0 ? void 0 : ffArgs[ffArgs.findIndex((arg) => arg === constants_1.FF_REMOTE_DEBUG_ARG) + 1]) !== null && _e !== void 0 ? _e : null;
106
+ if (!rdPort) {
107
+ throw new Error('Could\'t find remote debug port in Firefox options');
108
+ }
109
+ this.puppeteer = await puppeteer_core_1.default.connect({
110
+ browserURL: `http://localhost:${rdPort}`,
111
+ defaultViewport: null
112
+ });
113
+ return this.puppeteer;
114
+ }
115
+ }
116
+ throw new Error('Using DevTools capabilities is not supported for this session. ' +
117
+ 'This feature is only supported for local testing on Chrome, Firefox and Chromium Edge.');
118
+ }
119
+ exports.default = getPuppeteer;
@@ -0,0 +1,25 @@
1
+ interface BrowserSize {
2
+ width: number;
3
+ height: number;
4
+ }
5
+ /**
6
+ *
7
+ * Returns browser window size.
8
+ *
9
+ * <example>
10
+ :getWindowSize.js
11
+ it('should return browser window size', async () => {
12
+ const windowSize = await browser.getWindowSize();
13
+ console.log(windowSize);
14
+ // outputs `{ width: 1280, height: 767 }`
15
+ });
16
+ * </example>
17
+ *
18
+ * @alias browser.getWindowSize
19
+ * @return {Object} { x, y, width, height } for W3C or { width, height } for non W3C browser
20
+ * @type window
21
+ *
22
+ */
23
+ export default function getWindowSize(this: WebdriverIO.Browser): Promise<BrowserSize>;
24
+ export {};
25
+ //# sourceMappingURL=getWindowSize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getWindowSize.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/getWindowSize.ts"],"names":[],"mappings":"AAEA,UAAU,WAAW;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAA8B,aAAa,CAAC,IAAI,EAAE,WAAW,CAAC,OAAO,wBASpE"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("../../utils");
4
+ /**
5
+ *
6
+ * Returns browser window size.
7
+ *
8
+ * <example>
9
+ :getWindowSize.js
10
+ it('should return browser window size', async () => {
11
+ const windowSize = await browser.getWindowSize();
12
+ console.log(windowSize);
13
+ // outputs `{ width: 1280, height: 767 }`
14
+ });
15
+ * </example>
16
+ *
17
+ * @alias browser.getWindowSize
18
+ * @return {Object} { x, y, width, height } for W3C or { width, height } for non W3C browser
19
+ * @type window
20
+ *
21
+ */
22
+ async function getWindowSize() {
23
+ const browser = (0, utils_1.getBrowserObject)(this);
24
+ if (!browser.isW3C) {
25
+ return browser._getWindowSize();
26
+ }
27
+ const { width, height } = await browser.getWindowRect();
28
+ return { width, height };
29
+ }
30
+ exports.default = getWindowSize;
@@ -0,0 +1,28 @@
1
+ /**
2
+ *
3
+ * Send a sequence of key strokes to the active element. You can also use characters like
4
+ * "Left arrow" or "Back space". WebdriverIO will take care of translating them into unicode
5
+ * characters. You’ll find all supported characters [here](https://w3c.github.io/webdriver/webdriver-spec.html#keyboard-actions).
6
+ * To do that, the value has to correspond to a key from the table.
7
+ *
8
+ * Modifier like Ctrl, Shift, Alt and Meta will stay pressed so you need to trigger them again to release them.
9
+ * Modifiying a click however requires you to use the WebDriver Actions API through the [performActions](https://webdriver.io/docs/api/webdriver#performactions) method.
10
+ *
11
+ * <example>
12
+ :keys.js
13
+ it('copies text out of active element', async () => {
14
+ // copies text from an input element
15
+ const input = await $('#username')
16
+ await input.setValue('anonymous')
17
+
18
+ await browser.keys(['Meta', 'a'])
19
+ await browser.keys(['Meta', 'c'])
20
+ });
21
+ * </example>
22
+ *
23
+ * @param {String|String[]} value The sequence of keys to type. An array or string must be provided.
24
+ * @see https://w3c.github.io/webdriver/#dispatching-actions
25
+ *
26
+ */
27
+ export default function keys(this: WebdriverIO.Browser, value: string | string[]): Promise<void>;
28
+ //# sourceMappingURL=keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/keys.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,OAAO,UAAU,IAAI,CACxB,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,iBAoC3B"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("../../utils");
4
+ /**
5
+ *
6
+ * Send a sequence of key strokes to the active element. You can also use characters like
7
+ * "Left arrow" or "Back space". WebdriverIO will take care of translating them into unicode
8
+ * characters. You’ll find all supported characters [here](https://w3c.github.io/webdriver/webdriver-spec.html#keyboard-actions).
9
+ * To do that, the value has to correspond to a key from the table.
10
+ *
11
+ * Modifier like Ctrl, Shift, Alt and Meta will stay pressed so you need to trigger them again to release them.
12
+ * Modifiying a click however requires you to use the WebDriver Actions API through the [performActions](https://webdriver.io/docs/api/webdriver#performactions) method.
13
+ *
14
+ * <example>
15
+ :keys.js
16
+ it('copies text out of active element', async () => {
17
+ // copies text from an input element
18
+ const input = await $('#username')
19
+ await input.setValue('anonymous')
20
+
21
+ await browser.keys(['Meta', 'a'])
22
+ await browser.keys(['Meta', 'c'])
23
+ });
24
+ * </example>
25
+ *
26
+ * @param {String|String[]} value The sequence of keys to type. An array or string must be provided.
27
+ * @see https://w3c.github.io/webdriver/#dispatching-actions
28
+ *
29
+ */
30
+ function keys(value) {
31
+ let keySequence = [];
32
+ /**
33
+ * replace key with corresponding unicode character
34
+ */
35
+ if (typeof value === 'string') {
36
+ keySequence = (0, utils_1.checkUnicode)(value, this.isDevTools);
37
+ }
38
+ else if (Array.isArray(value)) {
39
+ const charArray = value;
40
+ for (const charSet of charArray) {
41
+ keySequence = keySequence.concat((0, utils_1.checkUnicode)(charSet, this.isDevTools));
42
+ }
43
+ }
44
+ else {
45
+ throw new Error('"keys" command requires a string or array of strings as parameter');
46
+ }
47
+ /**
48
+ * JsonWireProtocol action
49
+ */
50
+ if (!this.isW3C) {
51
+ return this.sendKeys(keySequence);
52
+ }
53
+ /**
54
+ * W3C way of handle it key actions
55
+ */
56
+ const keyDownActions = keySequence.map((value) => ({ type: 'keyDown', value }));
57
+ const keyUpActions = keySequence.map((value) => ({ type: 'keyUp', value }));
58
+ return this.performActions([{
59
+ type: 'key',
60
+ id: 'keyboard',
61
+ actions: [...keyDownActions, ...keyUpActions]
62
+ }]).then(() => this.releaseActions());
63
+ }
64
+ exports.default = keys;
@@ -0,0 +1,111 @@
1
+ import type Interception from '../../utils/interception/index';
2
+ import type { Mock } from '../../types';
3
+ import type { MockFilterOptions } from '../../utils/interception/types';
4
+ export declare const SESSION_MOCKS: Record<string, Set<Interception>>;
5
+ /**
6
+ * Mock the response of a request. You can define a mock based on a matching
7
+ * glob and corresponding header and status code. Calling the mock method
8
+ * returns a stub object that you can use to modify the response of the
9
+ * web resource.
10
+ *
11
+ * With the stub object you can then either return a custom response or
12
+ * have the request fail.
13
+ *
14
+ * There are 3 ways to modify the response:
15
+ * - return a custom JSON object (for stubbing API request)
16
+ * - replace web resource with a local file (service a modified JavaScript file) or
17
+ * - redirect resource to a different url
18
+ *
19
+ * :::info
20
+ *
21
+ * Note that using the `mock` command requires support for Chrome DevTools protocol and e.g.
22
+ * can not be used when running automated tests in the cloud. Find out more in the
23
+ * [Automation Protocols](/docs/automationProtocols) section.
24
+ *
25
+ * :::
26
+ *
27
+ * <example>
28
+ :mock.js
29
+ it('should mock network resources', async () => {
30
+ // via static string
31
+ const userListMock = await browser.mock('**' + '/users/list')
32
+ // or as regular expression
33
+ const userListMock = await browser.mock(/https:\/\/(domainA|domainB)\.com\/.+/)
34
+ // you can also specifying the mock even more by filtering resources
35
+ // by request or response headers, status code, postData, e.g. mock only responses with specific
36
+ // header set and statusCode
37
+ const strictMock = await browser.mock('**', {
38
+ // mock all json responses
39
+ statusCode: 200,
40
+ headers: { 'Content-Type': 'application/json' },
41
+ responseHeaders: { 'Cache-Control': 'no-cache' },
42
+ postData: 'foobar'
43
+ })
44
+
45
+ // comparator function
46
+ const apiV1Mock = await browser.mock('**' + '/api/v1', {
47
+ statusCode: (statusCode) => statusCode >= 200 && statusCode <= 203,
48
+ headers: (headers) => headers['Authorization'] && headers['Authorization'].startsWith('Bearer '),
49
+ responseHeaders: (headers) => headers['Impersonation'],
50
+ postData: (data) => typeof data === 'string' && data.includes('foo')
51
+ })
52
+ })
53
+
54
+ it('should modify API responses', async () => {
55
+ // filter by method
56
+ const todoMock = await browser.mock('**' + '/todos', {
57
+ method: 'get'
58
+ })
59
+
60
+ // mock an endpoint with a fixed fixture
61
+ mock.respond([{
62
+ title: 'Injected Todo',
63
+ order: null,
64
+ completed: false,
65
+ url: "http://todo-backend-express-knex.herokuapp.com/916"
66
+ }])
67
+
68
+ // respond with different status code or header
69
+ mock.respond([{
70
+ title: 'Injected Todo',
71
+ order: null,
72
+ completed: false,
73
+ url: "http://todo-backend-express-knex.herokuapp.com/916"
74
+ }], {
75
+ statusCode: 404,
76
+ headers: {
77
+ 'x-custom-header': 'foobar'
78
+ }
79
+ })
80
+ })
81
+
82
+ it('should modify text assets', async () => {
83
+ const scriptMock = await browser.mock('**' + '/script.min.js')
84
+ scriptMock.respond('./tests/fixtures/script.js')
85
+ })
86
+
87
+ it('should redirect web resources', async () => {
88
+ const headerMock = await browser.mock('**' + '/header.png')
89
+ headerMock.respond('https://media.giphy.com/media/F9hQLAVhWnL56/giphy.gif')
90
+
91
+ const pageMock = await browser.mock('https://google.com/')
92
+ pageMock.respond('https://webdriver.io')
93
+ await browser.url('https://google.com')
94
+ console.log(await browser.getTitle()) // returns "WebdriverIO · Next-gen browser and mobile automation test framework for Node.js"
95
+ })
96
+ * </example>
97
+ *
98
+ * @alias browser.mock
99
+ * @param {String|RegExp} url url to mock
100
+ * @param {MockFilterOptions=} filterOptions filter mock resource by additional options
101
+ * @param {String|Function=} filterOptions.method filter resource by HTTP method
102
+ * @param {Object|Function=} filterOptions.headers filter resource by specific request headers
103
+ * @param {Object|Function=} filterOptions.responseHeaders filter resource by specific response headers
104
+ * @param {String|Function=} filterOptions.postData filter resource by request postData
105
+ * @param {Number|Function=} filterOptions.statusCode filter resource by response statusCode
106
+ * @return {Mock} a mock object to modify the response
107
+ * @type utility
108
+ *
109
+ */
110
+ export default function mock(this: WebdriverIO.Browser, url: string | RegExp, filterOptions?: MockFilterOptions): Promise<Mock>;
111
+ //# sourceMappingURL=mock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/mock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAA;AAI9D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAEvE,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAAY,CAAC,CAAM,CAAA;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwGG;AACH,wBAA8B,IAAI,CAC9B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,GAAG,EAAE,MAAM,GAAG,MAAM,EACpB,aAAa,CAAC,EAAE,iBAAiB,iBA6DpC"}
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SESSION_MOCKS = void 0;
7
+ const devtools_1 = __importDefault(require("../../utils/interception/devtools"));
8
+ const webdriver_1 = __importDefault(require("../../utils/interception/webdriver"));
9
+ const utils_1 = require("../../utils");
10
+ exports.SESSION_MOCKS = {};
11
+ /**
12
+ * Mock the response of a request. You can define a mock based on a matching
13
+ * glob and corresponding header and status code. Calling the mock method
14
+ * returns a stub object that you can use to modify the response of the
15
+ * web resource.
16
+ *
17
+ * With the stub object you can then either return a custom response or
18
+ * have the request fail.
19
+ *
20
+ * There are 3 ways to modify the response:
21
+ * - return a custom JSON object (for stubbing API request)
22
+ * - replace web resource with a local file (service a modified JavaScript file) or
23
+ * - redirect resource to a different url
24
+ *
25
+ * :::info
26
+ *
27
+ * Note that using the `mock` command requires support for Chrome DevTools protocol and e.g.
28
+ * can not be used when running automated tests in the cloud. Find out more in the
29
+ * [Automation Protocols](/docs/automationProtocols) section.
30
+ *
31
+ * :::
32
+ *
33
+ * <example>
34
+ :mock.js
35
+ it('should mock network resources', async () => {
36
+ // via static string
37
+ const userListMock = await browser.mock('**' + '/users/list')
38
+ // or as regular expression
39
+ const userListMock = await browser.mock(/https:\/\/(domainA|domainB)\.com\/.+/)
40
+ // you can also specifying the mock even more by filtering resources
41
+ // by request or response headers, status code, postData, e.g. mock only responses with specific
42
+ // header set and statusCode
43
+ const strictMock = await browser.mock('**', {
44
+ // mock all json responses
45
+ statusCode: 200,
46
+ headers: { 'Content-Type': 'application/json' },
47
+ responseHeaders: { 'Cache-Control': 'no-cache' },
48
+ postData: 'foobar'
49
+ })
50
+
51
+ // comparator function
52
+ const apiV1Mock = await browser.mock('**' + '/api/v1', {
53
+ statusCode: (statusCode) => statusCode >= 200 && statusCode <= 203,
54
+ headers: (headers) => headers['Authorization'] && headers['Authorization'].startsWith('Bearer '),
55
+ responseHeaders: (headers) => headers['Impersonation'],
56
+ postData: (data) => typeof data === 'string' && data.includes('foo')
57
+ })
58
+ })
59
+
60
+ it('should modify API responses', async () => {
61
+ // filter by method
62
+ const todoMock = await browser.mock('**' + '/todos', {
63
+ method: 'get'
64
+ })
65
+
66
+ // mock an endpoint with a fixed fixture
67
+ mock.respond([{
68
+ title: 'Injected Todo',
69
+ order: null,
70
+ completed: false,
71
+ url: "http://todo-backend-express-knex.herokuapp.com/916"
72
+ }])
73
+
74
+ // respond with different status code or header
75
+ mock.respond([{
76
+ title: 'Injected Todo',
77
+ order: null,
78
+ completed: false,
79
+ url: "http://todo-backend-express-knex.herokuapp.com/916"
80
+ }], {
81
+ statusCode: 404,
82
+ headers: {
83
+ 'x-custom-header': 'foobar'
84
+ }
85
+ })
86
+ })
87
+
88
+ it('should modify text assets', async () => {
89
+ const scriptMock = await browser.mock('**' + '/script.min.js')
90
+ scriptMock.respond('./tests/fixtures/script.js')
91
+ })
92
+
93
+ it('should redirect web resources', async () => {
94
+ const headerMock = await browser.mock('**' + '/header.png')
95
+ headerMock.respond('https://media.giphy.com/media/F9hQLAVhWnL56/giphy.gif')
96
+
97
+ const pageMock = await browser.mock('https://google.com/')
98
+ pageMock.respond('https://webdriver.io')
99
+ await browser.url('https://google.com')
100
+ console.log(await browser.getTitle()) // returns "WebdriverIO · Next-gen browser and mobile automation test framework for Node.js"
101
+ })
102
+ * </example>
103
+ *
104
+ * @alias browser.mock
105
+ * @param {String|RegExp} url url to mock
106
+ * @param {MockFilterOptions=} filterOptions filter mock resource by additional options
107
+ * @param {String|Function=} filterOptions.method filter resource by HTTP method
108
+ * @param {Object|Function=} filterOptions.headers filter resource by specific request headers
109
+ * @param {Object|Function=} filterOptions.responseHeaders filter resource by specific response headers
110
+ * @param {String|Function=} filterOptions.postData filter resource by request postData
111
+ * @param {Number|Function=} filterOptions.statusCode filter resource by response statusCode
112
+ * @return {Mock} a mock object to modify the response
113
+ * @type utility
114
+ *
115
+ */
116
+ async function mock(url, filterOptions) {
117
+ const NetworkInterception = this.isSauce ? webdriver_1.default : devtools_1.default;
118
+ if (!this.isSauce) {
119
+ await this.getPuppeteer();
120
+ }
121
+ if (!this.puppeteer) {
122
+ throw new Error('No Puppeteer connection could be established which is required to use this command');
123
+ }
124
+ const browser = (0, utils_1.getBrowserObject)(this);
125
+ const handle = await browser.getWindowHandle();
126
+ if (!exports.SESSION_MOCKS[handle]) {
127
+ exports.SESSION_MOCKS[handle] = new Set();
128
+ }
129
+ /**
130
+ * enable network Mocking if not already
131
+ */
132
+ if (exports.SESSION_MOCKS[handle].size === 0 && !this.isSauce) {
133
+ const pages = await this.puppeteer.pages();
134
+ /**
135
+ * get active page
136
+ */
137
+ let page;
138
+ for (let i = 0; i < pages.length && !page; i++) {
139
+ const isHidden = await pages[i].evaluate(() => document.hidden);
140
+ if (!isHidden) {
141
+ page = pages[i];
142
+ }
143
+ }
144
+ /**
145
+ * fallback to the first page
146
+ */
147
+ if (!page) {
148
+ page = pages[0];
149
+ }
150
+ const client = await page.target().createCDPSession();
151
+ await client.send('Fetch.enable', {
152
+ patterns: [{ requestStage: 'Request' }, { requestStage: 'Response' }]
153
+ });
154
+ client.on('Fetch.requestPaused', NetworkInterception
155
+ .handleRequestInterception(client, exports.SESSION_MOCKS[handle]));
156
+ }
157
+ const networkInterception = new NetworkInterception(url, filterOptions, browser);
158
+ exports.SESSION_MOCKS[handle].add(networkInterception);
159
+ if (this.isSauce) {
160
+ await networkInterception.init();
161
+ }
162
+ return networkInterception;
163
+ }
164
+ exports.default = mock;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Resets all information stored in all registered mocks of the session.
3
+ *
4
+ * <example>
5
+ :mockClearAll.js
6
+ it('should clear all mocks', async () => {
7
+ const docMock = await browser.mock('**', {
8
+ headers: { 'Content-Type': 'text/html' }
9
+ })
10
+ const jsMock = await browser.mock('**', {
11
+ headers: { 'Content-Type': 'application/javascript' }
12
+ })
13
+
14
+ await browser.url('http://guinea-pig.webdriver.io/')
15
+ console.log(docMock.calls.length, jsMock.calls.length) // returns "1 4"
16
+
17
+ await browser.url('http://guinea-pig.webdriver.io/')
18
+ console.log(docMock.calls.length, jsMock.calls.length) // returns "2 4" (JavaScript comes from cache)
19
+
20
+ await browser.mockClearAll()
21
+ console.log(docMock.calls.length, jsMock.calls.length) // returns "0 0"
22
+ })
23
+ * </example>
24
+ *
25
+ * @alias browser.mockClearAll
26
+ */
27
+ export default function mockClearAll(): Promise<void>;
28
+ //# sourceMappingURL=mockClearAll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mockClearAll.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/mockClearAll.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAA8B,YAAY,kBAOzC"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const logger_1 = __importDefault(require("@wdio/logger"));
7
+ const mock_1 = require("./mock");
8
+ const log = (0, logger_1.default)('webdriverio:mockClearAll');
9
+ /**
10
+ * Resets all information stored in all registered mocks of the session.
11
+ *
12
+ * <example>
13
+ :mockClearAll.js
14
+ it('should clear all mocks', async () => {
15
+ const docMock = await browser.mock('**', {
16
+ headers: { 'Content-Type': 'text/html' }
17
+ })
18
+ const jsMock = await browser.mock('**', {
19
+ headers: { 'Content-Type': 'application/javascript' }
20
+ })
21
+
22
+ await browser.url('http://guinea-pig.webdriver.io/')
23
+ console.log(docMock.calls.length, jsMock.calls.length) // returns "1 4"
24
+
25
+ await browser.url('http://guinea-pig.webdriver.io/')
26
+ console.log(docMock.calls.length, jsMock.calls.length) // returns "2 4" (JavaScript comes from cache)
27
+
28
+ await browser.mockClearAll()
29
+ console.log(docMock.calls.length, jsMock.calls.length) // returns "0 0"
30
+ })
31
+ * </example>
32
+ *
33
+ * @alias browser.mockClearAll
34
+ */
35
+ async function mockClearAll() {
36
+ for (const [handle, mocks] of Object.entries(mock_1.SESSION_MOCKS)) {
37
+ log.trace(`Clearing mocks for ${handle}`);
38
+ for (const mock of mocks) {
39
+ mock.clear();
40
+ }
41
+ }
42
+ }
43
+ exports.default = mockClearAll;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Restores all mock information and behavior stored in all registered
3
+ * mocks of the session.
4
+ *
5
+ * <example>
6
+ :mockRestoreAll.js
7
+ it('should restore all mocks', async () => {
8
+ const googleMock = await browser.mock('https://google.com/')
9
+ googleMock.respond('https://webdriver.io')
10
+ const wdioMock = await browser.mock('https://webdriver.io')
11
+ wdioMock.respond('http://json.org')
12
+
13
+ await browser.url('https://google.com/')
14
+ console.log(await browser.getTitle()) // JSON
15
+
16
+ await browser.mockRestoreAll()
17
+
18
+ await browser.url('https://google.com/')
19
+ console.log(await browser.getTitle()) // Google
20
+ })
21
+ * </example>
22
+ *
23
+ * @alias browser.mockRestoreAll
24
+ */
25
+ export default function mockRestoreAll(): Promise<void>;
26
+ //# sourceMappingURL=mockRestoreAll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mockRestoreAll.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/mockRestoreAll.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAA8B,cAAc,kBAO3C"}