@mablhq/mabl-cli 1.16.32 → 1.18.3

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 (152) hide show
  1. package/api/basicApiClient.js +9 -4
  2. package/api/featureSet.js +1 -4
  3. package/api/mablApiClient.js +16 -9
  4. package/browserLauncher/browserLauncherFactory.js +4 -4
  5. package/browserLauncher/elementHandle.js +2 -1
  6. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +8 -1
  7. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +11 -9
  8. package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +23 -29
  9. package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +28 -6
  10. package/browserLauncher/playwrightBrowserLauncher/playwrightHttpRequest.js +5 -1
  11. package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +13 -9
  12. package/browserLauncher/runnerType.js +0 -1
  13. package/cli.js +12 -8
  14. package/commands/applications/applications_cmds/describe.js +4 -4
  15. package/commands/applications/applications_cmds/list.js +4 -4
  16. package/commands/auth/auth_cmds/activate-key.js +1 -1
  17. package/commands/branches/branches_cmds/create.js +4 -4
  18. package/commands/branches/branches_cmds/describe.js +3 -3
  19. package/commands/branches/branches_cmds/list.js +3 -3
  20. package/commands/branches/branches_cmds/merge.js +4 -4
  21. package/commands/commandUtil/codeInsights.js +4 -2
  22. package/commands/commandUtil/describe.js +1 -1
  23. package/commands/commandUtil/fileUtil.js +5 -1
  24. package/commands/commandUtil/util.js +2 -2
  25. package/commands/config/config_cmds/delete.js +1 -1
  26. package/commands/config/config_cmds/set.js +1 -1
  27. package/commands/constants.js +3 -1
  28. package/commands/credentials/credentials_cmds/list.js +4 -4
  29. package/commands/deploy/deploy_cmds/create.js +18 -13
  30. package/commands/deploy/deploy_cmds/describe.js +5 -5
  31. package/commands/deploy/deploy_cmds/executionResultPresenter.js +1 -1
  32. package/commands/deploy/deploy_cmds/list.js +4 -4
  33. package/commands/deploy/deploy_cmds/watch.js +2 -2
  34. package/commands/environments/environments_cmds/create.js +7 -7
  35. package/commands/environments/environments_cmds/delete.js +1 -1
  36. package/commands/environments/environments_cmds/describe.js +4 -4
  37. package/commands/environments/environments_cmds/list.js +4 -4
  38. package/commands/environments/environments_cmds/update.js +2 -2
  39. package/commands/environments/environments_cmds/urls_cmds/add.js +3 -3
  40. package/commands/environments/environments_cmds/urls_cmds/list.js +2 -2
  41. package/commands/flows/flows_cmds/export.js +5 -5
  42. package/commands/flows/flows_cmds/list.js +2 -2
  43. package/commands/link-agents/link-agents_cmds/delete.js +1 -1
  44. package/commands/plans/plans_cmds/describe.js +4 -4
  45. package/commands/plans/plans_cmds/list.js +2 -2
  46. package/commands/test-runs/test-runs_cmds/export.js +2 -2
  47. package/commands/tests/executionUtil.js +5 -5
  48. package/commands/tests/testsUtil.js +30 -18
  49. package/commands/tests/tests_cmds/create.js +3 -3
  50. package/commands/tests/tests_cmds/edit.js +3 -3
  51. package/commands/tests/tests_cmds/export.js +7 -7
  52. package/commands/tests/tests_cmds/import.js +35 -14
  53. package/commands/tests/tests_cmds/list.js +3 -3
  54. package/commands/tests/tests_cmds/run-alpha.js +3 -3
  55. package/commands/tests/tests_cmds/run-cloud.js +4 -4
  56. package/commands/tests/tests_cmds/run-legacy.js +8 -8
  57. package/commands/tests/tests_cmds/run.js +13 -8
  58. package/commands/tests/tests_cmds/trainer_cmds/trainerUtil.js +2 -2
  59. package/commands/tests/tests_cmds/trainer_cmds/update.js +1 -1
  60. package/commands/tests/tests_cmds/trainer_cmds/version.js +2 -2
  61. package/commands/workspaces/workspace_cmds/copy.js +2 -2
  62. package/commands/workspaces/workspace_cmds/describe.js +4 -4
  63. package/commands/workspaces/workspace_cmds/list.js +2 -2
  64. package/configGenerators/flowConfigGenerator.js +1 -1
  65. package/configGenerators/selIdeGenerator.js +6 -6
  66. package/core/messaging/actions/runnerActions.js +2 -2
  67. package/core/trainer/openUtils.js +2 -2
  68. package/core/trainer/trainingSessions.js +26 -26
  69. package/domUtil/index.js +1 -1
  70. package/domUtil/index.js.LICENSE.txt +5 -5
  71. package/env/env.js +5 -1
  72. package/execution/index.js +1 -1
  73. package/execution/index.js.LICENSE.txt +7 -5
  74. package/index.d.ts +0 -1
  75. package/mablApi/index.js +1 -1
  76. package/mablscript/AttributesConstants.js +2 -1
  77. package/mablscript/MablAction.js +1 -1
  78. package/mablscript/MablStep.js +26 -14
  79. package/mablscript/actions/AwaitPDFDownloadAction.js +2 -1
  80. package/mablscript/actions/ConditionAction.js +12 -4
  81. package/mablscript/actions/ExtractAction.js +16 -7
  82. package/mablscript/actions/FindAction.js +105 -80
  83. package/mablscript/actions/GenerateRandomStringAction.js +2 -1
  84. package/mablscript/actions/GetUrlAction.js +2 -2
  85. package/mablscript/actions/GetVariableValue.js +3 -3
  86. package/mablscript/actions/JavaScriptAction.js +16 -16
  87. package/mablscript/diffing/diffingUtil.js +146 -0
  88. package/mablscript/importer.js +26 -8
  89. package/mablscript/steps/AccessibilityCheck.js +9 -7
  90. package/mablscript/steps/AssertStep.js +60 -46
  91. package/mablscript/steps/AssertStepOld.js +41 -23
  92. package/mablscript/steps/AwaitTabStep.js +7 -6
  93. package/mablscript/steps/ClickAndHoldStep.js +6 -6
  94. package/mablscript/steps/ClickStep.js +6 -6
  95. package/mablscript/steps/CreateVariableStep.js +8 -8
  96. package/mablscript/steps/DoubleClickStep.js +7 -7
  97. package/mablscript/steps/DownloadStep.js +3 -2
  98. package/mablscript/steps/EchoStep.js +5 -3
  99. package/mablscript/steps/ElseIfConditionStep.js +5 -2
  100. package/mablscript/steps/EnterTextStep.js +13 -10
  101. package/mablscript/steps/EvaluateFlowStep.js +40 -0
  102. package/mablscript/steps/HoverStep.js +6 -6
  103. package/mablscript/steps/IfConditionStep.js +8 -7
  104. package/mablscript/steps/NavigateStep.js +1 -1
  105. package/mablscript/steps/ReleaseStep.js +7 -6
  106. package/mablscript/steps/RemoveCookieStep.js +2 -3
  107. package/mablscript/steps/SelectStep.js +5 -5
  108. package/mablscript/steps/SendHttpRequestStep.js +3 -3
  109. package/mablscript/steps/SendKeyStep.js +9 -9
  110. package/mablscript/steps/SetCookieStep.js +2 -4
  111. package/mablscript/steps/SetFilesStep.js +5 -5
  112. package/mablscript/steps/SetViewportStep.js +2 -2
  113. package/mablscript/steps/SwitchContextStep.js +12 -12
  114. package/mablscript/steps/VisitUrlStep.js +3 -2
  115. package/mablscript/steps/WaitStep.js +2 -5
  116. package/mablscript/steps/WaitUntilStep.js +3 -3
  117. package/{browserLauncher/puppeteerBrowserLauncher/internals.js → mablscript/types/EvaluateFlowStepDescriptor.js} +0 -0
  118. package/mablscript/types/GetCurrentLocationDescriptor.js +4 -3
  119. package/mablscript/types/OperatingSystemDescriptor.js +5 -1
  120. package/mablscript/types/VariableNamespace.js +1 -1
  121. package/mablscriptFind/index.js +1 -1
  122. package/mablscriptFind/index.js.LICENSE.txt +5 -5
  123. package/observers/mockObserver.js +4 -2
  124. package/package.json +55 -56
  125. package/popupDismissal/index.js +3 -3
  126. package/providers/authenticationProvider.js +3 -3
  127. package/providers/logging/loggingProvider.js +5 -1
  128. package/proxy/index.js +2 -1
  129. package/proxy/index.js.LICENSE.txt +5 -0
  130. package/reporters/mochAwesome/mochAwesomeReporter.js +11 -7
  131. package/reporters/reporter.js +1 -1
  132. package/resources/mablFind.js +1 -1
  133. package/resources/pdf-viewer/index.js +1 -1
  134. package/resources/pdf-viewer/libEmbeddedPdfHandler.js +11 -2
  135. package/resources/popupDismissal.js +1 -1
  136. package/util/RichPromise.js +1 -0
  137. package/util/actionabilityUtil.js +16 -35
  138. package/util/analytics.js +7 -3
  139. package/util/downloadUtil.js +6 -2
  140. package/util/httpUtil.js +6 -2
  141. package/util/markdownUtil.js +1 -1
  142. package/util/pureUtil.js +5 -1
  143. package/util/resourceUtil.js +5 -1
  144. package/browserLauncher/puppeteerBrowserLauncher/puppeteerBrowser.js +0 -134
  145. package/browserLauncher/puppeteerBrowserLauncher/puppeteerBrowserLauncher.js +0 -45
  146. package/browserLauncher/puppeteerBrowserLauncher/puppeteerElementHandle.js +0 -139
  147. package/browserLauncher/puppeteerBrowserLauncher/puppeteerFrame.js +0 -115
  148. package/browserLauncher/puppeteerBrowserLauncher/puppeteerHttpRequest.js +0 -38
  149. package/browserLauncher/puppeteerBrowserLauncher/puppeteerHttpResponse.js +0 -27
  150. package/browserLauncher/puppeteerBrowserLauncher/puppeteerJsHandle.js +0 -36
  151. package/browserLauncher/puppeteerBrowserLauncher/puppeteerPage.js +0 -331
  152. package/browserLauncher/puppeteerBrowserLauncher/wrappers.js +0 -25
@@ -171,10 +171,19 @@ class EmbeddedPdfHandler {
171
171
  // we're likely in the chrome viewer, so window.location actually has
172
172
  // the right URL
173
173
  pdfUrl = window.location.href;
174
+ } // Firefox does not always get the correct offsetHeight and offsetWidth
175
+ // so if the value returned is 0, then just leave the size to the default size
176
+
177
+
178
+ if (originalPdfElement.offsetHeight && originalPdfElement.offsetWidth) {
179
+ viewerElem.height = originalPdfElement.offsetHeight;
180
+ viewerElem.width = originalPdfElement.offsetWidth;
181
+ } else if (originalPdfElement.height && originalPdfElement.width) {
182
+ // Default to height and width of original if available
183
+ viewerElem.height = originalPdfElement.height;
184
+ viewerElem.width = originalPdfElement.width;
174
185
  }
175
186
 
176
- viewerElem.height = originalPdfElement.offsetHeight;
177
- viewerElem.width = originalPdfElement.offsetWidth;
178
187
  viewerElem.id = '__mabl_pdf_viewer_' + this.idSanitize(this.getPdfFilenameFromUrl(pdfUrl));
179
188
  viewerElem.src = this.getEmbeddedViewerURL(pdfUrl);
180
189
  viewerElem.setAttribute(MABL_PROCESSED_PDF_ATTRIBUTE, 'true');
@@ -1 +1 @@
1
- window.popupDismissal=function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";n.r(e),n.d(e,"elementsByHigherZIndex",(function(){return i})),n.d(e,"elementsAtCoordinate",(function(){return d})),n.d(e,"getAllElementsAbove",(function(){return h})),n.d(e,"detectAndDismissPopupCandidates",(function(){return g})),n.d(e,"elementsInFrontCount",(function(){return p}));const o=["close","dismiss","exit","not at this time","no thanks","no, thanks","i, agree","i agree"],r=[{attributeName:"className",matchFunction:a},{attributeName:"name",matchFunction:a},{attributeName:"id",matchFunction:a},{attributeName:"href",matchFunction:a},{attributeName:"innerText",matchFunction:function(t,e){const n=new RegExp(`\\b${e}\\b`);return!!t.toLowerCase().match(n)}}];function i(t){return Array.from(document.querySelectorAll("body *")).reduce((e,n)=>{const o=parseFloat(window.getComputedStyle(n).zIndex);return!Number.isNaN(o)&&o>=t&&(e.has(o)?e.get(o).push(n):e.set(o,[n])),e},new Map)}function u(t){const e=t=>void 0===t||"html"===t.tagName.toLowerCase();let n=t;for(;!e(n);){const t=window.getComputedStyle(n).zIndex;if(t&&"auto"!==t)return parseInt(t,10);n=(null==n?void 0:n.parentElement)?n.parentElement:void 0}return 0}function s(t){let e=[t];return Array.from(t.children).forEach(t=>{e=e.concat(s(t))}),e}function a(t,e){return t.toLowerCase().includes(e)}function c(t){const e=[];return t.forEach(t=>{const n=[],i=[];t.elements.forEach(t=>{var e,u;(null===(e=t)||void 0===e?void 0:e.offsetParent)&&(["BUTTON","A","DIV"].includes(null===(u=t.tagName)||void 0===u?void 0:u.toUpperCase())&&function(t){let e=0;return r.forEach(n=>{o.forEach(o=>{t.getAttribute(n.attributeName)&&n.matchFunction(t.getAttribute(n.attributeName),o)&&(e+=1)})}),e}(t)&&!i.includes(t)?i.push(t):function(t){if(t.getBoundingClientRect){const e=t.getBoundingClientRect(),n=e.width/window.innerWidth,o=e.height/window.innerHeight;return n>.95&&o>.95}return!1}(t)&&n.push(t))}),e.push({zIndex:t.zIndex,actionableElements:i,domCovering:n,dismissedStatus:!1,elementsInFront:0})}),e}function l(t,e){const n=t.getBoundingClientRect(),o=n.height/2,r=e?1:n.width/2,i=new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window,detail:0,screenX:n.left+r,screenY:n.top+o,clientX:t.clientLeft+r,clientY:t.clientTop+o,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,button:0,relatedTarget:void 0});t.dispatchEvent(i)}function d(t,e,n){const o=void 0!==e?e:m(t).x,r=void 0!==n?n:m(t).y,i=document.elementsFromPoint(o,r),u=i.findIndex(e=>e===t);return u?i.slice(0,u):[]}function f(t){return new Promise(e=>setTimeout(e,t))}function m(t){const e=t.getBoundingClientRect();return{x:Math.floor(e.x),y:Math.floor(e.y),top:Math.floor(e.top),bottom:Math.ceil(e.bottom),left:Math.floor(e.left),right:Math.ceil(e.right),height:Math.floor(e.bottom)-Math.ceil(e.top),width:Math.floor(e.right)-Math.ceil(e.left)}}function h(t,e){if(0===e.length)return[];const n=u(t),o=Math.min(...null==e?void 0:e.map(t=>u(t)));if(o<=n)return[];const r=i(o),a=Array.from(r).map(([t,e])=>({zIndex:t,elements:e.flatMap(s).reverse()}));return a.sort((t,e)=>e.zIndex-t.zIndex),a}async function g(t){const e=m(t);try{let n=d(t,e.x,e.y);const o=n.length;if(0===o)return{elementsInFront:0,dismissedStatus:!1};const r=async function(n,r){for(const i of n)if(l(i,r),await f(750),d(t,e.x,e.y).length<o)return!0;return!1};let i=h(t,n);const u=c(i);for(const t of u){let e=await r(t.domCovering,!0);if(e||(e=await r(t.actionableElements,!1)),e)return{dismissedStatus:!0,elementsInFront:0}}n=d(t,e.x,e.y),i=h(t,n);const s=c(i),a=s.length?s[0]:{zIndex:0,elementsInFront:0,dismissedStatus:!1,domCovering:[],actionableElements:[]};return a.elementsInFront=n.length,a.dismissedStatus=!1,{dismissedStatus:a.dismissedStatus,elementsInFront:a.elementsInFront}}catch(t){return{elementsInFront:0,dismissedStatus:!1,error:t.toString()}}}function p(t){return d(t).length}}]);
1
+ window.popupDismissal=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";n.r(e),n.d(e,"elementsByHigherZIndex",(function(){return i})),n.d(e,"elementsAtCoordinate",(function(){return d})),n.d(e,"getAllElementsAbove",(function(){return h})),n.d(e,"detectAndDismissPopupCandidates",(function(){return g})),n.d(e,"elementsInFrontCount",(function(){return p}));const r=["close","dismiss","exit","not at this time","no thanks","no, thanks","i, agree","i agree"],o=[{attributeName:"className",matchFunction:a},{attributeName:"name",matchFunction:a},{attributeName:"id",matchFunction:a},{attributeName:"href",matchFunction:a},{attributeName:"innerText",matchFunction:function(t,e){const n=new RegExp(`\\b${e}\\b`);return!!t.toLowerCase().match(n)}}];function i(t){return Array.from(document.querySelectorAll("body *")).reduce((e,n)=>{const r=parseFloat(window.getComputedStyle(n).zIndex);return!Number.isNaN(r)&&r>=t&&(e.has(r)?e.get(r).push(n):e.set(r,[n])),e},new Map)}function u(t){const e=t=>void 0===t||"html"===t.tagName.toLowerCase();let n=t;for(;!e(n);){const t=window.getComputedStyle(n).zIndex;if(t&&"auto"!==t)return parseInt(t,10);n=(null==n?void 0:n.parentElement)?n.parentElement:void 0}return 0}function s(t){let e=[t];return Array.from(t.children).forEach(t=>{e=e.concat(s(t))}),e}function a(t,e){return t.toLowerCase().includes(e)}function c(t){const e=[];return t.forEach(t=>{const n=[],i=[];t.elements.forEach(t=>{var e;(null==t?void 0:t.offsetParent)&&(["BUTTON","A","DIV"].includes(null===(e=t.tagName)||void 0===e?void 0:e.toUpperCase())&&function(t){let e=0;return o.forEach(n=>{r.forEach(r=>{t.getAttribute(n.attributeName)&&n.matchFunction(t.getAttribute(n.attributeName),r)&&(e+=1)})}),e}(t)&&!i.includes(t)?i.push(t):function(t){if(t.getBoundingClientRect){const e=t.getBoundingClientRect(),n=e.width/window.innerWidth,r=e.height/window.innerHeight;return n>.95&&r>.95}return!1}(t)&&n.push(t))}),e.push({zIndex:t.zIndex,actionableElements:i,domCovering:n,dismissedStatus:!1,elementsInFront:0})}),e}function l(t,e){const n=t.getBoundingClientRect(),r=n.height/2,o=e?1:n.width/2,i=new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window,detail:0,screenX:n.left+o,screenY:n.top+r,clientX:t.clientLeft+o,clientY:t.clientTop+r,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,button:0,relatedTarget:void 0});t.dispatchEvent(i)}function d(t,e,n){const r=void 0!==e?e:m(t).x,o=void 0!==n?n:m(t).y,i=document.elementsFromPoint(r,o),u=i.findIndex(e=>e===t);return u?i.slice(0,u):[]}function f(t){return new Promise(e=>setTimeout(e,t))}function m(t){const e=t.getBoundingClientRect();return{x:Math.floor(e.x),y:Math.floor(e.y),top:Math.floor(e.top),bottom:Math.ceil(e.bottom),left:Math.floor(e.left),right:Math.ceil(e.right),height:Math.floor(e.bottom)-Math.ceil(e.top),width:Math.floor(e.right)-Math.ceil(e.left)}}function h(t,e){if(0===e.length)return[];const n=u(t),r=Math.min(...null==e?void 0:e.map(t=>u(t)));if(r<=n)return[];const o=i(r),a=Array.from(o).map(([t,e])=>({zIndex:t,elements:e.flatMap(s).reverse()}));return a.sort((t,e)=>e.zIndex-t.zIndex),a}async function g(t){const e=m(t);try{let n=d(t,e.x,e.y);const r=n.length;if(0===r)return{elementsInFront:0,dismissedStatus:!1};const o=async function(n,o){for(const i of n)if(l(i,o),await f(750),d(t,e.x,e.y).length<r)return!0;return!1};let i=h(t,n);const u=c(i);for(const t of u){let e=await o(t.domCovering,!0);if(e||(e=await o(t.actionableElements,!1)),e)return{dismissedStatus:!0,elementsInFront:0}}n=d(t,e.x,e.y),i=h(t,n);const s=c(i),a=s.length?s[0]:{zIndex:0,elementsInFront:0,dismissedStatus:!1,domCovering:[],actionableElements:[]};return a.elementsInFront=n.length,a.dismissedStatus=!1,{dismissedStatus:a.dismissedStatus,elementsInFront:a.elementsInFront}}catch(t){return{elementsInFront:0,dismissedStatus:!1,error:t.toString()}}}function p(t){return d(t).length}}]);
@@ -48,3 +48,4 @@ class RichPromise {
48
48
  }
49
49
  }
50
50
  exports.default = RichPromise;
51
+ Symbol.toStringTag;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -19,15 +23,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
19
23
  return result;
20
24
  };
21
25
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.maybeAddPopupLogic = exports.attemptPopupDismissal = exports.checkActionabilityAt = exports.checkActionabilityAtWithRetries = exports.checkPopupDismissalOnAction = void 0;
26
+ exports.maybeAddPopupLogic = exports.attemptPopupDismissal = exports.checkActionabilityAt = exports.checkPopupDismissalOnAction = void 0;
23
27
  const fs = __importStar(require("fs"));
24
28
  const resourceUtil_1 = require("./resourceUtil");
25
29
  const messaging_1 = require("../core/messaging/messaging");
26
- const ExecutorUtils_1 = require("../execution/actions/ExecutorUtils");
27
30
  const logUtils_1 = require("./logUtils");
28
31
  const loggingProvider_1 = require("../providers/logging/loggingProvider");
29
- const ACTIONABILITY_CHECK_SCRIPT_LOCATION = resourceUtil_1.findResource('actionabilityCheck.js');
30
- const EMBEDDED_POPUP_SCRIPT_LOCATION = resourceUtil_1.findResource('popupDismissal.js');
32
+ const ACTIONABILITY_CHECK_SCRIPT_LOCATION = (0, resourceUtil_1.findResource)('actionabilityCheck.js');
33
+ const EMBEDDED_POPUP_SCRIPT_LOCATION = (0, resourceUtil_1.findResource)('popupDismissal.js');
31
34
  const NO_CLICKABLE_POINT_ERROR = 'Unable to find a clickable point for the element';
32
35
  const POPUP_ERROR_MESSAGE_HINT = 'intercepts pointer events';
33
36
  let embeddedPopupScript;
@@ -47,37 +50,15 @@ async function checkPopupDismissalOnAction(elementHandle, action, executionConte
47
50
  return checkPopupDismissalOnAction(elementHandle, action, executionContext, false);
48
51
  }
49
52
  if (!dismissalResult) {
50
- logUtils_1.logWebUIAndCliOutput(`Found element may not be actionable`, loggingProvider_1.LogLevel.Warn, executionContext, {
53
+ (0, logUtils_1.logWebUIAndCliOutput)(`Found element may not be actionable`, loggingProvider_1.LogLevel.Warn, executionContext, {
51
54
  executionPhase: messaging_1.ExecutionPhase.DURING_ACTION,
52
55
  });
53
- logUtils_1.logInternal(`Found element might not be actionable. ${error.toString()}`);
56
+ (0, logUtils_1.logInternal)(`Found element might not be actionable. ${error.toString()}`);
54
57
  }
55
58
  }
56
59
  }
57
60
  }
58
61
  exports.checkPopupDismissalOnAction = checkPopupDismissalOnAction;
59
- async function checkActionabilityAtWithRetries(elementHandle, executionContext, failIfClickablePointWasNotFound = true) {
60
- var _a, _b, _c, _d;
61
- let actionabilityResult;
62
- try {
63
- actionabilityResult = await ExecutorUtils_1.runWithRetries(() => checkActionabilityAt(elementHandle, executionContext), 10, [
64
- 'Element not at point',
65
- 'Element not clickable at point',
66
- NO_CLICKABLE_POINT_ERROR,
67
- ], executionContext);
68
- }
69
- catch (error) {
70
- if (failIfClickablePointWasNotFound &&
71
- error.message === NO_CLICKABLE_POINT_ERROR) {
72
- throw new Error(NO_CLICKABLE_POINT_ERROR);
73
- }
74
- logUtils_1.logWebUIAndCliOutput(`Found element may not be actionable`, loggingProvider_1.LogLevel.Warn, executionContext, {
75
- executionPhase: messaging_1.ExecutionPhase.DURING_ACTION,
76
- });
77
- logUtils_1.logInternal(`Found element might not be actionable at the expected point (x: ${(_b = (_a = actionabilityResult === null || actionabilityResult === void 0 ? void 0 : actionabilityResult.clickablePoint) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : 'Not found'}, y: ${(_d = (_c = actionabilityResult === null || actionabilityResult === void 0 ? void 0 : actionabilityResult.clickablePoint) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : 'Not found'}), performing action anyway`);
78
- }
79
- }
80
- exports.checkActionabilityAtWithRetries = checkActionabilityAtWithRetries;
81
62
  async function checkActionabilityAt(elementHandle, executionContext, recheckOnFail = true) {
82
63
  let point = await elementHandle.clickablePoint();
83
64
  if (point === undefined) {
@@ -98,7 +79,7 @@ async function checkActionabilityAt(elementHandle, executionContext, recheckOnFa
98
79
  const result = await elementHandle.evaluate((node, point) => mablCheckActionability(node, point), { ...point });
99
80
  if (result !== 'done') {
100
81
  if (typeof result === 'object' && 'actionabilityDescription' in result) {
101
- logUtils_1.logInternal(`${result.actionabilityDescription} intercepts pointer events. Trying to auto-dismiss popups.`);
82
+ (0, logUtils_1.logInternal)(`${result.actionabilityDescription} intercepts pointer events. Trying to auto-dismiss popups.`);
102
83
  const hasPopup = await isElementWithPopup(elementHandle);
103
84
  if (hasPopup) {
104
85
  return {
@@ -125,27 +106,27 @@ async function attemptPopupDismissal(element, executionContext) {
125
106
  await maybeAddPopupLogic(element);
126
107
  const { dismissedStatus, elementsInFront, error } = await element.evaluate((element) => window.popupDismissal.detectAndDismissPopupCandidates(element));
127
108
  if (error) {
128
- logUtils_1.logInternal(`Error while trying to dismiss popups: ${error}`);
109
+ (0, logUtils_1.logInternal)(`Error while trying to dismiss popups: ${error}`);
129
110
  }
130
111
  if (!dismissedStatus) {
131
112
  if (elementsInFront) {
132
- logUtils_1.logInternal('Failed to auto dismiss and there are still elements in front. Sending escape key to body.');
113
+ (0, logUtils_1.logInternal)('Failed to auto dismiss and there are still elements in front. Sending escape key to body.');
133
114
  const bodyElement = await frame.$('BODY');
134
115
  if (bodyElement) {
135
116
  await bodyElement.press('Escape');
136
117
  }
137
118
  const elementsInFront = await element.evaluate((element) => window.popupDismissal.elementsInFrontCount(element));
138
119
  if (elementsInFront) {
139
- logUtils_1.logInternal('The popup did not dismiss using the escape key.');
120
+ (0, logUtils_1.logInternal)('The popup did not dismiss using the escape key.');
140
121
  return false;
141
122
  }
142
123
  }
143
124
  else {
144
- logUtils_1.logInternal('Failed to auto dismiss. No elements found in front of target element.');
125
+ (0, logUtils_1.logInternal)('Failed to auto dismiss. No elements found in front of target element.');
145
126
  return false;
146
127
  }
147
128
  }
148
- logUtils_1.logWebUIAndCliOutput(`A popup was detected and dismissed`, loggingProvider_1.LogLevel.Info, executionContext, {
129
+ (0, logUtils_1.logWebUIAndCliOutput)(`A popup was detected and dismissed`, loggingProvider_1.LogLevel.Info, executionContext, {
149
130
  executionPhase: messaging_1.ExecutionPhase.DURING_ACTION,
150
131
  });
151
132
  return true;
package/util/analytics.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -97,8 +101,8 @@ function trackEvent(event, userId, properties) {
97
101
  context: {
98
102
  app: {
99
103
  build: env_1.ENV,
100
- name: pureUtil_1.getCliName(),
101
- version: pureUtil_1.getCliVersion(),
104
+ name: (0, pureUtil_1.getCliName)(),
105
+ version: (0, pureUtil_1.getCliVersion)(),
102
106
  },
103
107
  os: {
104
108
  name: os.platform(),
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -43,7 +47,7 @@ async function awaitDownload(downloadDirectory, filePathSuffix, timeoutMillis =
43
47
  foundDownloadPath = latestFile;
44
48
  }
45
49
  else {
46
- await testsUtil_1.sleep(AWAIT_DOWNLOAD_POLLING_INTERVAL_MILLISECONDS);
50
+ await (0, testsUtil_1.sleep)(AWAIT_DOWNLOAD_POLLING_INTERVAL_MILLISECONDS);
47
51
  }
48
52
  }
49
53
  return foundDownloadPath;
package/util/httpUtil.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -24,7 +28,7 @@ const cliConfigProvider_1 = require("../providers/cliConfigProvider");
24
28
  const https = __importStar(require("https"));
25
29
  const pureUtil_1 = require("./pureUtil");
26
30
  const https_proxy_agent_1 = require("https-proxy-agent");
27
- exports.USER_AGENT = `${pureUtil_1.getCliName()}@${pureUtil_1.getCliVersion()}`;
31
+ exports.USER_AGENT = `${(0, pureUtil_1.getCliName)()}@${(0, pureUtil_1.getCliVersion)()}`;
28
32
  exports.USER_AGENT_HEADER = 'User-Agent';
29
33
  exports.EXECUTION_ENGINE_SSL_VERIFY = false;
30
34
  function setAgentSslVerification(agent, verifySsl) {
@@ -109,7 +109,7 @@ function humanizedMablStatusToGithubIcon(status) {
109
109
  exports.humanizedMablStatusToGithubIcon = humanizedMablStatusToGithubIcon;
110
110
  function maybeCapitalize(input) {
111
111
  if (input) {
112
- return change_case_1.capitalCase(input.replace('_', ' '));
112
+ return (0, change_case_1.capitalCase)(input.replace('_', ' '));
113
113
  }
114
114
  return '';
115
115
  }
package/util/pureUtil.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,134 +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.PuppeteerBrowser = void 0;
7
- const browserLauncher_1 = require("../browserLauncher");
8
- const puppeteer_core_1 = __importDefault(require("puppeteer-core"));
9
- const events_1 = __importDefault(require("events"));
10
- const puppeteerBrowserLauncher_1 = require("./puppeteerBrowserLauncher");
11
- const puppeteerPage_1 = require("./puppeteerPage");
12
- const runnerType_1 = require("../runnerType");
13
- class PuppeteerBrowser extends events_1.default {
14
- constructor(browser, downloadDirectory, credentials) {
15
- var _a;
16
- super();
17
- this.browser = browser;
18
- this.downloadDirectory = downloadDirectory;
19
- this.credentials = credentials;
20
- this.puppeteerPages = new Map();
21
- (_a = this.browser
22
- .process()) === null || _a === void 0 ? void 0 : _a.on('close', () => this.emit(browserLauncher_1.BrowserEvent.BrowserDestroyed));
23
- this.browser.on('targetcreated', async (target) => {
24
- const page = await target.page();
25
- if (page) {
26
- this.emit(browserLauncher_1.BrowserEvent.PageCreated, await this.getOrCreatePage(page));
27
- }
28
- });
29
- this.browser.on("disconnected", () => this.emit(browserLauncher_1.BrowserEvent.Disconnected));
30
- browser._connection.on('Browser.downloadWillBegin', (event) => this.emit(browserLauncher_1.BrowserEvent.DownloadWillBegin, {
31
- guid: event.guid,
32
- suggestedFilename: event.suggestedFilename,
33
- url: event.url,
34
- }));
35
- browser._connection.on('Browser.downloadProgress', (event) => this.emit(browserLauncher_1.BrowserEvent.DownloadProgress, {
36
- guid: event.guid,
37
- totalBytes: event.totalBytes,
38
- receivedBytes: event.receivedBytes,
39
- state: event.state,
40
- }));
41
- }
42
- getRunnerType() {
43
- return runnerType_1.RunnerType.Puppeteer;
44
- }
45
- getDownloadDirectory() {
46
- return this.downloadDirectory;
47
- }
48
- makeCdpCall(method, paramArgs) {
49
- const connection = this.browser._connection;
50
- return connection.send(method, paramArgs);
51
- }
52
- disconnect() {
53
- this.browser.disconnect();
54
- return Promise.resolve();
55
- }
56
- reconnect() {
57
- const webSocketEndpoint = this.wsEndpoint();
58
- if (!webSocketEndpoint) {
59
- throw new Error(`No browser websocket endpoint configured or supplied for connection`);
60
- }
61
- return browserLauncher_1.BrowserLauncherFactory.createRunner(this.getRunnerType()).connect({
62
- defaultDeviceDescriptor: undefined,
63
- browserWSEndpoint: webSocketEndpoint,
64
- }, this.getDownloadDirectory());
65
- }
66
- async newPage() {
67
- return this.getOrCreatePage(await this.browser.newPage());
68
- }
69
- isConnected() {
70
- return this.browser.isConnected();
71
- }
72
- async setDownloadBehavior(downloadDirectory) {
73
- const request = {
74
- behavior: 'allow',
75
- downloadPath: downloadDirectory,
76
- eventsEnabled: true,
77
- };
78
- await this.makeCdpCall('Browser.setDownloadBehavior', request);
79
- }
80
- wsEndpoint() {
81
- return this.browser.wsEndpoint();
82
- }
83
- close() {
84
- return this.browser.close();
85
- }
86
- async pages() {
87
- const pages = await this.browser.pages();
88
- return Promise.all(pages.map((page) => this.getOrCreatePage(page)));
89
- }
90
- async getExtensionBackgroundPage(extensionId) {
91
- const targets = this.browser.targets();
92
- const target = targets.find((target) => target.type() === 'background_page' &&
93
- target.url().includes(extensionId));
94
- if (target) {
95
- const backgroundPage = await target.page();
96
- if (!backgroundPage) {
97
- throw new browserLauncher_1.RunnerError('No background page found');
98
- }
99
- return this.getOrCreatePage(backgroundPage);
100
- }
101
- throw new Error('mabl test initialization failure, unable to locate mabl extension page, please try again');
102
- }
103
- async waitForPage(opener, options) {
104
- try {
105
- const pageTarget = opener.getPuppeteerPage().target();
106
- const newTarget = await this.browser.waitForTarget((target) => target.opener() === pageTarget, puppeteerBrowserLauncher_1.convertWaitForOptions(options));
107
- return this.getOrCreatePage((await newTarget.page()));
108
- }
109
- catch (e) {
110
- if (e instanceof puppeteer_core_1.default.errors.TimeoutError) {
111
- throw new browserLauncher_1.RUNNER_ERRORS.TimeoutError(e.message);
112
- }
113
- throw new browserLauncher_1.RunnerError(e.message);
114
- }
115
- }
116
- getPuppeteerBrowser() {
117
- return this.browser;
118
- }
119
- onPageClose(page) {
120
- this.puppeteerPages.delete(page.getPageId());
121
- this.emit(browserLauncher_1.BrowserEvent.PageDestroyed, page);
122
- }
123
- async getOrCreatePage(page) {
124
- const pageId = page.target()._targetId;
125
- if (!this.puppeteerPages.has(pageId)) {
126
- const newPage = new puppeteerPage_1.PuppeteerPage(page, this);
127
- this.puppeteerPages.set(pageId, newPage);
128
- }
129
- const puppeteerPage = this.puppeteerPages.get(pageId);
130
- await puppeteerPage.waitForInitialization();
131
- return puppeteerPage;
132
- }
133
- }
134
- exports.PuppeteerBrowser = PuppeteerBrowser;
@@ -1,45 +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.convertWaitForOptions = exports.PuppeteerBrowserLauncher = void 0;
7
- const puppeteer_core_1 = __importDefault(require("puppeteer-core"));
8
- const types_1 = require("../types");
9
- const puppeteerBrowser_1 = require("./puppeteerBrowser");
10
- class PuppeteerBrowserLauncher {
11
- async connect(options, currentDownloadPath) {
12
- return new puppeteerBrowser_1.PuppeteerBrowser(await puppeteer_core_1.default.connect({
13
- browserWSEndpoint: options.browserWSEndpoint,
14
- defaultViewport: options.defaultDeviceDescriptor,
15
- }), currentDownloadPath);
16
- }
17
- async launch(options) {
18
- const browser = new puppeteerBrowser_1.PuppeteerBrowser(await puppeteer_core_1.default.launch({
19
- ignoreHTTPSErrors: true,
20
- ...options,
21
- }), options.downloadPath, options.credentials);
22
- if (options.downloadPath) {
23
- await browser.setDownloadBehavior(options.downloadPath);
24
- }
25
- return browser;
26
- }
27
- }
28
- exports.PuppeteerBrowserLauncher = PuppeteerBrowserLauncher;
29
- function convertWaitForOptions(options) {
30
- return {
31
- timeout: options === null || options === void 0 ? void 0 : options.timeout,
32
- waitUntil: convertWaitUntil(options === null || options === void 0 ? void 0 : options.waitUntil),
33
- };
34
- }
35
- exports.convertWaitForOptions = convertWaitForOptions;
36
- function convertWaitUntil(waitUntil) {
37
- switch (waitUntil) {
38
- case types_1.LifecycleEvent.DomContentLoaded:
39
- return 'domcontentloaded';
40
- case types_1.LifecycleEvent.NetworkIdle:
41
- return 'networkidle2';
42
- default:
43
- return 'load';
44
- }
45
- }
@@ -1,139 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PuppeteerElementHandle = void 0;
4
- const puppeteerJsHandle_1 = require("./puppeteerJsHandle");
5
- const utils_1 = require("../utils");
6
- const testsUtil_1 = require("../../commands/tests/testsUtil");
7
- const elementHandle_1 = require("../elementHandle");
8
- const pureUtil_1 = require("../../util/pureUtil");
9
- const msBetweenClicks = 100;
10
- class PuppeteerElementHandle extends puppeteerJsHandle_1.PuppeteerJsHandle {
11
- constructor(element, parentPage) {
12
- super(element, parentPage);
13
- this.element = element;
14
- this.parentPage = parentPage;
15
- }
16
- uploadFile(filePath) {
17
- return this.element.uploadFile(filePath);
18
- }
19
- async contentFrame() {
20
- const frame = await this.element.contentFrame();
21
- return utils_1.mapIfNotNull(frame, (frame) => this.parentPage.getOrCreateFrame(frame));
22
- }
23
- focus() {
24
- return this.element.focus();
25
- }
26
- select(value) {
27
- return this.element.select(value);
28
- }
29
- clickablePoint() {
30
- return this.element._clickablePoint();
31
- }
32
- scrollIntoViewIfNeeded() {
33
- return this.element._scrollIntoViewIfNeeded();
34
- }
35
- hover() {
36
- return this.element.hover();
37
- }
38
- click(options) {
39
- if (options === null || options === void 0 ? void 0 : options.trial) {
40
- return Promise.resolve();
41
- }
42
- return this.element.click(options);
43
- }
44
- async doubleClick(options) {
45
- if (options === null || options === void 0 ? void 0 : options.trial) {
46
- return Promise.resolve();
47
- }
48
- await this.element.click();
49
- await testsUtil_1.sleep(msBetweenClicks);
50
- return this.element.click({ clickCount: 2 });
51
- }
52
- asElement() {
53
- return utils_1.mapIfNotNull(this.handle.asElement(), (handle) => new PuppeteerElementHandle(handle, this.parentPage));
54
- }
55
- type(text, options) {
56
- return this.element.type(text, options);
57
- }
58
- async $x(xpathQuery) {
59
- return (await this.element.$x(xpathQuery)).map((element) => new PuppeteerElementHandle(element, this.parentPage));
60
- }
61
- async boundingBox() {
62
- const boundingBox = await this.element.boundingBox();
63
- return utils_1.mapIfNotNull(boundingBox, (boundingBox) => boundingBox);
64
- }
65
- frame() {
66
- return Promise.resolve(utils_1.mapIfNotNull(this.element.executionContext().frame(), (frame) => this.parentPage.getOrCreateFrame(frame)));
67
- }
68
- press(key) {
69
- return this.element.press(key);
70
- }
71
- getRemoteObjectId() {
72
- return this.element._remoteObject.objectId;
73
- }
74
- async highlight(highlightDurationMillis, highlightPhases) {
75
- await this.enableDom();
76
- await this.enableOverlay();
77
- const nodeInfo = await this.makeCdpCall('DOM.describeNode', {
78
- objectId: this.getRemoteObjectId(),
79
- depth: -1,
80
- pierce: true,
81
- });
82
- const highlightConfig = {
83
- backendNodeId: nodeInfo.node.backendNodeId,
84
- highlightConfig: {
85
- borderColor: elementHandle_1.getHighlightColor(0),
86
- contentColor: elementHandle_1.getHighlightColor(1),
87
- colorFormat: 'rgb',
88
- },
89
- };
90
- await this.fadeInOutHighlight(highlightConfig, highlightDurationMillis, highlightPhases);
91
- await this.hideHighlight();
92
- }
93
- async enableDom() {
94
- await this.makeCdpCall('DOM.enable');
95
- }
96
- async enableOverlay() {
97
- await this.makeCdpCall('Overlay.enable');
98
- }
99
- async hideHighlight() {
100
- await this.makeCdpCall('Overlay.hideHighlight');
101
- }
102
- async fadeInOutHighlight(highlightConfig, highlightDurationMillis, highlightPhases) {
103
- var _a;
104
- if (highlightPhases <= 0) {
105
- throw new Error('Highlight phases must be greater than 0');
106
- }
107
- const phaseIntervalMilliseconds = highlightDurationMillis / highlightPhases;
108
- for (let iteration = 0; iteration < highlightPhases; iteration++) {
109
- if (((_a = highlightConfig.highlightConfig.contentColor) === null || _a === void 0 ? void 0 : _a.a) !== undefined) {
110
- const x = iteration / highlightPhases;
111
- highlightConfig.highlightConfig.contentColor.a =
112
- x * (1 - x) * 4 * elementHandle_1.MAX_HIGHLIGHT_OPACITY;
113
- }
114
- await this.makeCdpCall('Overlay.highlightNode', highlightConfig);
115
- await testsUtil_1.sleep(phaseIntervalMilliseconds);
116
- }
117
- }
118
- getCdpClient() {
119
- return this.element._client;
120
- }
121
- makeCdpCall(method, paramArgs) {
122
- return this.getCdpClient().send(method, paramArgs);
123
- }
124
- getValue() {
125
- return this.element.evaluate((el) => el.value);
126
- }
127
- async getInnerText() {
128
- const result = await this.element.evaluate((el) => el.innerText);
129
- return pureUtil_1.isNullish(result) ? undefined : result;
130
- }
131
- getTagName() {
132
- return this.element.evaluate((el) => el.tagName.toLowerCase());
133
- }
134
- async getAttribute(attributeName) {
135
- const result = await this.element.evaluate((el, attributeName) => el.getAttribute(attributeName), attributeName);
136
- return pureUtil_1.isNullish(result) ? undefined : result;
137
- }
138
- }
139
- exports.PuppeteerElementHandle = PuppeteerElementHandle;