webdriverio 7.16.16 → 7.17.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/package.json +7 -7
  2. package/build/commands/browser/$$.d.ts +0 -50
  3. package/build/commands/browser/$$.d.ts.map +0 -1
  4. package/build/commands/browser/$$.js +0 -57
  5. package/build/commands/browser/$.d.ts +0 -77
  6. package/build/commands/browser/$.d.ts.map +0 -1
  7. package/build/commands/browser/$.js +0 -91
  8. package/build/commands/browser/addCommand.d.ts +0 -37
  9. package/build/commands/browser/addCommand.d.ts.map +0 -1
  10. package/build/commands/browser/addCommand.js +0 -37
  11. package/build/commands/browser/call.d.ts +0 -42
  12. package/build/commands/browser/call.d.ts.map +0 -1
  13. package/build/commands/browser/call.js +0 -49
  14. package/build/commands/browser/custom$$.d.ts +0 -26
  15. package/build/commands/browser/custom$$.d.ts.map +0 -1
  16. package/build/commands/browser/custom$$.js +0 -47
  17. package/build/commands/browser/custom$.d.ts +0 -25
  18. package/build/commands/browser/custom$.d.ts.map +0 -1
  19. package/build/commands/browser/custom$.js +0 -47
  20. package/build/commands/browser/debug.d.ts +0 -32
  21. package/build/commands/browser/debug.d.ts.map +0 -1
  22. package/build/commands/browser/debug.js +0 -108
  23. package/build/commands/browser/deleteCookies.d.ts +0 -45
  24. package/build/commands/browser/deleteCookies.d.ts.map +0 -1
  25. package/build/commands/browser/deleteCookies.js +0 -56
  26. package/build/commands/browser/execute.d.ts +0 -37
  27. package/build/commands/browser/execute.d.ts.map +0 -1
  28. package/build/commands/browser/execute.js +0 -55
  29. package/build/commands/browser/executeAsync.d.ts +0 -45
  30. package/build/commands/browser/executeAsync.d.ts.map +0 -1
  31. package/build/commands/browser/executeAsync.js +0 -63
  32. package/build/commands/browser/getCookies.d.ts +0 -34
  33. package/build/commands/browser/getCookies.d.ts.map +0 -1
  34. package/build/commands/browser/getCookies.js +0 -46
  35. package/build/commands/browser/getPuppeteer.d.ts +0 -38
  36. package/build/commands/browser/getPuppeteer.d.ts.map +0 -1
  37. package/build/commands/browser/getPuppeteer.js +0 -119
  38. package/build/commands/browser/getWindowSize.d.ts +0 -25
  39. package/build/commands/browser/getWindowSize.d.ts.map +0 -1
  40. package/build/commands/browser/getWindowSize.js +0 -30
  41. package/build/commands/browser/keys.d.ts +0 -28
  42. package/build/commands/browser/keys.d.ts.map +0 -1
  43. package/build/commands/browser/keys.js +0 -64
  44. package/build/commands/browser/mock.d.ts +0 -111
  45. package/build/commands/browser/mock.d.ts.map +0 -1
  46. package/build/commands/browser/mock.js +0 -164
  47. package/build/commands/browser/mockClearAll.d.ts +0 -28
  48. package/build/commands/browser/mockClearAll.d.ts.map +0 -1
  49. package/build/commands/browser/mockClearAll.js +0 -43
  50. package/build/commands/browser/mockRestoreAll.d.ts +0 -26
  51. package/build/commands/browser/mockRestoreAll.d.ts.map +0 -1
  52. package/build/commands/browser/mockRestoreAll.js +0 -41
  53. package/build/commands/browser/newWindow.d.ts +0 -41
  54. package/build/commands/browser/newWindow.d.ts.map +0 -1
  55. package/build/commands/browser/newWindow.js +0 -83
  56. package/build/commands/browser/overwriteCommand.d.ts +0 -32
  57. package/build/commands/browser/overwriteCommand.d.ts.map +0 -1
  58. package/build/commands/browser/overwriteCommand.js +0 -32
  59. package/build/commands/browser/pause.d.ts +0 -23
  60. package/build/commands/browser/pause.d.ts.map +0 -1
  61. package/build/commands/browser/pause.js +0 -27
  62. package/build/commands/browser/react$$.d.ts +0 -36
  63. package/build/commands/browser/react$$.d.ts.map +0 -1
  64. package/build/commands/browser/react$$.js +0 -51
  65. package/build/commands/browser/react$.d.ts +0 -46
  66. package/build/commands/browser/react$.d.ts.map +0 -1
  67. package/build/commands/browser/react$.js +0 -59
  68. package/build/commands/browser/reloadSession.d.ts +0 -23
  69. package/build/commands/browser/reloadSession.d.ts.map +0 -1
  70. package/build/commands/browser/reloadSession.js +0 -58
  71. package/build/commands/browser/savePDF.d.ts +0 -46
  72. package/build/commands/browser/savePDF.d.ts.map +0 -1
  73. package/build/commands/browser/savePDF.js +0 -51
  74. package/build/commands/browser/saveRecordingScreen.d.ts +0 -28
  75. package/build/commands/browser/saveRecordingScreen.d.ts.map +0 -1
  76. package/build/commands/browser/saveRecordingScreen.js +0 -47
  77. package/build/commands/browser/saveScreenshot.d.ts +0 -22
  78. package/build/commands/browser/saveScreenshot.d.ts.map +0 -1
  79. package/build/commands/browser/saveScreenshot.js +0 -41
  80. package/build/commands/browser/setCookies.d.ts +0 -57
  81. package/build/commands/browser/setCookies.d.ts.map +0 -1
  82. package/build/commands/browser/setCookies.js +0 -66
  83. package/build/commands/browser/setTimeout.d.ts +0 -31
  84. package/build/commands/browser/setTimeout.d.ts.map +0 -1
  85. package/build/commands/browser/setTimeout.js +0 -61
  86. package/build/commands/browser/setWindowSize.d.ts +0 -20
  87. package/build/commands/browser/setWindowSize.d.ts.map +0 -1
  88. package/build/commands/browser/setWindowSize.js +0 -43
  89. package/build/commands/browser/switchWindow.d.ts +0 -30
  90. package/build/commands/browser/switchWindow.d.ts.map +0 -1
  91. package/build/commands/browser/switchWindow.js +0 -73
  92. package/build/commands/browser/throttle.d.ts +0 -3
  93. package/build/commands/browser/throttle.d.ts.map +0 -1
  94. package/build/commands/browser/throttle.js +0 -144
  95. package/build/commands/browser/touchAction.d.ts +0 -61
  96. package/build/commands/browser/touchAction.d.ts.map +0 -1
  97. package/build/commands/browser/touchAction.js +0 -65
  98. package/build/commands/browser/uploadFile.d.ts +0 -32
  99. package/build/commands/browser/uploadFile.d.ts.map +0 -1
  100. package/build/commands/browser/uploadFile.js +0 -63
  101. package/build/commands/browser/url.d.ts +0 -38
  102. package/build/commands/browser/url.d.ts.map +0 -1
  103. package/build/commands/browser/url.js +0 -49
  104. package/build/commands/browser/waitUntil.d.ts +0 -44
  105. package/build/commands/browser/waitUntil.d.ts.map +0 -1
  106. package/build/commands/browser/waitUntil.js +0 -73
  107. package/build/commands/browser.d.ts +0 -70
  108. package/build/commands/browser.d.ts.map +0 -1
  109. package/build/commands/browser.js +0 -44
  110. package/build/commands/constant.d.ts +0 -19
  111. package/build/commands/constant.d.ts.map +0 -1
  112. package/build/commands/constant.js +0 -91
  113. package/build/commands/element/$$.d.ts +0 -46
  114. package/build/commands/element/$$.d.ts.map +0 -1
  115. package/build/commands/element/$$.js +0 -50
  116. package/build/commands/element/$.d.ts +0 -72
  117. package/build/commands/element/$.d.ts.map +0 -1
  118. package/build/commands/element/$.js +0 -76
  119. package/build/commands/element/addValue.d.ts +0 -33
  120. package/build/commands/element/addValue.d.ts.map +0 -1
  121. package/build/commands/element/addValue.js +0 -48
  122. package/build/commands/element/clearValue.d.ts +0 -28
  123. package/build/commands/element/clearValue.d.ts.map +0 -1
  124. package/build/commands/element/clearValue.js +0 -32
  125. package/build/commands/element/click.d.ts +0 -73
  126. package/build/commands/element/click.d.ts.map +0 -1
  127. package/build/commands/element/click.js +0 -134
  128. package/build/commands/element/custom$$.d.ts +0 -28
  129. package/build/commands/element/custom$$.d.ts.map +0 -1
  130. package/build/commands/element/custom$$.js +0 -57
  131. package/build/commands/element/custom$.d.ts +0 -27
  132. package/build/commands/element/custom$.d.ts.map +0 -1
  133. package/build/commands/element/custom$.js +0 -57
  134. package/build/commands/element/doubleClick.d.ts +0 -25
  135. package/build/commands/element/doubleClick.d.ts.map +0 -1
  136. package/build/commands/element/doubleClick.js +0 -51
  137. package/build/commands/element/dragAndDrop.d.ts +0 -41
  138. package/build/commands/element/dragAndDrop.d.ts.map +0 -1
  139. package/build/commands/element/dragAndDrop.js +0 -98
  140. package/build/commands/element/getAttribute.d.ts +0 -28
  141. package/build/commands/element/getAttribute.d.ts.map +0 -1
  142. package/build/commands/element/getAttribute.js +0 -32
  143. package/build/commands/element/getCSSProperty.d.ts +0 -71
  144. package/build/commands/element/getCSSProperty.d.ts.map +0 -1
  145. package/build/commands/element/getCSSProperty.js +0 -108
  146. package/build/commands/element/getComputedLabel.d.ts +0 -20
  147. package/build/commands/element/getComputedLabel.d.ts.map +0 -1
  148. package/build/commands/element/getComputedLabel.js +0 -24
  149. package/build/commands/element/getComputedRole.d.ts +0 -20
  150. package/build/commands/element/getComputedRole.d.ts.map +0 -1
  151. package/build/commands/element/getComputedRole.js +0 -24
  152. package/build/commands/element/getHTML.d.ts +0 -32
  153. package/build/commands/element/getHTML.d.ts.map +0 -1
  154. package/build/commands/element/getHTML.js +0 -46
  155. package/build/commands/element/getLocation.d.ts +0 -6
  156. package/build/commands/element/getLocation.d.ts.map +0 -1
  157. package/build/commands/element/getLocation.js +0 -46
  158. package/build/commands/element/getProperty.d.ts +0 -53
  159. package/build/commands/element/getProperty.d.ts.map +0 -1
  160. package/build/commands/element/getProperty.js +0 -31
  161. package/build/commands/element/getSize.d.ts +0 -6
  162. package/build/commands/element/getSize.d.ts.map +0 -1
  163. package/build/commands/element/getSize.js +0 -47
  164. package/build/commands/element/getTagName.d.ts +0 -25
  165. package/build/commands/element/getTagName.d.ts.map +0 -1
  166. package/build/commands/element/getTagName.js +0 -29
  167. package/build/commands/element/getText.d.ts +0 -42
  168. package/build/commands/element/getText.d.ts.map +0 -1
  169. package/build/commands/element/getText.js +0 -46
  170. package/build/commands/element/getValue.d.ts +0 -25
  171. package/build/commands/element/getValue.d.ts.map +0 -1
  172. package/build/commands/element/getValue.js +0 -33
  173. package/build/commands/element/isClickable.d.ts +0 -40
  174. package/build/commands/element/isClickable.d.ts.map +0 -1
  175. package/build/commands/element/isClickable.js +0 -57
  176. package/build/commands/element/isDisplayed.d.ts +0 -50
  177. package/build/commands/element/isDisplayed.d.ts.map +0 -1
  178. package/build/commands/element/isDisplayed.js +0 -85
  179. package/build/commands/element/isDisplayedInViewport.d.ts +0 -38
  180. package/build/commands/element/isDisplayedInViewport.d.ts.map +0 -1
  181. package/build/commands/element/isDisplayedInViewport.js +0 -55
  182. package/build/commands/element/isEnabled.d.ts +0 -34
  183. package/build/commands/element/isEnabled.d.ts.map +0 -1
  184. package/build/commands/element/isEnabled.js +0 -38
  185. package/build/commands/element/isEqual.d.ts +0 -24
  186. package/build/commands/element/isEqual.d.ts.map +0 -1
  187. package/build/commands/element/isEqual.js +0 -52
  188. package/build/commands/element/isExisting.d.ts +0 -49
  189. package/build/commands/element/isExisting.d.ts.map +0 -1
  190. package/build/commands/element/isExisting.js +0 -65
  191. package/build/commands/element/isFocused.d.ts +0 -28
  192. package/build/commands/element/isFocused.d.ts.map +0 -1
  193. package/build/commands/element/isFocused.js +0 -42
  194. package/build/commands/element/isSelected.d.ts +0 -31
  195. package/build/commands/element/isSelected.d.ts.map +0 -1
  196. package/build/commands/element/isSelected.js +0 -35
  197. package/build/commands/element/moveTo.d.ts +0 -21
  198. package/build/commands/element/moveTo.d.ts.map +0 -1
  199. package/build/commands/element/moveTo.js +0 -39
  200. package/build/commands/element/nextElement.d.ts +0 -25
  201. package/build/commands/element/nextElement.d.ts.map +0 -1
  202. package/build/commands/element/nextElement.js +0 -31
  203. package/build/commands/element/parentElement.d.ts +0 -25
  204. package/build/commands/element/parentElement.d.ts.map +0 -1
  205. package/build/commands/element/parentElement.js +0 -31
  206. package/build/commands/element/previousElement.d.ts +0 -25
  207. package/build/commands/element/previousElement.d.ts.map +0 -1
  208. package/build/commands/element/previousElement.js +0 -31
  209. package/build/commands/element/react$$.d.ts +0 -36
  210. package/build/commands/element/react$$.d.ts.map +0 -1
  211. package/build/commands/element/react$$.js +0 -51
  212. package/build/commands/element/react$.d.ts +0 -46
  213. package/build/commands/element/react$.d.ts.map +0 -1
  214. package/build/commands/element/react$.js +0 -59
  215. package/build/commands/element/saveScreenshot.d.ts +0 -21
  216. package/build/commands/element/saveScreenshot.d.ts.map +0 -1
  217. package/build/commands/element/saveScreenshot.js +0 -40
  218. package/build/commands/element/scrollIntoView.d.ts +0 -21
  219. package/build/commands/element/scrollIntoView.d.ts.map +0 -1
  220. package/build/commands/element/scrollIntoView.js +0 -31
  221. package/build/commands/element/selectByAttribute.d.ts +0 -37
  222. package/build/commands/element/selectByAttribute.d.ts.map +0 -1
  223. package/build/commands/element/selectByAttribute.js +0 -59
  224. package/build/commands/element/selectByIndex.d.ts +0 -31
  225. package/build/commands/element/selectByIndex.d.ts.map +0 -1
  226. package/build/commands/element/selectByIndex.js +0 -55
  227. package/build/commands/element/selectByVisibleText.d.ts +0 -31
  228. package/build/commands/element/selectByVisibleText.d.ts.map +0 -1
  229. package/build/commands/element/selectByVisibleText.js +0 -66
  230. package/build/commands/element/setValue.d.ts +0 -29
  231. package/build/commands/element/setValue.d.ts.map +0 -1
  232. package/build/commands/element/setValue.js +0 -33
  233. package/build/commands/element/shadow$$.d.ts +0 -22
  234. package/build/commands/element/shadow$$.d.ts.map +0 -1
  235. package/build/commands/element/shadow$$.js +0 -27
  236. package/build/commands/element/shadow$.d.ts +0 -22
  237. package/build/commands/element/shadow$.d.ts.map +0 -1
  238. package/build/commands/element/shadow$.js +0 -27
  239. package/build/commands/element/touchAction.d.ts +0 -54
  240. package/build/commands/element/touchAction.d.ts.map +0 -1
  241. package/build/commands/element/touchAction.js +0 -58
  242. package/build/commands/element/waitForClickable.d.ts +0 -34
  243. package/build/commands/element/waitForClickable.d.ts.map +0 -1
  244. package/build/commands/element/waitForClickable.js +0 -37
  245. package/build/commands/element/waitForDisplayed.d.ts +0 -44
  246. package/build/commands/element/waitForDisplayed.d.ts.map +0 -1
  247. package/build/commands/element/waitForDisplayed.js +0 -47
  248. package/build/commands/element/waitForEnabled.d.ts +0 -46
  249. package/build/commands/element/waitForEnabled.d.ts.map +0 -1
  250. package/build/commands/element/waitForEnabled.js +0 -55
  251. package/build/commands/element/waitForExist.d.ts +0 -46
  252. package/build/commands/element/waitForExist.d.ts.map +0 -1
  253. package/build/commands/element/waitForExist.js +0 -49
  254. package/build/commands/element/waitUntil.d.ts +0 -49
  255. package/build/commands/element/waitUntil.d.ts.map +0 -1
  256. package/build/commands/element/waitUntil.js +0 -53
  257. package/build/commands/element.d.ts +0 -100
  258. package/build/commands/element.d.ts.map +0 -1
  259. package/build/commands/element.js +0 -63
  260. package/build/commands/mock/abort.d.ts +0 -19
  261. package/build/commands/mock/abort.d.ts.map +0 -1
  262. package/build/commands/mock/abort.js +0 -20
  263. package/build/commands/mock/abortOnce.d.ts +0 -27
  264. package/build/commands/mock/abortOnce.d.ts.map +0 -1
  265. package/build/commands/mock/abortOnce.js +0 -28
  266. package/build/commands/mock/clear.d.ts +0 -18
  267. package/build/commands/mock/clear.d.ts.map +0 -1
  268. package/build/commands/mock/clear.js +0 -19
  269. package/build/commands/mock/respond.d.ts +0 -54
  270. package/build/commands/mock/respond.d.ts.map +0 -1
  271. package/build/commands/mock/respond.js +0 -55
  272. package/build/commands/mock/respondOnce.d.ts +0 -55
  273. package/build/commands/mock/respondOnce.d.ts.map +0 -1
  274. package/build/commands/mock/respondOnce.js +0 -56
  275. package/build/commands/mock/restore.d.ts +0 -18
  276. package/build/commands/mock/restore.d.ts.map +0 -1
  277. package/build/commands/mock/restore.js +0 -19
  278. package/build/constants.d.ts +0 -14
  279. package/build/constants.d.ts.map +0 -1
  280. package/build/constants.js +0 -286
  281. package/build/index.d.ts +0 -45
  282. package/build/index.d.ts.map +0 -1
  283. package/build/index.js +0 -171
  284. package/build/middlewares.d.ts +0 -12
  285. package/build/middlewares.d.ts.map +0 -1
  286. package/build/middlewares.js +0 -65
  287. package/build/multiremote.d.ts +0 -71
  288. package/build/multiremote.d.ts.map +0 -1
  289. package/build/multiremote.js +0 -160
  290. package/build/protocol-stub.d.ts +0 -16
  291. package/build/protocol-stub.d.ts.map +0 -1
  292. package/build/protocol-stub.js +0 -77
  293. package/build/scripts/getHTML.d.ts +0 -9
  294. package/build/scripts/getHTML.d.ts.map +0 -1
  295. package/build/scripts/getHTML.js +0 -13
  296. package/build/scripts/getProperty.d.ts +0 -43
  297. package/build/scripts/getProperty.d.ts.map +0 -1
  298. package/build/scripts/getProperty.js +0 -12
  299. package/build/scripts/isElementClickable.d.ts +0 -7
  300. package/build/scripts/isElementClickable.d.ts.map +0 -1
  301. package/build/scripts/isElementClickable.js +0 -121
  302. package/build/scripts/isElementDisplayed.d.ts +0 -7
  303. package/build/scripts/isElementDisplayed.d.ts.map +0 -1
  304. package/build/scripts/isElementDisplayed.js +0 -216
  305. package/build/scripts/isElementInViewport.d.ts +0 -10
  306. package/build/scripts/isElementInViewport.d.ts.map +0 -1
  307. package/build/scripts/isElementInViewport.js +0 -22
  308. package/build/scripts/isFocused.d.ts +0 -7
  309. package/build/scripts/isFocused.d.ts.map +0 -1
  310. package/build/scripts/isFocused.js +0 -11
  311. package/build/scripts/newWindow.d.ts +0 -10
  312. package/build/scripts/newWindow.d.ts.map +0 -1
  313. package/build/scripts/newWindow.js +0 -14
  314. package/build/scripts/resq.d.ts +0 -6
  315. package/build/scripts/resq.d.ts.map +0 -1
  316. package/build/scripts/resq.js +0 -58
  317. package/build/scripts/shadowFnFactory.d.ts +0 -2
  318. package/build/scripts/shadowFnFactory.d.ts.map +0 -1
  319. package/build/scripts/shadowFnFactory.js +0 -17
  320. package/build/types.d.ts +0 -402
  321. package/build/types.d.ts.map +0 -1
  322. package/build/types.js +0 -2
  323. package/build/utils/SevereServiceError.d.ts +0 -7
  324. package/build/utils/SevereServiceError.d.ts.map +0 -1
  325. package/build/utils/SevereServiceError.js +0 -12
  326. package/build/utils/Timer.d.ts +0 -33
  327. package/build/utils/Timer.d.ts.map +0 -1
  328. package/build/utils/Timer.js +0 -126
  329. package/build/utils/detectBackend.d.ts +0 -23
  330. package/build/utils/detectBackend.d.ts.map +0 -1
  331. package/build/utils/detectBackend.js +0 -119
  332. package/build/utils/findStrategy.d.ts +0 -10
  333. package/build/utils/findStrategy.d.ts.map +0 -1
  334. package/build/utils/findStrategy.js +0 -267
  335. package/build/utils/getElementObject.d.ts +0 -17
  336. package/build/utils/getElementObject.d.ts.map +0 -1
  337. package/build/utils/getElementObject.js +0 -107
  338. package/build/utils/implicitWait.d.ts +0 -7
  339. package/build/utils/implicitWait.d.ts.map +0 -1
  340. package/build/utils/implicitWait.js +0 -39
  341. package/build/utils/index.d.ts +0 -102
  342. package/build/utils/index.d.ts.map +0 -1
  343. package/build/utils/index.js +0 -543
  344. package/build/utils/interception/devtools.d.ts +0 -61
  345. package/build/utils/interception/devtools.d.ts.map +0 -1
  346. package/build/utils/interception/devtools.js +0 -247
  347. package/build/utils/interception/index.d.ts +0 -26
  348. package/build/utils/interception/index.d.ts.map +0 -1
  349. package/build/utils/interception/index.js +0 -49
  350. package/build/utils/interception/types.d.ts +0 -94
  351. package/build/utils/interception/types.d.ts.map +0 -1
  352. package/build/utils/interception/types.js +0 -2
  353. package/build/utils/interception/webdriver.d.ts +0 -48
  354. package/build/utils/interception/webdriver.d.ts.map +0 -1
  355. package/build/utils/interception/webdriver.js +0 -75
  356. package/build/utils/refetchElement.d.ts +0 -6
  357. package/build/utils/refetchElement.d.ts.map +0 -1
  358. package/build/utils/refetchElement.js +0 -32
@@ -1,102 +0,0 @@
1
- import type { ElementReference } from '@wdio/protocols';
2
- import type { Options } from '@wdio/types';
3
- import type { ElementArray, Selector, ParsedCSSValue, CustomLocatorReturnValue } from '../types';
4
- /**
5
- * enhances objects with element commands
6
- */
7
- export declare const getPrototype: (scope: 'browser' | 'element') => Record<string, PropertyDescriptor>;
8
- /**
9
- * get element id from WebDriver response
10
- * @param {?Object|undefined} res body object from response or null
11
- * @return {?string} element id or null if element couldn't be found
12
- */
13
- export declare const getElementFromResponse: (res: ElementReference) => any;
14
- /**
15
- * traverse up the scope chain until browser element was reached
16
- */
17
- export declare function getBrowserObject(elem: WebdriverIO.Element | WebdriverIO.Browser): WebdriverIO.Browser;
18
- /**
19
- * transform whatever value is into an array of char strings
20
- */
21
- export declare function transformToCharString(value: any, translateToUnicode?: boolean): string[];
22
- /**
23
- * parse css values to a better format
24
- * @param {Object} cssPropertyValue result of WebDriver call
25
- * @param {String} cssProperty name of css property to parse
26
- * @return {Object} parsed css property
27
- */
28
- export declare function parseCSS(cssPropertyValue: string, cssProperty?: string): ParsedCSSValue;
29
- /**
30
- * check for unicode character or split string into literals
31
- * @param {String} value text
32
- * @return {Array} set of characters or unicode symbols
33
- */
34
- export declare function checkUnicode(value: string, isDevTools?: boolean): string[];
35
- /**
36
- * logic to find an element
37
- */
38
- export declare function findElement(this: WebdriverIO.Browser | WebdriverIO.Element, selector: Selector): Promise<Error | ElementReference>;
39
- /**
40
- * logic to find a elements
41
- */
42
- export declare function findElements(this: WebdriverIO.Browser | WebdriverIO.Element, selector: Selector): Promise<ElementReference[]>;
43
- /**
44
- * Strip element object and return w3c and jsonwp compatible keys
45
- */
46
- export declare function verifyArgsAndStripIfElement(args: any): any;
47
- /**
48
- * getElementRect
49
- */
50
- export declare function getElementRect(scope: WebdriverIO.Element): Promise<import("@wdio/protocols").RectReturn>;
51
- export declare function getAbsoluteFilepath(filepath: string): string;
52
- /**
53
- * check if directory exists
54
- */
55
- export declare function assertDirectoryExists(filepath: string): void;
56
- /**
57
- * check if urls are valid and fix them if necessary
58
- * @param {string} url url to navigate to
59
- * @param {Boolean} [retryCheck=false] true if an url was already check and still failed with fix applied
60
- * @return {string} fixed url
61
- */
62
- export declare function validateUrl(url: string, origError?: Error): string;
63
- /**
64
- * get window's scrollX and scrollY
65
- * @param {object} scope
66
- */
67
- export declare function getScrollPosition(scope: WebdriverIO.Element): Promise<{
68
- scrollX: number;
69
- scrollY: number;
70
- }>;
71
- export declare function hasElementId(element: WebdriverIO.Element): Promise<boolean>;
72
- export declare function addLocatorStrategyHandler(scope: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser): (name: string, func: (selector: string, root?: HTMLElement | undefined) => CustomLocatorReturnValue) => void;
73
- /**
74
- * Enhance elements array with data required to refetch it
75
- * @param {object[]} elements elements
76
- * @param {object} parent element or browser
77
- * @param {string|Function} selector string or function, or strategy name for `custom$$`
78
- * @param {string} foundWith name of the command elements were found with, ex `$$`, `react$$`, etc
79
- * @param {Array} props additional properties required to fetch elements again
80
- * @returns {object[]} elements
81
- */
82
- export declare const enhanceElementsArray: (elements: ElementArray, parent: WebdriverIO.Browser | WebdriverIO.Element, selector: Selector, foundWith?: string, props?: any[]) => ElementArray;
83
- /**
84
- * is protocol stub
85
- * @param {string} automationProtocol
86
- */
87
- export declare const isStub: (automationProtocol?: string | undefined) => boolean;
88
- export declare const getAutomationProtocol: (config: Options.WebdriverIO | Options.Testrunner) => Promise<Options.SupportedProtocols>;
89
- /**
90
- * updateCapabilities allows modifying capabilities before session
91
- * is started
92
- *
93
- * NOTE: this method is executed twice when running the WDIO testrunner
94
- */
95
- export declare const updateCapabilities: (params: Options.WebdriverIO | Options.Testrunner, automationProtocol?: Options.SupportedProtocols | undefined) => Promise<void>;
96
- /**
97
- * compare if an object (`base`) contains the same values as another object (`match`)
98
- * @param {object} base object to compare to
99
- * @param {object} match object that needs to match thebase
100
- */
101
- export declare const containsHeaderObject: (base: Record<string, string>, match: Record<string, string>) => boolean;
102
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,KAAK,EAAE,OAAO,EAAgB,MAAM,aAAa,CAAA;AAKxD,OAAO,KAAK,EAAE,YAAY,EAAmB,QAAQ,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAqBjH;;GAEG;AACH,eAAO,MAAM,YAAY,UAAW,SAAS,GAAG,SAAS,uCAmBxD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,QAAS,gBAAgB,QAuB3D,CAAA;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAE,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,CAGtG;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAE,KAAK,EAAE,GAAG,EAAE,kBAAkB,UAAO,YA0B3E;AAWD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAE,gBAAgB,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,kBAkDvE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CACxB,KAAK,EAAE,MAAM,EACb,UAAU,UAAQ,YAKrB;AAkBD;;GAEG;AACH,wBAAsB,WAAW,CAC7B,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,EAC/C,QAAQ,EAAE,QAAQ,qCAwCrB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAC9B,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,EAC/C,QAAQ,EAAE,QAAQ,+BAsCrB;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,GAAG,OAkBpD;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,WAAW,CAAC,OAAO,iDAuC9D;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,UAInD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,QAIrD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAE,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAcnE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAE,KAAK,EAAE,WAAW,CAAC,OAAO;;;GAK5D;AAED,wBAAsB,YAAY,CAAE,OAAO,EAAE,WAAW,CAAC,OAAO,oBAkB/D;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB,UACnF,MAAM,mBAAmB,MAAM,qCAAyB,wBAAwB,UAOjG;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,aACnB,YAAY,UACd,YAAY,OAAO,GAAG,mBAAmB,YACvC,QAAQ,8BAEX,GAAG,EAAE,iBAOf,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,MAAM,sDAA4E,CAAA;AAE/F,eAAO,MAAM,qBAAqB,WAAkB,mBAAmB,GAAG,QAAQ,UAAU,wCAmE3F,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,WAAkB,mBAAmB,GAAG,QAAQ,UAAU,+EA2BxF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,SACvB,OAAO,MAAM,EAAE,MAAM,CAAC,SACrB,OAAO,MAAM,EAAE,MAAM,CAAC,YAShC,CAAA"}
@@ -1,543 +0,0 @@
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.containsHeaderObject = exports.updateCapabilities = exports.getAutomationProtocol = exports.isStub = exports.enhanceElementsArray = exports.addLocatorStrategyHandler = exports.hasElementId = exports.getScrollPosition = exports.validateUrl = exports.assertDirectoryExists = exports.getAbsoluteFilepath = exports.getElementRect = exports.verifyArgsAndStripIfElement = exports.findElements = exports.findElement = exports.checkUnicode = exports.parseCSS = exports.transformToCharString = exports.getBrowserObject = exports.getElementFromResponse = exports.getPrototype = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const http_1 = __importDefault(require("http"));
9
- const path_1 = __importDefault(require("path"));
10
- const css_value_1 = __importDefault(require("css-value"));
11
- const rgb2hex_1 = __importDefault(require("rgb2hex"));
12
- const get_port_1 = __importDefault(require("get-port"));
13
- const grapheme_splitter_1 = __importDefault(require("grapheme-splitter"));
14
- const logger_1 = __importDefault(require("@wdio/logger"));
15
- const lodash_isobject_1 = __importDefault(require("lodash.isobject"));
16
- const lodash_isplainobject_1 = __importDefault(require("lodash.isplainobject"));
17
- const url_1 = require("url");
18
- const devtools_1 = require("devtools");
19
- const utils_1 = require("@wdio/utils");
20
- const webdriverio_1 = require("query-selector-shadow-dom/plugins/webdriverio");
21
- const constants_1 = require("../constants");
22
- const findStrategy_1 = require("./findStrategy");
23
- const browserCommands = require('../commands/browser').default;
24
- const elementCommands = require('../commands/element').default;
25
- const log = (0, logger_1.default)('webdriverio');
26
- const INVALID_SELECTOR_ERROR = 'selector needs to be typeof `string` or `function`';
27
- const scopes = {
28
- browser: browserCommands,
29
- element: elementCommands
30
- };
31
- const applyScopePrototype = (prototype, scope) => {
32
- Object.entries(scopes[scope]).forEach(([commandName, command]) => {
33
- prototype[commandName] = { value: command };
34
- });
35
- };
36
- /**
37
- * enhances objects with element commands
38
- */
39
- const getPrototype = (scope) => {
40
- const prototype = {
41
- /**
42
- * used to store the puppeteer instance in the browser scope
43
- */
44
- puppeteer: { value: null, writable: true },
45
- /**
46
- * for handling sync execution in @wdio/sync
47
- */
48
- _NOT_FIBER: { value: false, writable: true, configurable: true }
49
- };
50
- /**
51
- * register action commands
52
- */
53
- applyScopePrototype(prototype, scope);
54
- prototype.strategies = { value: new Map() };
55
- return prototype;
56
- };
57
- exports.getPrototype = getPrototype;
58
- /**
59
- * get element id from WebDriver response
60
- * @param {?Object|undefined} res body object from response or null
61
- * @return {?string} element id or null if element couldn't be found
62
- */
63
- const getElementFromResponse = (res) => {
64
- /**
65
- * a function selector can return null
66
- */
67
- if (!res) {
68
- return null;
69
- }
70
- /**
71
- * deprecated JSONWireProtocol response
72
- */
73
- if (res.ELEMENT) {
74
- return res.ELEMENT;
75
- }
76
- /**
77
- * W3C WebDriver response
78
- */
79
- if (res[constants_1.ELEMENT_KEY]) {
80
- return res[constants_1.ELEMENT_KEY];
81
- }
82
- return null;
83
- };
84
- exports.getElementFromResponse = getElementFromResponse;
85
- /**
86
- * traverse up the scope chain until browser element was reached
87
- */
88
- function getBrowserObject(elem) {
89
- const elemObject = elem;
90
- return elemObject.parent ? getBrowserObject(elemObject.parent) : elem;
91
- }
92
- exports.getBrowserObject = getBrowserObject;
93
- /**
94
- * transform whatever value is into an array of char strings
95
- */
96
- function transformToCharString(value, translateToUnicode = true) {
97
- const ret = [];
98
- if (!Array.isArray(value)) {
99
- value = [value];
100
- }
101
- for (const val of value) {
102
- if (typeof val === 'string') {
103
- translateToUnicode
104
- ? ret.push(...checkUnicode(val))
105
- : ret.push(...`${val}`.split(''));
106
- }
107
- else if (typeof val === 'number') {
108
- const entry = `${val}`.split('');
109
- ret.push(...entry);
110
- }
111
- else if (val && typeof val === 'object') {
112
- try {
113
- ret.push(...JSON.stringify(val).split(''));
114
- }
115
- catch (err) { /* ignore */ }
116
- }
117
- else if (typeof val === 'boolean') {
118
- const entry = val ? 'true'.split('') : 'false'.split('');
119
- ret.push(...entry);
120
- }
121
- }
122
- return ret;
123
- }
124
- exports.transformToCharString = transformToCharString;
125
- function sanitizeCSS(value) {
126
- /* istanbul ignore next */
127
- if (!value) {
128
- return value;
129
- }
130
- return value.trim().replace(/'/g, '').replace(/"/g, '').toLowerCase();
131
- }
132
- /**
133
- * parse css values to a better format
134
- * @param {Object} cssPropertyValue result of WebDriver call
135
- * @param {String} cssProperty name of css property to parse
136
- * @return {Object} parsed css property
137
- */
138
- function parseCSS(cssPropertyValue, cssProperty) {
139
- var _a;
140
- const parsedValue = {
141
- property: cssProperty,
142
- value: cssPropertyValue.toLowerCase().trim(),
143
- parsed: {}
144
- };
145
- if (((_a = parsedValue.value) === null || _a === void 0 ? void 0 : _a.indexOf('rgb')) === 0) {
146
- /**
147
- * remove whitespaces in rgb values
148
- */
149
- parsedValue.value = parsedValue.value.replace(/\s/g, '');
150
- /**
151
- * parse color values
152
- */
153
- let color = parsedValue.value;
154
- parsedValue.parsed = (0, rgb2hex_1.default)(parsedValue.value);
155
- parsedValue.parsed.type = 'color';
156
- const colorType = /[rgba]+/g.exec(color) || [];
157
- parsedValue.parsed[colorType[0]] = color;
158
- }
159
- else if (parsedValue.property === 'font-family') {
160
- let font = (0, css_value_1.default)(cssPropertyValue);
161
- let string = parsedValue.value;
162
- let value = cssPropertyValue.split(/,/).map(sanitizeCSS);
163
- parsedValue.value = sanitizeCSS(font[0].value || font[0].string);
164
- parsedValue.parsed = { value, type: 'font', string };
165
- }
166
- else {
167
- /**
168
- * parse other css properties
169
- */
170
- try {
171
- const value = (0, css_value_1.default)(cssPropertyValue);
172
- if (value.length === 1) {
173
- parsedValue.parsed = value[0];
174
- }
175
- if (parsedValue.parsed.type && parsedValue.parsed.type === 'number' && parsedValue.parsed.unit === '') {
176
- parsedValue.value = parsedValue.parsed.value;
177
- }
178
- }
179
- catch (err) {
180
- // TODO improve css-parse lib to handle properties like
181
- // `-webkit-animation-timing-function : cubic-bezier(0.25, 0.1, 0.25, 1)
182
- }
183
- }
184
- return parsedValue;
185
- }
186
- exports.parseCSS = parseCSS;
187
- /**
188
- * check for unicode character or split string into literals
189
- * @param {String} value text
190
- * @return {Array} set of characters or unicode symbols
191
- */
192
- function checkUnicode(value, isDevTools = false) {
193
- return Object.prototype.hasOwnProperty.call(utils_1.UNICODE_CHARACTERS, value)
194
- ? isDevTools ? [value] : [utils_1.UNICODE_CHARACTERS[value]]
195
- : new grapheme_splitter_1.default().splitGraphemes(value);
196
- }
197
- exports.checkUnicode = checkUnicode;
198
- function fetchElementByJSFunction(selector, scope) {
199
- if (!scope.elementId) {
200
- return scope.execute(selector);
201
- }
202
- /**
203
- * use a regular function because IE does not understand arrow functions
204
- */
205
- const script = (function (elem) {
206
- return selector.call(elem);
207
- }).toString().replace('selector', `(${selector.toString()})`);
208
- return getBrowserObject(scope).execute(`return (${script}).apply(null, arguments)`, scope);
209
- }
210
- /**
211
- * logic to find an element
212
- */
213
- async function findElement(selector) {
214
- /**
215
- * check if shadow DOM integration is used
216
- */
217
- if (!this.isDevTools && typeof selector === 'string' && selector.startsWith(constants_1.DEEP_SELECTOR)) {
218
- const notFoundError = new Error(`shadow selector "${selector.slice(constants_1.DEEP_SELECTOR.length)}" did not return an HTMLElement`);
219
- let elem = await this.execute(webdriverio_1.locatorStrategy, ...[
220
- selector.slice(constants_1.DEEP_SELECTOR.length),
221
- this.elementId ? this : undefined
222
- ].filter(Boolean));
223
- elem = Array.isArray(elem) ? elem[0] : elem;
224
- return (0, exports.getElementFromResponse)(elem) ? elem : notFoundError;
225
- }
226
- /**
227
- * fetch element using regular protocol command
228
- */
229
- if (typeof selector === 'string' || (0, lodash_isplainobject_1.default)(selector)) {
230
- const { using, value } = (0, findStrategy_1.findStrategy)(selector, this.isW3C, this.isMobile);
231
- return this.elementId
232
- // casting to any necessary given weak type support of protocol commands
233
- ? this.findElementFromElement(this.elementId, using, value)
234
- : this.findElement(using, value);
235
- }
236
- /**
237
- * fetch element with JS function
238
- */
239
- if (typeof selector === 'function') {
240
- const notFoundError = new Error(`Function selector "${selector.toString()}" did not return an HTMLElement`);
241
- let elem = await fetchElementByJSFunction(selector, this);
242
- elem = Array.isArray(elem) ? elem[0] : elem;
243
- return (0, exports.getElementFromResponse)(elem) ? elem : notFoundError;
244
- }
245
- throw new Error(INVALID_SELECTOR_ERROR);
246
- }
247
- exports.findElement = findElement;
248
- /**
249
- * logic to find a elements
250
- */
251
- async function findElements(selector) {
252
- /**
253
- * check if shadow DOM integration is used
254
- */
255
- if (!this.isDevTools && typeof selector === 'string' && selector.startsWith(constants_1.DEEP_SELECTOR)) {
256
- const elems = await this.execute(webdriverio_1.locatorStrategy, ...[
257
- selector.slice(constants_1.DEEP_SELECTOR.length),
258
- this.elementId ? this : undefined
259
- ].filter(Boolean));
260
- const elemArray = Array.isArray(elems) ? elems : [elems];
261
- return elemArray.filter((elem) => elem && (0, exports.getElementFromResponse)(elem));
262
- }
263
- /**
264
- * fetch element using regular protocol command
265
- */
266
- if (typeof selector === 'string' || (0, lodash_isplainobject_1.default)(selector)) {
267
- const { using, value } = (0, findStrategy_1.findStrategy)(selector, this.isW3C, this.isMobile);
268
- return this.elementId
269
- // casting to any necessary given weak type support of protocol commands
270
- ? this.findElementsFromElement(this.elementId, using, value)
271
- : this.findElements(using, value);
272
- }
273
- /**
274
- * fetch element with JS function
275
- */
276
- if (typeof selector === 'function') {
277
- const elems = await fetchElementByJSFunction(selector, this);
278
- const elemArray = Array.isArray(elems) ? elems : [elems];
279
- return elemArray.filter((elem) => elem && (0, exports.getElementFromResponse)(elem));
280
- }
281
- throw new Error(INVALID_SELECTOR_ERROR);
282
- }
283
- exports.findElements = findElements;
284
- /**
285
- * Strip element object and return w3c and jsonwp compatible keys
286
- */
287
- function verifyArgsAndStripIfElement(args) {
288
- function verify(arg) {
289
- if ((0, lodash_isobject_1.default)(arg) && arg.constructor.name === 'Element') {
290
- const elem = arg;
291
- if (!elem.elementId) {
292
- throw new Error(`The element with selector "${elem.selector}" you are trying to pass into the execute method wasn't found`);
293
- }
294
- return {
295
- [constants_1.ELEMENT_KEY]: elem.elementId,
296
- ELEMENT: elem.elementId
297
- };
298
- }
299
- return arg;
300
- }
301
- return !Array.isArray(args) ? verify(args) : args.map(verify);
302
- }
303
- exports.verifyArgsAndStripIfElement = verifyArgsAndStripIfElement;
304
- /**
305
- * getElementRect
306
- */
307
- async function getElementRect(scope) {
308
- const rect = await scope.getElementRect(scope.elementId);
309
- let defaults = { x: 0, y: 0, width: 0, height: 0 };
310
- /**
311
- * getElementRect workaround for Safari 12.0.3
312
- * if one of [x, y, height, width] is undefined get rect with javascript
313
- */
314
- if (Object.keys(defaults).some((key) => rect[key] == null)) {
315
- /* istanbul ignore next */
316
- const rectJs = await getBrowserObject(scope).execute(function (el) {
317
- if (!el || !el.getBoundingClientRect) {
318
- return;
319
- }
320
- const { left, top, width, height } = el.getBoundingClientRect();
321
- return {
322
- x: left + this.scrollX,
323
- y: top + this.scrollY,
324
- width,
325
- height
326
- };
327
- }, scope);
328
- // try set proper value
329
- Object.keys(defaults).forEach((key) => {
330
- if (rect[key] != null) {
331
- return;
332
- }
333
- if (rectJs && typeof rectJs[key] === 'number') {
334
- rect[key] = Math.floor(rectJs[key]);
335
- }
336
- else {
337
- log.error('getElementRect', { rect, rectJs, key });
338
- throw new Error('Failed to receive element rects via execute command');
339
- }
340
- });
341
- }
342
- return rect;
343
- }
344
- exports.getElementRect = getElementRect;
345
- function getAbsoluteFilepath(filepath) {
346
- return filepath.startsWith('/') || filepath.startsWith('\\') || filepath.match(/^[a-zA-Z]:\\/)
347
- ? filepath
348
- : path_1.default.join(process.cwd(), filepath);
349
- }
350
- exports.getAbsoluteFilepath = getAbsoluteFilepath;
351
- /**
352
- * check if directory exists
353
- */
354
- function assertDirectoryExists(filepath) {
355
- if (!fs_1.default.existsSync(path_1.default.dirname(filepath))) {
356
- throw new Error(`directory (${path_1.default.dirname(filepath)}) doesn't exist`);
357
- }
358
- }
359
- exports.assertDirectoryExists = assertDirectoryExists;
360
- /**
361
- * check if urls are valid and fix them if necessary
362
- * @param {string} url url to navigate to
363
- * @param {Boolean} [retryCheck=false] true if an url was already check and still failed with fix applied
364
- * @return {string} fixed url
365
- */
366
- function validateUrl(url, origError) {
367
- try {
368
- const urlObject = new url_1.URL(url);
369
- return urlObject.href;
370
- }
371
- catch (err) {
372
- /**
373
- * if even adding http:// doesn't help, fail with original error
374
- */
375
- if (origError) {
376
- throw origError;
377
- }
378
- return validateUrl(`http://${url}`, new Error(`Invalid URL: ${url}`));
379
- }
380
- }
381
- exports.validateUrl = validateUrl;
382
- /**
383
- * get window's scrollX and scrollY
384
- * @param {object} scope
385
- */
386
- function getScrollPosition(scope) {
387
- return getBrowserObject(scope)
388
- .execute(/* istanbul ignore next */ function () {
389
- return { scrollX: this.pageXOffset, scrollY: this.pageYOffset };
390
- });
391
- }
392
- exports.getScrollPosition = getScrollPosition;
393
- async function hasElementId(element) {
394
- /*
395
- * This is only necessary as isDisplayed is on the exclusion list for the middleware
396
- */
397
- if (!element.elementId) {
398
- const command = element.isReactElement
399
- ? element.parent.react$.bind(element.parent)
400
- : element.parent.$.bind(element.parent);
401
- element.elementId = (await command(element.selector)).elementId;
402
- }
403
- /*
404
- * if element was still not found it also is not displayed
405
- */
406
- if (!element.elementId) {
407
- return false;
408
- }
409
- return true;
410
- }
411
- exports.hasElementId = hasElementId;
412
- function addLocatorStrategyHandler(scope) {
413
- return (name, func) => {
414
- if (scope.strategies.get(name)) {
415
- throw new Error(`Strategy ${name} already exists`);
416
- }
417
- scope.strategies.set(name, func);
418
- };
419
- }
420
- exports.addLocatorStrategyHandler = addLocatorStrategyHandler;
421
- /**
422
- * Enhance elements array with data required to refetch it
423
- * @param {object[]} elements elements
424
- * @param {object} parent element or browser
425
- * @param {string|Function} selector string or function, or strategy name for `custom$$`
426
- * @param {string} foundWith name of the command elements were found with, ex `$$`, `react$$`, etc
427
- * @param {Array} props additional properties required to fetch elements again
428
- * @returns {object[]} elements
429
- */
430
- const enhanceElementsArray = (elements, parent, selector, foundWith = '$$', props = []) => {
431
- elements.parent = parent;
432
- elements.selector = selector;
433
- elements.foundWith = foundWith;
434
- elements.props = props;
435
- return elements;
436
- };
437
- exports.enhanceElementsArray = enhanceElementsArray;
438
- /**
439
- * is protocol stub
440
- * @param {string} automationProtocol
441
- */
442
- const isStub = (automationProtocol) => automationProtocol === './protocol-stub';
443
- exports.isStub = isStub;
444
- const getAutomationProtocol = async (config) => {
445
- var _a, _b;
446
- /**
447
- * if automation protocol is set by user prefer this
448
- */
449
- if (config.automationProtocol) {
450
- return config.automationProtocol;
451
- }
452
- /**
453
- * run WebDriver if hostname or port is set
454
- */
455
- if (config.hostname || config.port || config.path || (config.user && config.key)) {
456
- return 'webdriver';
457
- }
458
- /**
459
- * only run DevTools protocol if capabilities match supported platforms
460
- */
461
- const caps = (((_a = config.capabilities) === null || _a === void 0 ? void 0 : _a.alwaysMatch) ||
462
- config.capabilities) || {};
463
- const desiredCaps = caps;
464
- if (!devtools_1.SUPPORTED_BROWSER.includes((_b = caps.browserName) === null || _b === void 0 ? void 0 : _b.toLowerCase())) {
465
- return 'webdriver';
466
- }
467
- /**
468
- * check if we are on mobile and use WebDriver if so
469
- */
470
- if (desiredCaps.deviceName || caps['appium:deviceName'] ||
471
- desiredCaps.platformVersion || caps['appium:platformVersion'] ||
472
- desiredCaps.app || caps['appium:app']) {
473
- return 'webdriver';
474
- }
475
- /**
476
- * run WebDriver if capabilities clearly identify it as it
477
- */
478
- if (config.capabilities && config.capabilities.alwaysMatch) {
479
- return 'webdriver';
480
- }
481
- /**
482
- * make a head request to check if a driver is available
483
- */
484
- const resp = await new Promise((resolve) => {
485
- const req = http_1.default.request(constants_1.DRIVER_DEFAULT_ENDPOINT, resolve);
486
- req.on('error', (error) => resolve({ error }));
487
- req.end();
488
- });
489
- /**
490
- * kill agent otherwise process will stale
491
- */
492
- const driverEndpointHeaders = resp;
493
- if (driverEndpointHeaders.req && driverEndpointHeaders.req.agent) {
494
- driverEndpointHeaders.req.agent.destroy();
495
- }
496
- if (driverEndpointHeaders && driverEndpointHeaders.statusCode === 200) {
497
- return 'webdriver';
498
- }
499
- return 'devtools';
500
- };
501
- exports.getAutomationProtocol = getAutomationProtocol;
502
- /**
503
- * updateCapabilities allows modifying capabilities before session
504
- * is started
505
- *
506
- * NOTE: this method is executed twice when running the WDIO testrunner
507
- */
508
- const updateCapabilities = async (params, automationProtocol) => {
509
- const caps = params.capabilities;
510
- if (automationProtocol && !params.automationProtocol) {
511
- params.automationProtocol = automationProtocol;
512
- }
513
- /**
514
- * attach remote debugging port options to Firefox sessions
515
- * (this will be ignored if not supported)
516
- */
517
- if (automationProtocol === 'webdriver' && caps.browserName === 'firefox') {
518
- if (!caps['moz:firefoxOptions']) {
519
- caps['moz:firefoxOptions'] = {};
520
- }
521
- if (!caps['moz:firefoxOptions'].args) {
522
- caps['moz:firefoxOptions'].args = [];
523
- }
524
- if (!caps['moz:firefoxOptions'].args.includes(constants_1.FF_REMOTE_DEBUG_ARG)) {
525
- caps['moz:firefoxOptions'].args.push(constants_1.FF_REMOTE_DEBUG_ARG, (await (0, get_port_1.default)()).toString());
526
- }
527
- }
528
- };
529
- exports.updateCapabilities = updateCapabilities;
530
- /**
531
- * compare if an object (`base`) contains the same values as another object (`match`)
532
- * @param {object} base object to compare to
533
- * @param {object} match object that needs to match thebase
534
- */
535
- const containsHeaderObject = (base, match) => {
536
- for (const [key, value] of Object.entries(match)) {
537
- if (typeof base[key] === 'undefined' || base[key] !== value) {
538
- return false;
539
- }
540
- }
541
- return true;
542
- };
543
- exports.containsHeaderObject = containsHeaderObject;