webdriverio 6.6.7 → 6.7.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 (126) hide show
  1. package/build/commands/browser/$$.d.ts +3 -1
  2. package/build/commands/browser/$$.d.ts.map +1 -1
  3. package/build/commands/browser/$.d.ts +4 -1
  4. package/build/commands/browser/$.d.ts.map +1 -1
  5. package/build/commands/browser/$.js +2 -2
  6. package/build/commands/browser/addCommand.d.ts.map +1 -1
  7. package/build/commands/browser/call.d.ts +1 -1
  8. package/build/commands/browser/call.d.ts.map +1 -1
  9. package/build/commands/browser/call.js +5 -2
  10. package/build/commands/browser/custom$$.d.ts +3 -1
  11. package/build/commands/browser/custom$$.d.ts.map +1 -1
  12. package/build/commands/browser/custom$$.js +4 -4
  13. package/build/commands/browser/custom$.d.ts +3 -1
  14. package/build/commands/browser/custom$.d.ts.map +1 -1
  15. package/build/commands/browser/custom$.js +3 -3
  16. package/build/commands/browser/debug.d.ts +3 -1
  17. package/build/commands/browser/debug.d.ts.map +1 -1
  18. package/build/commands/browser/debug.js +7 -4
  19. package/build/commands/browser/deleteCookies.d.ts +3 -1
  20. package/build/commands/browser/deleteCookies.d.ts.map +1 -1
  21. package/build/commands/browser/deleteCookies.js +2 -2
  22. package/build/commands/browser/execute.d.ts +3 -1
  23. package/build/commands/browser/execute.d.ts.map +1 -1
  24. package/build/commands/browser/execute.js +1 -2
  25. package/build/commands/browser/executeAsync.d.ts +3 -1
  26. package/build/commands/browser/executeAsync.d.ts.map +1 -1
  27. package/build/commands/browser/executeAsync.js +1 -2
  28. package/build/commands/browser/getCookies.d.ts +3 -1
  29. package/build/commands/browser/getCookies.d.ts.map +1 -1
  30. package/build/commands/browser/getCookies.js +2 -2
  31. package/build/commands/browser/getPuppeteer.d.ts +3 -4
  32. package/build/commands/browser/getPuppeteer.d.ts.map +1 -1
  33. package/build/commands/browser/getPuppeteer.js +11 -4
  34. package/build/commands/browser/getWindowSize.d.ts +3 -1
  35. package/build/commands/browser/getWindowSize.d.ts.map +1 -1
  36. package/build/commands/browser/keys.d.ts +3 -1
  37. package/build/commands/browser/keys.d.ts.map +1 -1
  38. package/build/commands/browser/mock.d.ts +5 -3
  39. package/build/commands/browser/mock.d.ts.map +1 -1
  40. package/build/commands/browser/mock.js +2 -1
  41. package/build/commands/browser/newWindow.d.ts +3 -4
  42. package/build/commands/browser/newWindow.d.ts.map +1 -1
  43. package/build/commands/browser/newWindow.js +3 -0
  44. package/build/commands/browser/overwriteCommand.d.ts.map +1 -1
  45. package/build/commands/browser/pause.d.ts +3 -1
  46. package/build/commands/browser/pause.d.ts.map +1 -1
  47. package/build/commands/browser/react$$.d.ts +3 -4
  48. package/build/commands/browser/react$$.d.ts.map +1 -1
  49. package/build/commands/browser/react$.d.ts +3 -4
  50. package/build/commands/browser/react$.d.ts.map +1 -1
  51. package/build/commands/browser/reloadSession.d.ts +3 -1
  52. package/build/commands/browser/reloadSession.d.ts.map +1 -1
  53. package/build/commands/browser/saveRecordingScreen.d.ts +4 -1
  54. package/build/commands/browser/saveRecordingScreen.d.ts.map +1 -1
  55. package/build/commands/browser/saveScreenshot.d.ts +4 -1
  56. package/build/commands/browser/saveScreenshot.d.ts.map +1 -1
  57. package/build/commands/browser/setCookies.d.ts +4 -1
  58. package/build/commands/browser/setCookies.d.ts.map +1 -1
  59. package/build/commands/browser/setCookies.js +2 -1
  60. package/build/commands/browser/setTimeout.d.ts +4 -1
  61. package/build/commands/browser/setTimeout.d.ts.map +1 -1
  62. package/build/commands/browser/setTimeout.js +5 -4
  63. package/build/commands/browser/setWindowSize.d.ts +3 -1
  64. package/build/commands/browser/setWindowSize.d.ts.map +1 -1
  65. package/build/commands/browser/switchWindow.d.ts +3 -1
  66. package/build/commands/browser/switchWindow.d.ts.map +1 -1
  67. package/build/commands/browser/throttle.d.ts +3 -1
  68. package/build/commands/browser/throttle.d.ts.map +1 -1
  69. package/build/commands/browser/touchAction.d.ts +3 -1
  70. package/build/commands/browser/touchAction.d.ts.map +1 -1
  71. package/build/commands/browser/uploadFile.d.ts +3 -1
  72. package/build/commands/browser/uploadFile.d.ts.map +1 -1
  73. package/build/commands/browser/uploadFile.js +1 -5
  74. package/build/commands/browser/url.d.ts +3 -1
  75. package/build/commands/browser/url.d.ts.map +1 -1
  76. package/build/commands/browser/url.js +1 -1
  77. package/build/commands/browser/waitUntil.d.ts +3 -5
  78. package/build/commands/browser/waitUntil.d.ts.map +1 -1
  79. package/build/commands/browser/waitUntil.js +2 -2
  80. package/build/commands/element/$.d.ts +1 -1
  81. package/build/commands/element/$.d.ts.map +1 -1
  82. package/build/commands/element/custom$.d.ts +1 -1
  83. package/build/commands/element/custom$.d.ts.map +1 -1
  84. package/build/commands/element/nextElement.d.ts +2 -0
  85. package/build/commands/element/nextElement.d.ts.map +1 -0
  86. package/build/commands/element/nextElement.js +6 -0
  87. package/build/commands/element/parentElement.d.ts +2 -0
  88. package/build/commands/element/parentElement.d.ts.map +1 -0
  89. package/build/commands/element/parentElement.js +6 -0
  90. package/build/commands/element/previousElement.d.ts +2 -0
  91. package/build/commands/element/previousElement.d.ts.map +1 -0
  92. package/build/commands/element/previousElement.js +6 -0
  93. package/build/commands/element/react$$.d.ts.map +1 -1
  94. package/build/commands/element/react$.d.ts +1 -1
  95. package/build/commands/element/react$.d.ts.map +1 -1
  96. package/build/commands/element.d.ts +3 -0
  97. package/build/commands/element.d.ts.map +1 -1
  98. package/build/commands/element.js +4 -1
  99. package/build/multiremote.d.ts +1 -1
  100. package/build/multiremote.d.ts.map +1 -1
  101. package/build/types.d.ts +14 -0
  102. package/build/types.d.ts.map +1 -0
  103. package/build/types.js +2 -0
  104. package/build/utils/SevereServiceError.d.ts.map +1 -1
  105. package/build/utils/findStrategy.d.ts +2 -2
  106. package/build/utils/findStrategy.d.ts.map +1 -1
  107. package/build/utils/findStrategy.js +12 -3
  108. package/build/utils/getElementObject.d.ts +5 -2
  109. package/build/utils/getElementObject.d.ts.map +1 -1
  110. package/build/utils/getElementObject.js +9 -13
  111. package/build/utils/implicitWait.d.ts +10 -1
  112. package/build/utils/implicitWait.d.ts.map +1 -1
  113. package/build/utils/implicitWait.js +9 -0
  114. package/build/utils/interception/devtools.d.ts +31 -6
  115. package/build/utils/interception/devtools.d.ts.map +1 -1
  116. package/build/utils/interception/devtools.js +10 -9
  117. package/build/utils/interception/index.d.ts +2 -2
  118. package/build/utils/interception/index.d.ts.map +1 -1
  119. package/build/utils/interception/webdriver.d.ts +11 -9
  120. package/build/utils/interception/webdriver.d.ts.map +1 -1
  121. package/build/utils/interception/webdriver.js +7 -7
  122. package/build/utils/refetchElement.d.ts +2 -1
  123. package/build/utils/refetchElement.d.ts.map +1 -1
  124. package/package.json +14 -9
  125. package/webdriverio-core.d.ts +90 -20
  126. package/webdriverio.d.ts +21 -6
@@ -1,2 +1,4 @@
1
- export default function throttle(params: any): Promise<null>;
1
+ /// <reference types="webdriverio/webdriverio-core" />
2
+ /// <reference types="webdriverio" />
3
+ export default function throttle(this: WebdriverIO.BrowserObject, params: WebdriverIO.ThrottleOptions): Promise<null>;
2
4
  //# sourceMappingURL=throttle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/throttle.js"],"names":[],"mappings":"AAsGA,6DAqCC"}
1
+ {"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/throttle.ts"],"names":[],"mappings":";;AAsGA,wBAA8B,QAAQ,CAAE,IAAI,EAAE,WAAW,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,CAAC,eAAe,iBAqC3G"}
@@ -1,2 +1,4 @@
1
- export default function touchAction(...args: any[]): any;
1
+ /// <reference types="webdriverio/webdriverio-core" />
2
+ /// <reference types="webdriverio" />
3
+ export default function touchAction(this: WebdriverIO.BrowserObject, ...args: WebdriverIO.TouchAction[]): any;
2
4
  //# sourceMappingURL=touchAction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"touchAction.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/touchAction.js"],"names":[],"mappings":"AA6DA,yDAEC"}
1
+ {"version":3,"file":"touchAction.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/touchAction.ts"],"names":[],"mappings":";;AA6DA,MAAM,CAAC,OAAO,UAAU,WAAW,CAAE,IAAI,EAAE,WAAW,CAAC,aAAa,EAAE,GAAG,IAAI,EAAE,WAAW,CAAC,WAAW,EAAE,OAEvG"}
@@ -1,2 +1,4 @@
1
- export default function uploadFile(localPath: any): Promise<any>;
1
+ /// <reference types="webdriverio/webdriverio-core" />
2
+ /// <reference types="webdriverio" />
3
+ export default function uploadFile(this: WebdriverIO.BrowserObject, localPath: string): Promise<unknown>;
2
4
  //# sourceMappingURL=uploadFile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"uploadFile.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/uploadFile.js"],"names":[],"mappings":"AA4BA,iEA+BC"}
1
+ {"version":3,"file":"uploadFile.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/uploadFile.ts"],"names":[],"mappings":";;AA4BA,wBAA8B,UAAU,CAAE,IAAI,EAAE,WAAW,CAAC,aAAa,EAAE,SAAS,EAAE,MAAM,oBA0B3F"}
@@ -21,11 +21,7 @@ async function uploadFile(localPath) {
21
21
  .on('data', (data) => zipData.push(data))
22
22
  .on('end', () => this.file(Buffer.concat(zipData).toString('base64')).then(resolve, reject))
23
23
  .append(source, { name: path_1.default.basename(localPath) })
24
- .finalize((err) => {
25
- if (err) {
26
- reject(err);
27
- }
28
- });
24
+ .finalize();
29
25
  });
30
26
  }
31
27
  exports.default = uploadFile;
@@ -1,2 +1,4 @@
1
- export default function url(path: any): any;
1
+ /// <reference types="webdriverio/webdriverio-core" />
2
+ /// <reference types="webdriverio" />
3
+ export default function url(this: WebdriverIO.BrowserObject, path: string): Promise<void>;
2
4
  //# sourceMappingURL=url.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/url.js"],"names":[],"mappings":"AAqCA,4CAUC"}
1
+ {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/url.ts"],"names":[],"mappings":";;AAqCA,MAAM,CAAC,OAAO,UAAU,GAAG,CAAE,IAAI,EAAE,WAAW,CAAC,aAAa,EAAE,IAAI,EAAE,MAAM,iBAUzE"}
@@ -12,6 +12,6 @@ function url(path) {
12
12
  if (typeof this.options.baseUrl === 'string') {
13
13
  path = url_1.default.resolve(this.options.baseUrl, path);
14
14
  }
15
- return this.navigateTo(utils_1.validateUrl(path));
15
+ return this.navigateTo(utils_1.validateUrl(path, null));
16
16
  }
17
17
  exports.default = url;
@@ -1,6 +1,4 @@
1
- export default function _default(condition: any, { timeout, interval, timeoutMsg }?: {
2
- timeout?: any;
3
- interval?: any;
4
- timeoutMsg: any;
5
- }): any;
1
+ /// <reference types="webdriverio/webdriverio-core" />
2
+ /// <reference types="webdriverio" />
3
+ export default function waitUntil(this: WebdriverIO.BrowserObject, condition: () => boolean | Promise<Boolean>, { timeout, interval, timeoutMsg }?: WebdriverIO.WaitUntilOptions): any;
6
4
  //# sourceMappingURL=waitUntil.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"waitUntil.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/waitUntil.js"],"names":[],"mappings":"AA4CA;;;;QAoCC"}
1
+ {"version":3,"file":"waitUntil.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/waitUntil.ts"],"names":[],"mappings":";;AA4CA,MAAM,CAAC,OAAO,UAAU,SAAS,CAC7B,IAAI,EAAE,WAAW,CAAC,aAAa,EAC/B,SAAS,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,EAC3C,EACI,OAAqC,EACrC,QAAuC,EACvC,UAAU,EACb,GAAE,WAAW,CAAC,gBAAqB,OA8BvC"}
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const Timer_1 = __importDefault(require("../../utils/Timer"));
7
- function default_1(condition, { timeout = this.options.waitforTimeout, interval = this.options.waitforInterval, timeoutMsg } = {}) {
7
+ function waitUntil(condition, { timeout = this.options.waitforTimeout, interval = this.options.waitforInterval, timeoutMsg } = {}) {
8
8
  if (typeof condition !== 'function') {
9
9
  throw new Error('Condition is not a function');
10
10
  }
@@ -26,4 +26,4 @@ function default_1(condition, { timeout = this.options.waitforTimeout, interval
26
26
  throw new Error(`waitUntil condition failed with the following reason: ${(e && e.message) || e}`);
27
27
  });
28
28
  }
29
- exports.default = default_1;
29
+ exports.default = waitUntil;
@@ -1,2 +1,2 @@
1
- export default function $(selector: any): Promise<Object>;
1
+ export default function $(selector: any): Promise<any>;
2
2
  //# sourceMappingURL=$.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/$.js"],"names":[],"mappings":"AAsDA,0DAWC"}
1
+ {"version":3,"file":"$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/$.js"],"names":[],"mappings":"AAsDA,uDAWC"}
@@ -1,3 +1,3 @@
1
1
  export default custom$;
2
- declare function custom$(strategyName: any, strategyArguments: any): Promise<Object>;
2
+ declare function custom$(strategyName: any, strategyArguments: any): Promise<any>;
3
3
  //# sourceMappingURL=custom$.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"custom$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/custom$.js"],"names":[],"mappings":";AA4BA,qFAgCC"}
1
+ {"version":3,"file":"custom$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/custom$.js"],"names":[],"mappings":";AA4BA,kFAgCC"}
@@ -0,0 +1,2 @@
1
+ export default function nextElement(): Element;
2
+ //# sourceMappingURL=nextElement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nextElement.d.ts","sourceRoot":"","sources":["../../../src/commands/element/nextElement.js"],"names":[],"mappings":"AAwBA,uCAJY,OAAO,CAMlB"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function nextElement() {
4
+ return this.$(function () { return this.nextElementSibling; });
5
+ }
6
+ exports.default = nextElement;
@@ -0,0 +1,2 @@
1
+ export default function parentElement(): Element;
2
+ //# sourceMappingURL=parentElement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parentElement.d.ts","sourceRoot":"","sources":["../../../src/commands/element/parentElement.js"],"names":[],"mappings":"AAwBA,yCAJY,OAAO,CAMlB"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function parentElement() {
4
+ return this.$(function () { return this.parentElement; });
5
+ }
6
+ exports.default = parentElement;
@@ -0,0 +1,2 @@
1
+ export default function previousElement(): Element;
2
+ //# sourceMappingURL=previousElement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"previousElement.d.ts","sourceRoot":"","sources":["../../../src/commands/element/previousElement.js"],"names":[],"mappings":"AAwBA,2CAJY,OAAO,CAMlB"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function previousElement() {
4
+ return this.$(function () { return this.previousElementSibling; });
5
+ }
6
+ exports.default = previousElement;
@@ -1 +1 @@
1
- {"version":3,"file":"react$$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/react$$.js"],"names":[],"mappings":"AAmCA;;;sBAOC"}
1
+ {"version":3,"file":"react$$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/react$$.js"],"names":[],"mappings":"AAkCA;;;sBAOC"}
@@ -1,5 +1,5 @@
1
1
  export default function react$(selector: any, { props, state }?: {
2
2
  props?: {} | undefined;
3
3
  state?: {} | undefined;
4
- }): Promise<Object>;
4
+ }): Promise<any>;
5
5
  //# sourceMappingURL=react$.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"react$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/react$.js"],"names":[],"mappings":"AA4CA;;;oBAMC"}
1
+ {"version":3,"file":"react$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/react$.js"],"names":[],"mappings":"AA4CA;;;iBAMC"}
@@ -25,6 +25,9 @@ export const isExisting: typeof import("./element/isExisting").default;
25
25
  export const isFocused: typeof import("./element/isFocused").default;
26
26
  export const isSelected: typeof import("./element/isSelected").default;
27
27
  export const moveTo: typeof import("./element/moveTo").default;
28
+ export const nextElement: typeof import("./element/nextElement").default;
29
+ export const parentElement: typeof import("./element/parentElement").default;
30
+ export const previousElement: typeof import("./element/previousElement").default;
28
31
  export const react$$: typeof import("./element/react$$").default;
29
32
  export const react$: typeof import("./element/react$").default;
30
33
  export const saveScreenshot: typeof import("./element/saveScreenshot").default;
@@ -1 +1 @@
1
- {"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../src/commands/element.js"],"names":[],"mappings":"AAAA,uDAAiD;AACjD,qDAA+C;AAC/C,mEAA6D;AAC7D,uEAAiE;AACjE,6DAAuD;AACvD,mEAA6D;AAC7D,iEAA2D;AAC3D,yEAAmE;AACnE,yEAAmE;AACnE,2EAAqE;AACrE,+EAAyE;AACzE,iEAA2D;AAC3D,yEAAmE;AACnE,yEAAmE;AACnE,iEAA2D;AAC3D,uEAAiE;AACjE,iEAA2D;AAC3D,mEAA6D;AAC7D,yEAAmE;AACnE,yEAAmE;AACnE,6FAAuF;AACvF,qEAA+D;AAC/D,iEAA2D;AAC3D,uEAAiE;AACjE,qEAA+D;AAC/D,uEAAiE;AACjE,+DAAyD;AACzD,iEAA2D;AAC3D,+DAAyD;AACzD,+EAAyE;AACzE,+EAAyE;AACzE,qFAA+E;AAC/E,6EAAuE;AACvE,yFAAmF;AACnF,mEAA6D;AAC7D,mEAA6D;AAC7D,iEAA2D;AAC3D,yEAAmE;AACnE,mFAA6E;AAC7E,mFAA6E;AAC7E,+EAAyE;AACzE,2EAAqE;AACrE,qEAA+D"}
1
+ {"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../src/commands/element.js"],"names":[],"mappings":"AAAA,uDAAiD;AACjD,qDAA+C;AAC/C,mEAA6D;AAC7D,uEAAiE;AACjE,6DAAuD;AACvD,mEAA6D;AAC7D,iEAA2D;AAC3D,yEAAmE;AACnE,yEAAmE;AACnE,2EAAqE;AACrE,+EAAyE;AACzE,iEAA2D;AAC3D,yEAAmE;AACnE,yEAAmE;AACnE,iEAA2D;AAC3D,uEAAiE;AACjE,iEAA2D;AAC3D,mEAA6D;AAC7D,yEAAmE;AACnE,yEAAmE;AACnE,6FAAuF;AACvF,qEAA+D;AAC/D,iEAA2D;AAC3D,uEAAiE;AACjE,qEAA+D;AAC/D,uEAAiE;AACjE,+DAAyD;AACzD,yEAAmE;AACnE,6EAAuE;AACvE,iFAA2E;AAC3E,iEAA2D;AAC3D,+DAAyD;AACzD,+EAAyE;AACzE,+EAAyE;AACzE,qFAA+E;AAC/E,6EAAuE;AACvE,yFAAmF;AACnF,mEAA6D;AAC7D,mEAA6D;AAC7D,iEAA2D;AAC3D,yEAAmE;AACnE,mFAA6E;AAC7E,mFAA6E;AAC7E,+EAAyE;AACzE,2EAAqE;AACrE,qEAA+D"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.waitUntil = exports.waitForExist = exports.waitForEnabled = exports.waitForDisplayed = exports.waitForClickable = exports.touchAction = exports.shadow$ = exports.shadow$$ = exports.setValue = exports.selectByVisibleText = exports.selectByIndex = exports.selectByAttribute = exports.scrollIntoView = exports.saveScreenshot = exports.react$ = exports.react$$ = exports.moveTo = exports.isSelected = exports.isFocused = exports.isExisting = exports.isEqual = exports.isEnabled = exports.isDisplayedInViewport = exports.isDisplayed = exports.isClickable = exports.getValue = exports.getText = exports.getTagName = exports.getSize = exports.getProperty = exports.getLocation = exports.getHTML = exports.getCSSProperty = exports.getAttribute = exports.dragAndDrop = exports.doubleClick = exports.custom$ = exports.custom$$ = exports.click = exports.clearValue = exports.addValue = exports.$ = exports.$$ = void 0;
3
+ exports.waitUntil = exports.waitForExist = exports.waitForEnabled = exports.waitForDisplayed = exports.waitForClickable = exports.touchAction = exports.shadow$ = exports.shadow$$ = exports.setValue = exports.selectByVisibleText = exports.selectByIndex = exports.selectByAttribute = exports.scrollIntoView = exports.saveScreenshot = exports.react$ = exports.react$$ = exports.previousElement = exports.parentElement = exports.nextElement = exports.moveTo = exports.isSelected = exports.isFocused = exports.isExisting = exports.isEqual = exports.isEnabled = exports.isDisplayedInViewport = exports.isDisplayed = exports.isClickable = exports.getValue = exports.getText = exports.getTagName = exports.getSize = exports.getProperty = exports.getLocation = exports.getHTML = exports.getCSSProperty = exports.getAttribute = exports.dragAndDrop = exports.doubleClick = exports.custom$ = exports.custom$$ = exports.click = exports.clearValue = exports.addValue = exports.$ = exports.$$ = void 0;
4
4
  exports.$$ = require('./element/$$').default;
5
5
  exports.$ = require('./element/$').default;
6
6
  exports.addValue = require('./element/addValue').default;
@@ -28,6 +28,9 @@ exports.isExisting = require('./element/isExisting').default;
28
28
  exports.isFocused = require('./element/isFocused').default;
29
29
  exports.isSelected = require('./element/isSelected').default;
30
30
  exports.moveTo = require('./element/moveTo').default;
31
+ exports.nextElement = require('./element/nextElement').default;
32
+ exports.parentElement = require('./element/parentElement').default;
33
+ exports.previousElement = require('./element/previousElement').default;
31
34
  exports.react$$ = require('./element/react$$').default;
32
35
  exports.react$ = require('./element/react$').default;
33
36
  exports.saveScreenshot = require('./element/saveScreenshot').default;
@@ -4,7 +4,7 @@ export default class MultiRemote {
4
4
  addInstance(browserName: any, client: any): Promise<any>;
5
5
  modifier(wrapperClient: any): any;
6
6
  baseInstance: MultiRemoteDriver | undefined;
7
- commandWrapper(commandName: any): (...args: any[]) => Promise<any>;
7
+ commandWrapper(commandName: any): (...args: any) => Promise<any>;
8
8
  }
9
9
  declare class MultiRemoteDriver {
10
10
  constructor(instances: any, propertiesObject: any);
@@ -1 +1 @@
1
- {"version":3,"file":"multiremote.d.ts","sourceRoot":"","sources":["../src/multiremote.js"],"names":[],"mappings":"AAUA;IA4DI,+EAiBC;IA3EG,cAAmB;IAMvB,yDAGC;IAKD,kCA2BC;IAXG,4CAA2E;IAkD/E,mEAmBC;CACJ;AAMD;IACI,mDAIC;IAHG,oBAAuC;IACvC,uBAAyB;IACzB,0BAA4C;IAGhD,yBAEC;IAED,2BAEC;IAED,2BAEC;IAED,iCAEC;IAED,wBAEC;IAED,oCAEC;IAED,gCAEC;IAED,qCAEC;IAED,yCAEC;CACJ"}
1
+ {"version":3,"file":"multiremote.d.ts","sourceRoot":"","sources":["../src/multiremote.js"],"names":[],"mappings":"AAUA;IA4DI,+EAiBC;IA3EG,cAAmB;IAMvB,yDAGC;IAKD,kCA2BC;IAXG,4CAA2E;IAkD/E,iEAmBC;CACJ;AAMD;IACI,mDAIC;IAHG,oBAAuC;IACvC,uBAAyB;IACzB,0BAA4C;IAGhD,yBAEC;IAED,2BAEC;IAED,2BAEC;IAED,iCAEC;IAED,wBAEC;IAED,oCAEC;IAED,gCAEC;IAED,qCAEC;IAED,yCAEC;CACJ"}
@@ -0,0 +1,14 @@
1
+ /// <reference types="webdriverio/webdriverio-core" />
2
+ /// <reference types="webdriverio" />
3
+ export declare type ElementReferenceId = 'element-6066-11e4-a52e-4f735466cecf';
4
+ export declare type ElementReference = Record<ElementReferenceId, string>;
5
+ export interface ElementObject extends ElementReference, WebdriverIO.BrowserObject {
6
+ elementId: string;
7
+ ELEMENT: string;
8
+ selector?: string;
9
+ index?: number;
10
+ parent?: WebdriverIO.BrowserObject;
11
+ isReactElement?: boolean;
12
+ error?: Error;
13
+ }
14
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;AAAA,oBAAY,kBAAkB,GAAG,qCAAqC,CAAA;AAEtE,oBAAY,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAA;AAEjE,MAAM,WAAW,aAAc,SAAQ,gBAAgB,EAAE,WAAW,CAAC,aAAa;IAI9E,SAAS,EAAE,MAAM,CAAA;IAIjB,OAAO,EAAE,MAAM,CAAA;IAKf,QAAQ,CAAC,EAAE,MAAM,CAAA;IAIjB,KAAK,CAAC,EAAE,MAAM,CAAA;IAId,MAAM,CAAC,EAAE,WAAW,CAAC,aAAa,CAAA;IAIlC,cAAc,CAAC,EAAE,OAAO,CAAA;IAIxB,KAAK,CAAC,EAAE,KAAK,CAAA;CAChB"}
package/build/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1 @@
1
- {"version":3,"file":"SevereServiceError.d.ts","sourceRoot":"","sources":["../../src/utils/SevereServiceError.js"],"names":[],"mappings":"AAGA;IACI,8BAGC;CACJ"}
1
+ {"version":3,"file":"SevereServiceError.d.ts","sourceRoot":"","sources":["../../src/utils/SevereServiceError.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,KAAK;gBACrC,OAAO,SAAmC;CAIzD"}
@@ -1,5 +1,5 @@
1
- export function findStrategy(selector: any, isW3C: any, isMobile: any): {
1
+ export declare const findStrategy: (selector: string, isW3C: boolean, isMobile: boolean) => {
2
2
  using: string;
3
- value: any;
3
+ value: string;
4
4
  };
5
5
  //# sourceMappingURL=findStrategy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"findStrategy.d.ts","sourceRoot":"","sources":["../../src/utils/findStrategy.js"],"names":[],"mappings":"AAkGO;;;EAqHN"}
1
+ {"version":3,"file":"findStrategy.d.ts","sourceRoot":"","sources":["../../src/utils/findStrategy.ts"],"names":[],"mappings":"AAoGA,eAAO,MAAM,YAAY,aAAuB,MAAM,SAAS,OAAO,YAAY,OAAO;;;CA6HxF,CAAA"}
@@ -4,8 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.findStrategy = void 0;
7
- const constants_1 = require("../constants");
7
+ const fs_1 = __importDefault(require("fs"));
8
8
  const lodash_isplainobject_1 = __importDefault(require("lodash.isplainobject"));
9
+ const constants_1 = require("../constants");
9
10
  const DEFAULT_STRATEGY = 'css selector';
10
11
  const DIRECT_SELECTOR_REGEXP = /^(id|css selector|xpath|link text|partial link text|name|tag name|class name|-android uiautomator|-android datamatcher|-android viewmatcher|-android viewtag|-ios uiautomation|-ios predicate string|-ios class chain|accessibility id):(.+)/;
11
12
  const XPATH_SELECTORS_START = [
@@ -78,7 +79,7 @@ exports.findStrategy = function (selector, isW3C, isMobile) {
78
79
  switch (defineStrategy(selector)) {
79
80
  case 'directly': {
80
81
  const match = selector.match(DIRECT_SELECTOR_REGEXP);
81
- if (!isMobile && isW3C && !constants_1.W3C_SELECTOR_STRATEGIES.includes(match[1])) {
82
+ if (!match || !isMobile && isW3C && !constants_1.W3C_SELECTOR_STRATEGIES.includes(match[1])) {
82
83
  throw new Error('InvalidSelectorStrategy');
83
84
  }
84
85
  using = match[1];
@@ -140,14 +141,21 @@ exports.findStrategy = function (selector, isW3C, isMobile) {
140
141
  }
141
142
  case 'name': {
142
143
  if (isMobile || !isW3C) {
144
+ const match = selector.match(/^\[name=("|')([a-zA-z0-9\-_.@=[\] ']+)("|')]$/);
145
+ if (!match) {
146
+ throw new Error(`InvalidSelectorMatch. Strategy 'name' has failed to match '${selector}'`);
147
+ }
143
148
  using = 'name';
144
- value = selector.match(/^\[name=("|')([a-zA-z0-9\-_.@=[\] ']+)("|')]$/)[2];
149
+ value = match[2];
145
150
  }
146
151
  break;
147
152
  }
148
153
  case 'xpath extended': {
149
154
  using = 'xpath';
150
155
  const match = selector.match(new RegExp(XPATH_SELECTOR_REGEXP.map(rx => rx.source).join('')));
156
+ if (!match) {
157
+ throw new Error(`InvalidSelectorMatch: Strategy 'xpath extended' has failed to match '${selector}'`);
158
+ }
151
159
  const PREFIX_NAME = { '.': 'class', '#': 'id' };
152
160
  const conditions = [];
153
161
  const [tag, prefix, name, attrName, attrValue, partial, query] = match.slice(1);
@@ -165,6 +173,7 @@ exports.findStrategy = function (selector, isW3C, isMobile) {
165
173
  }
166
174
  case '-image': {
167
175
  using = '-image';
176
+ value = fs_1.default.readFileSync(selector, { encoding: 'base64' });
168
177
  break;
169
178
  }
170
179
  }
@@ -1,3 +1,6 @@
1
- export function getElement(selector: string, res: Object, isReactElement?: boolean): Object;
2
- export function getElements(selector: string, elemResponse: any, isReactElement?: boolean): any[];
1
+ /// <reference types="webdriverio/webdriverio-core" />
2
+ /// <reference types="webdriverio" />
3
+ import type { ElementReference } from '../types';
4
+ export declare const getElement: (this: WebdriverIO.BrowserObject, selector?: string | undefined, res?: Error | Record<"element-6066-11e4-a52e-4f735466cecf", string> | undefined, isReactElement?: boolean) => any;
5
+ export declare const getElements: (this: WebdriverIO.BrowserObject, selector: string, elemResponse: ElementReference[], isReactElement?: boolean) => any[];
3
6
  //# sourceMappingURL=getElementObject.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getElementObject.d.ts","sourceRoot":"","sources":["../../src/utils/getElementObject.js"],"names":[],"mappings":"AAaO,kDAHK,MAAM,6BACN,MAAM,CAgDjB;AAQM,kGAkDN"}
1
+ {"version":3,"file":"getElementObject.d.ts","sourceRoot":"","sources":["../../src/utils/getElementObject.ts"],"names":[],"mappings":";;AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAiB,MAAM,UAAU,CAAA;AAQ/D,eAAO,MAAM,UAAU,SAA8B,YAAY,aAAa,kJA8C7E,CAAA;AAQD,eAAO,MAAM,WAAW,SAA8B,YAAY,aAAa,YAAY,MAAM,gBAAgB,gBAAgB,EAAE,oCA+ClI,CAAA"}
@@ -6,18 +6,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getElements = exports.getElement = void 0;
7
7
  const utils_1 = require("@wdio/utils");
8
8
  const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
9
- const utils_2 = require("../utils");
9
+ const _1 = require(".");
10
10
  const middlewares_1 = require("../middlewares");
11
11
  const constants_1 = require("../constants");
12
12
  exports.getElement = function findElement(selector, res, isReactElement = false) {
13
- const browser = utils_2.getBrowserObject(this);
13
+ const browser = _1.getBrowserObject(this);
14
14
  const propertiesObject = {
15
15
  ...lodash_clonedeep_1.default(browser.__propertiesObject__),
16
- ...utils_2.getPrototype('element'),
16
+ ..._1.getPrototype('element'),
17
17
  scope: 'element'
18
18
  };
19
19
  const element = utils_1.webdriverMonad(this.options, (client) => {
20
- const elementId = utils_2.getElementFromResponse(res);
20
+ const elementId = _1.getElementFromResponse(res);
21
21
  if (elementId) {
22
22
  client.elementId = elementId;
23
23
  if (this.isW3C) {
@@ -45,23 +45,19 @@ exports.getElement = function findElement(selector, res, isReactElement = false)
45
45
  return elementInstance;
46
46
  };
47
47
  exports.getElements = function getElements(selector, elemResponse, isReactElement = false) {
48
- const browser = utils_2.getBrowserObject(this);
48
+ const browser = _1.getBrowserObject(this);
49
49
  const propertiesObject = {
50
50
  ...lodash_clonedeep_1.default(browser.__propertiesObject__),
51
- ...utils_2.getPrototype('element')
51
+ ..._1.getPrototype('element')
52
52
  };
53
53
  const elements = elemResponse.map((res, i) => {
54
54
  propertiesObject.scope = 'element';
55
55
  const element = utils_1.webdriverMonad(this.options, (client) => {
56
- const elementId = utils_2.getElementFromResponse(res);
56
+ const elementId = _1.getElementFromResponse(res);
57
57
  if (elementId) {
58
58
  client.elementId = elementId;
59
- if (this.isW3C) {
60
- client[constants_1.ELEMENT_KEY] = elementId;
61
- }
62
- else {
63
- client.ELEMENT = elementId;
64
- }
59
+ const elementKey = this.isW3C ? constants_1.ELEMENT_KEY : 'ELEMENT';
60
+ client[elementKey] = elementId;
65
61
  }
66
62
  else {
67
63
  client.error = res;
@@ -1,2 +1,11 @@
1
- export default function implicitWait(currentElement: Object, commandName: string): Promise<any>;
1
+ export declare type CurrentElement = {
2
+ index: number;
3
+ elementId: string;
4
+ selector: string;
5
+ parent: CurrentElement;
6
+ $: (selector: string) => Promise<CurrentElement>;
7
+ $$: (selector: string) => Promise<CurrentElement[]>;
8
+ waitForExist: () => Promise<void>;
9
+ };
10
+ export default function implicitWait(currentElement: CurrentElement, commandName: string): Promise<CurrentElement>;
2
11
  //# sourceMappingURL=implicitWait.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"implicitWait.d.ts","sourceRoot":"","sources":["../../src/utils/implicitWait.js"],"names":[],"mappings":"AAWA,qDAJY,MAAM,eACN,MAAM,gBAwBjB"}
1
+ {"version":3,"file":"implicitWait.d.ts","sourceRoot":"","sources":["../../src/utils/implicitWait.ts"],"names":[],"mappings":"AAGA,oBAAY,cAAc,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,cAAc,CAAC;IACvB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,CAAA;IAChD,EAAE,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,EAAE,CAAC,CAAA;IACnD,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CACpC,CAAA;AAOD,wBAA8B,YAAY,CAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAqCxH"}
@@ -14,6 +14,15 @@ async function implicitWait(currentElement, commandName) {
14
14
  return await currentElement.parent.$(currentElement.selector);
15
15
  }
16
16
  catch (_a) {
17
+ if (currentElement.selector.toString().includes('this.previousElementSibling')) {
18
+ throw new Error(`Can't call ${commandName} on previous element of element with selector "${currentElement.parent.selector}" because sibling wasn't found`);
19
+ }
20
+ if (currentElement.selector.toString().includes('this.nextElementSibling')) {
21
+ throw new Error(`Can't call ${commandName} on next element of element with selector "${currentElement.parent.selector}" because sibling wasn't found`);
22
+ }
23
+ if (currentElement.selector.toString().includes('this.parentElement')) {
24
+ throw new Error(`Can't call ${commandName} on parent element of element with selector "${currentElement.parent.selector}" because it wasn't found`);
25
+ }
17
26
  throw new Error(`Can't call ${commandName} on element with selector "${currentElement.selector}" because element wasn't found`);
18
27
  }
19
28
  }
@@ -1,12 +1,37 @@
1
+ /// <reference types="webdriverio/webdriverio-core" />
2
+ /// <reference types="node" />
3
+ import Interception from '.';
4
+ declare type RequestOptions = {
5
+ requestId: string;
6
+ responseCode?: number;
7
+ responseHeaders?: Record<string, string>[];
8
+ body?: string | WebdriverIO.JsonCompatible;
9
+ errorReason?: string;
10
+ };
11
+ declare type ClientResponse = {
12
+ body: string;
13
+ base64Encoded?: boolean;
14
+ };
15
+ declare type Client = {
16
+ send: (requestName: string, requestOptions: RequestOptions) => Promise<ClientResponse>;
17
+ };
18
+ declare type Event = {
19
+ requestId: string;
20
+ request: WebdriverIO.Matches & {
21
+ mockedResponse: string | Buffer;
22
+ };
23
+ responseStatusCode?: number;
24
+ responseHeaders: Record<string, string>[];
25
+ };
1
26
  export default class DevtoolsInterception extends Interception {
2
- static handleRequestInterception(client: any, mocks: any): (event: any) => Promise<any>;
3
- constructor(url: string, filterOptions: {} | undefined, browser: WebdriverIO.Browser);
27
+ static handleRequestInterception(client: Client, mocks: Set<Interception>): (event: Event) => Promise<void | ClientResponse>;
28
+ get calls(): WebdriverIO.Matches[];
4
29
  clear(): void;
5
30
  restore(): void;
6
- respond(overwrite: any, params?: any): void;
7
- respondOnce(overwrite: any, params?: any): void;
8
- abort(errorReason: any, sticky?: boolean): void;
31
+ respond(overwrite: WebdriverIO.MockOverwrite, params?: WebdriverIO.MockResponseParams): void;
32
+ respondOnce(overwrite: WebdriverIO.MockOverwrite, params?: WebdriverIO.MockResponseParams): void;
33
+ abort(errorReason: string, sticky?: boolean): void;
9
34
  abortOnce(errorReason: string): void;
10
35
  }
11
- import Interception from ".";
36
+ export {};
12
37
  //# sourceMappingURL=devtools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"devtools.d.ts","sourceRoot":"","sources":["../../../src/utils/interception/devtools.js"],"names":[],"mappings":"AAYA;IACI,wFA0IC;IAzIG,sFAGwB;IAkJ5B,cAEC;IAMD,gBAGC;IAOD,4CAEC;IAOD,gDAEC;IAMD,gDAKC;IAMD,uBAFW,MAAM,QAIhB;CACJ"}
1
+ {"version":3,"file":"devtools.d.ts","sourceRoot":"","sources":["../../../src/utils/interception/devtools.ts"],"names":[],"mappings":";;AAMA,OAAO,YAAY,MAAM,GAAG,CAAA;AAM5B,aAAK,cAAc,GAAG;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAC3C,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,cAAc,CAAC;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB,CAAA;AAED,aAAK,cAAc,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,aAAK,MAAM,GAAG;IACV,IAAI,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;CAC1F,CAAA;AAED,aAAK,KAAK,GAAG;IACT,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,WAAW,CAAC,OAAO,GAAG;QAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAAC;KAAE,CAAC;IACpE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;CAC7C,CAAA;AAID,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,YAAY;IAC1D,MAAM,CAAC,yBAAyB,CAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,GAAG,cAAc,CAAC;IAkJ7H,IAAI,KAAK,0BAER;IAKD,KAAK;IAQL,OAAO;IAUP,OAAO,CAAE,SAAS,EAAE,WAAW,CAAC,aAAa,EAAE,MAAM,GAAE,WAAW,CAAC,kBAAuB;IAS1F,WAAW,CAAE,SAAS,EAAE,WAAW,CAAC,aAAa,EAAE,MAAM,GAAE,WAAW,CAAC,kBAAuB;IAQ9F,KAAK,CAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAE,OAAc;IAWlD,SAAS,CAAE,WAAW,EAAE,MAAM;CAGjC"}
@@ -8,7 +8,7 @@ const path_1 = __importDefault(require("path"));
8
8
  const atob_1 = __importDefault(require("atob"));
9
9
  const minimatch_1 = __importDefault(require("minimatch"));
10
10
  const logger_1 = __importDefault(require("@wdio/logger"));
11
- const _1 = __importDefault(require("./"));
11
+ const _1 = __importDefault(require("."));
12
12
  const __1 = require("..");
13
13
  const constants_1 = require("../../constants");
14
14
  const log = logger_1.default('webdriverio');
@@ -41,9 +41,10 @@ class DevtoolsInterception extends _1.default {
41
41
  filterStatusCode(responseStatusCode, mock.filterOptions.statusCode)) {
42
42
  continue;
43
43
  }
44
- const { body, base64Encoded } = isRequest ? { body: '' } : await client.send('Fetch.getResponseBody', { requestId }).catch(() => ({}));
44
+ const { body, base64Encoded = undefined } = isRequest ? { body: '' } : await client.send('Fetch.getResponseBody', { requestId }).catch(() => ({}));
45
45
  request.body = base64Encoded ? atob_1.default(body) : body;
46
- const responseContentType = responseHeaders[Object.keys(responseHeaders).find(h => h.toLowerCase() === 'content-type')];
46
+ const contentTypeHeader = Object.keys(responseHeaders).find(h => h.toLowerCase() === 'content-type') || '';
47
+ const responseContentType = responseHeaders[contentTypeHeader];
47
48
  request.body = responseContentType && responseContentType.includes('application/json')
48
49
  ? tryParseJson(request.body)
49
50
  : request.body;
@@ -53,7 +54,7 @@ class DevtoolsInterception extends _1.default {
53
54
  }
54
55
  const { errorReason, overwrite, params } = mock.respondOverwrites[0].sticky
55
56
  ? mock.respondOverwrites[0]
56
- : mock.respondOverwrites.shift();
57
+ : mock.respondOverwrites.shift() || {};
57
58
  if (overwrite !== undefined) {
58
59
  let newBody = overwrite;
59
60
  if (typeof overwrite === 'function') {
@@ -66,14 +67,14 @@ class DevtoolsInterception extends _1.default {
66
67
  if (typeof newBody !== 'string') {
67
68
  newBody = JSON.stringify(newBody);
68
69
  }
69
- let responseCode = params.statusCode || responseStatusCode;
70
+ let responseCode = (params === null || params === void 0 ? void 0 : params.statusCode) || responseStatusCode;
70
71
  let responseHeaders = [
71
72
  ...eventResponseHeaders,
72
- ...Object.entries(params.headers || {}).map(([name, value]) => ({ name, value }))
73
+ ...Object.entries((params === null || params === void 0 ? void 0 : params.headers) || {}).map(([name, value]) => ({ name, value }))
73
74
  ];
74
75
  const responseFilePath = path_1.default.isAbsolute(newBody) ? newBody : path_1.default.join(process.cwd(), newBody);
75
76
  if (newBody.length > 0 && await fs_extra_1.default.pathExists(responseFilePath) && await canAccess(responseFilePath)) {
76
- newBody = (await fs_extra_1.default.readFile(responseFilePath)).toString();
77
+ newBody = await fs_extra_1.default.readFile(responseFilePath);
77
78
  }
78
79
  else if (newBody.startsWith('http')) {
79
80
  responseCode = 301;
@@ -85,7 +86,7 @@ class DevtoolsInterception extends _1.default {
85
86
  requestId,
86
87
  responseCode,
87
88
  responseHeaders,
88
- body: isBodyUndefined ? undefined : Buffer.from(newBody, 'binary').toString('base64')
89
+ body: isBodyUndefined ? undefined : (newBody instanceof Buffer ? newBody : Buffer.from(newBody, 'utf8')).toString('base64')
89
90
  }).catch(logFetchError);
90
91
  }
91
92
  if (errorReason) {
@@ -179,5 +180,5 @@ const tryParseJson = (body) => {
179
180
  }
180
181
  };
181
182
  const logFetchError = (err) => {
182
- log.debug(err && err.message ? err.message : err);
183
+ log.debug(err === null || err === void 0 ? void 0 : err.message);
183
184
  };
@@ -3,7 +3,7 @@
3
3
  export default class Interception {
4
4
  url: string;
5
5
  filterOptions: WebdriverIO.MockFilterOptions;
6
- browser: WebdriverIO.Browser;
6
+ browser: WebdriverIO.BrowserObject;
7
7
  respondOverwrites: {
8
8
  overwrite?: WebdriverIO.MockOverwrite;
9
9
  params?: WebdriverIO.MockResponseParams;
@@ -12,7 +12,7 @@ export default class Interception {
12
12
  }[];
13
13
  matches: WebdriverIO.Matches[];
14
14
  calls?: WebdriverIO.Matches[];
15
- constructor(url: string, filterOptions: {} | undefined, browser: WebdriverIO.Browser);
15
+ constructor(url: string, filterOptions: {} | undefined, browser: WebdriverIO.BrowserObject);
16
16
  waitForResponse({ timeout, interval, timeoutMsg, }?: WebdriverIO.WaitForOptions): Promise<void>;
17
17
  }
18
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/interception/index.ts"],"names":[],"mappings":";;AAEA,MAAM,CAAC,OAAO,OAAO,YAAY;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,WAAW,CAAC,iBAAiB,CAAC;IAC7C,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC;IAC7B,iBAAiB,EAAE;QACf,SAAS,CAAC,EAAE,WAAW,CAAC,aAAa,CAAC;QACtC,MAAM,CAAC,EAAE,WAAW,CAAC,kBAAkB,CAAC;QACxC,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;KACxB,EAAE,CAAC;IACJ,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,CAAC;gBAEjB,GAAG,EAAE,MAAM,EAAE,aAAa,gBAAK,EAAE,OAAO,EAAE,WAAW,CAAC,OAAO;IAQ1E,eAAe,CAAE,EACb,OAA6C,EAC7C,QAA+C,EAC/C,UAAU,GACb,GAAE,WAAW,CAAC,cAAmB;CA0BrC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/interception/index.ts"],"names":[],"mappings":";;AAEA,MAAM,CAAC,OAAO,OAAO,YAAY;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,WAAW,CAAC,iBAAiB,CAAC;IAC7C,OAAO,EAAE,WAAW,CAAC,aAAa,CAAC;IACnC,iBAAiB,EAAE;QACf,SAAS,CAAC,EAAE,WAAW,CAAC,aAAa,CAAC;QACtC,MAAM,CAAC,EAAE,WAAW,CAAC,kBAAkB,CAAC;QACxC,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;KACxB,EAAE,CAAC;IACJ,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,CAAC;gBAEjB,GAAG,EAAE,MAAM,EAAE,aAAa,gBAAK,EAAE,OAAO,EAAE,WAAW,CAAC,aAAa;IAQhF,eAAe,CAAE,EACb,OAA6C,EAC7C,QAA+C,EAC/C,UAAU,GACb,GAAE,WAAW,CAAC,cAAmB;CA0BrC"}