@mablhq/mabl-cli 1.12.24 → 1.12.33

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 (98) hide show
  1. package/api/basicApiClient.js +1 -1
  2. package/api/mablApiClient.js +9 -9
  3. package/auth/AuthClient.js +1 -4
  4. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +2 -2
  5. package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +25 -11
  6. package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +24 -17
  7. package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +19 -19
  8. package/browserLauncher/playwrightBrowserLauncher/wrappers.js +1 -1
  9. package/browserLauncher/puppeteerBrowserLauncher/puppeteerBrowser.js +3 -3
  10. package/browserLauncher/puppeteerBrowserLauncher/puppeteerElementHandle.js +6 -6
  11. package/browserLauncher/puppeteerBrowserLauncher/puppeteerFrame.js +7 -7
  12. package/browserLauncher/puppeteerBrowserLauncher/puppeteerHttpRequest.js +1 -1
  13. package/browserLauncher/puppeteerBrowserLauncher/puppeteerHttpResponse.js +1 -1
  14. package/browserLauncher/puppeteerBrowserLauncher/puppeteerJsHandle.js +3 -3
  15. package/browserLauncher/puppeteerBrowserLauncher/puppeteerPage.js +23 -16
  16. package/browserLauncher/puppeteerBrowserLauncher/wrappers.js +1 -1
  17. package/cli.js +6 -4
  18. package/commands/applications/applications_cmds/list.js +1 -1
  19. package/commands/branches/branches_cmds/create.js +1 -1
  20. package/commands/branches/branches_cmds/list.js +1 -1
  21. package/commands/branches/branches_cmds/merge.js +1 -1
  22. package/commands/commandUtil/awaitCompletion.js +2 -2
  23. package/commands/commandUtil/codeInsights.js +6 -6
  24. package/commands/commandUtil/fileUtil.js +1 -1
  25. package/commands/commandUtil/util.js +12 -12
  26. package/commands/config/config_cmds/list.js +1 -1
  27. package/commands/constants.js +1 -1
  28. package/commands/credentials/credentials_cmds/list.js +1 -1
  29. package/commands/deploy/deploy_cmds/create.js +2 -2
  30. package/commands/deploy/deploy_cmds/executionResultPresenter.js +7 -7
  31. package/commands/deploy/deploy_cmds/list.js +1 -1
  32. package/commands/environments/environments_cmds/create.js +3 -3
  33. package/commands/environments/environments_cmds/list.js +1 -1
  34. package/commands/environments/environments_cmds/urls_cmds/add.js +1 -1
  35. package/commands/flows/flows_cmds/list.js +1 -1
  36. package/commands/plans/plans_cmds/list.js +1 -1
  37. package/commands/test-runs/test-runs_cmds/export.js +1 -1
  38. package/commands/tests/executionUtil.js +1 -1
  39. package/commands/tests/testsUtil.js +10 -17
  40. package/commands/tests/tests_cmds/edit.js +1 -1
  41. package/commands/tests/tests_cmds/export.js +1 -1
  42. package/commands/tests/tests_cmds/import.js +13 -13
  43. package/commands/tests/tests_cmds/list.js +2 -2
  44. package/commands/tests/tests_cmds/run-alpha.js +1 -1
  45. package/commands/tests/tests_cmds/run-cloud.js +6 -6
  46. package/commands/tests/tests_cmds/run-legacy.js +2 -2
  47. package/commands/tests/tests_cmds/run.js +4 -4
  48. package/commands/workspaces/workspace_cmds/copy.js +1 -1
  49. package/commands/workspaces/workspace_cmds/list.js +1 -1
  50. package/configGenerators/flowConfigGenerator.js +3 -3
  51. package/configGenerators/selIdeGenerator.js +1 -1
  52. package/configGenerators/testConfigGenerator.js +7 -8
  53. package/core/execution/ApiTestUtils.js +2 -2
  54. package/core/trainer/openUtils.js +47 -0
  55. package/core/trainer/trainingSessions.js +36 -61
  56. package/env/defaultEnv.js +2 -1
  57. package/env/dev.js +2 -1
  58. package/env/env.js +3 -1
  59. package/env/local.js +2 -1
  60. package/env/prod.js +2 -1
  61. package/execution/index.js +1 -1
  62. package/mablscript/MablStep.js +11 -7
  63. package/mablscript/actions/ConditionAction.js +2 -4
  64. package/mablscript/actions/FindAction.js +4 -4
  65. package/mablscript/importer.js +16 -14
  66. package/mablscript/steps/AccessibilityCheck.js +88 -0
  67. package/mablscript/steps/AssertStep.js +6 -5
  68. package/mablscript/steps/CreateVariableStep.js +2 -3
  69. package/mablscript/steps/DownloadStep.js +1 -2
  70. package/mablscript/steps/EnterTextStep.js +2 -1
  71. package/mablscript/steps/IfConditionStep.js +3 -3
  72. package/mablscript/steps/SendHttpRequestStep.js +2 -2
  73. package/mablscript/steps/SendKeyStep.js +2 -2
  74. package/mablscript/steps/SetFilesStep.js +1 -1
  75. package/mablscript/steps/SwitchContextStep.js +2 -1
  76. package/mablscript/types/AccessibilityCheckStepDescriptor.js +2 -0
  77. package/mablscript/types/AccessibilityCheckTypes.js +9 -0
  78. package/mablscript/types/VariableDataType.js +1 -8
  79. package/mablscript/types/VariableNamespace.js +1 -1
  80. package/mablscriptFind/index.js +1 -1
  81. package/package.json +6 -5
  82. package/popupDismissal/index.js +7 -7
  83. package/providers/authenticationProvider.js +2 -3
  84. package/providers/cliConfigProvider.js +1 -1
  85. package/providers/exportRequestProvider.js +1 -1
  86. package/providers/logging/loggingProvider.js +2 -2
  87. package/providers/scmContextProvider.js +1 -1
  88. package/reporters/mochAwesome/mochAwesomeReporter.js +10 -6
  89. package/reporters/reporter.js +1 -1
  90. package/resources/mablFind.js +1 -1
  91. package/util/RichPromise.js +2 -2
  92. package/util/actionabilityUtil.js +5 -3
  93. package/util/downloadUtil.js +1 -1
  94. package/util/logUtils.js +20 -1
  95. package/util/markdownUtil.js +3 -3
  96. package/util/pureUtil.js +6 -6
  97. package/util/resourceUtil.js +14 -1
  98. package/core/trainer/trainerBrowserUtil.js +0 -33
@@ -129,7 +129,7 @@ class BasicApiClient {
129
129
  maxRetryTime: (_h = (_g = this.retryConfig) === null || _g === void 0 ? void 0 : _g.maxRetryTimeMillis) !== null && _h !== void 0 ? _h : DEFAULT_MAX_TOTAL_RETRY_TIME_MILLISECONDS,
130
130
  forever: false,
131
131
  };
132
- return async_retry_1.default(async (bail) => requestFunc().catch(error => {
132
+ return async_retry_1.default(async (bail) => requestFunc().catch((error) => {
133
133
  var _a, _b;
134
134
  const statusCode = (_a = error.statusCode) !== null && _a !== void 0 ? _a : (_b = error.response) === null || _b === void 0 ? void 0 : _b.status;
135
135
  if (statusCode === 429 ||
@@ -67,7 +67,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
67
67
  organization_id: workspaceId,
68
68
  limit,
69
69
  });
70
- const applications = await this.makeGetRequest(`${env_1.BASE_API_URL}/applications?${applicationQueryString}`).then(result => { var _a; return (_a = result.applications) !== null && _a !== void 0 ? _a : []; });
70
+ const applications = await this.makeGetRequest(`${env_1.BASE_API_URL}/applications?${applicationQueryString}`).then((result) => { var _a; return (_a = result.applications) !== null && _a !== void 0 ? _a : []; });
71
71
  sortTemporallyAscending(applications);
72
72
  return applications;
73
73
  }
@@ -117,7 +117,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
117
117
  organization_id: workspaceId,
118
118
  limit,
119
119
  });
120
- const environments = await this.makeGetRequest(`${env_1.BASE_API_URL}/v1/environments/?${environmentQueryString}`).then(result => { var _a; return (_a = result.environments) !== null && _a !== void 0 ? _a : []; });
120
+ const environments = await this.makeGetRequest(`${env_1.BASE_API_URL}/v1/environments/?${environmentQueryString}`).then((result) => { var _a; return (_a = result.environments) !== null && _a !== void 0 ? _a : []; });
121
121
  sortTemporallyAscending(environments);
122
122
  return environments;
123
123
  }
@@ -170,7 +170,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
170
170
  organization_id: workspaceId,
171
171
  limit,
172
172
  });
173
- return await this.makeGetRequest(`${env_1.BASE_API_URL}/credentials?${credentialsQueryString}`).then(result => { var _a; return (_a = result.credentials) !== null && _a !== void 0 ? _a : []; });
173
+ return await this.makeGetRequest(`${env_1.BASE_API_URL}/credentials?${credentialsQueryString}`).then((result) => { var _a; return (_a = result.credentials) !== null && _a !== void 0 ? _a : []; });
174
174
  }
175
175
  catch (error) {
176
176
  throw toApiError(`Failed to get credentials`, error);
@@ -190,7 +190,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
190
190
  workspace_id: workspaceId,
191
191
  limit,
192
192
  });
193
- return await this.makeGetRequest(`${env_1.BASE_API_URL}/events/deployment?${deploymentQueryString}`).then(result => { var _a; return (_a = result.deployments) !== null && _a !== void 0 ? _a : []; });
193
+ return await this.makeGetRequest(`${env_1.BASE_API_URL}/events/deployment?${deploymentQueryString}`).then((result) => { var _a; return (_a = result.deployments) !== null && _a !== void 0 ? _a : []; });
194
194
  }
195
195
  catch (error) {
196
196
  throw toApiError(`Failed to get deployment events`, error);
@@ -245,7 +245,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
245
245
  }
246
246
  async getTestOverrides(testId, environmentId, selectorOverrideLimit = 10) {
247
247
  try {
248
- return await this.makeGetRequest(`${env_1.BASE_API_URL}/tests/testScripts/${testId}/overrides?environment_id=${environmentId}&selector_override_limit=${selectorOverrideLimit}`).then(result => { var _a; return (_a = result.overrides) !== null && _a !== void 0 ? _a : []; });
248
+ return await this.makeGetRequest(`${env_1.BASE_API_URL}/tests/testScripts/${testId}/overrides?environment_id=${environmentId}&selector_override_limit=${selectorOverrideLimit}`).then((result) => { var _a; return (_a = result.overrides) !== null && _a !== void 0 ? _a : []; });
249
249
  }
250
250
  catch (error) {
251
251
  throw toApiError(`Failed to get selector overrides`, error);
@@ -271,7 +271,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
271
271
  var _a, _b;
272
272
  try {
273
273
  const userInfo = await this.getSelf();
274
- const requests = (_b = (_a = userInfo.roles) === null || _a === void 0 ? void 0 : _a.slice(0, limit).map(role => this.getWorkspace(role.organization_id))) !== null && _b !== void 0 ? _b : [];
274
+ const requests = (_b = (_a = userInfo.roles) === null || _a === void 0 ? void 0 : _a.slice(0, limit).map((role) => this.getWorkspace(role.organization_id))) !== null && _b !== void 0 ? _b : [];
275
275
  const workspaces = await Promise.all(requests);
276
276
  sortTemporallyAscending(workspaces);
277
277
  return workspaces;
@@ -406,7 +406,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
406
406
  limit,
407
407
  status: statusFilter,
408
408
  });
409
- return await this.makeGetRequest(`${env_1.BASE_API_URL}/branch?${branchQueryString}`).then(result => { var _a; return (_a = result.branches) !== null && _a !== void 0 ? _a : []; });
409
+ return await this.makeGetRequest(`${env_1.BASE_API_URL}/branch?${branchQueryString}`).then((result) => { var _a; return (_a = result.branches) !== null && _a !== void 0 ? _a : []; });
410
410
  }
411
411
  catch (error) {
412
412
  throw toApiError(`Failed to get Branches`, error);
@@ -422,7 +422,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
422
422
  }
423
423
  async getDatatableRows(datatableId) {
424
424
  try {
425
- return await this.makeGetRequest(`${env_1.BASE_API_URL}/variables/tables/${datatableId}/rows`).then(result => { var _a; return (_a = result.variableRows) !== null && _a !== void 0 ? _a : []; });
425
+ return await this.makeGetRequest(`${env_1.BASE_API_URL}/variables/tables/${datatableId}/rows`).then((result) => { var _a; return (_a = result.variableRows) !== null && _a !== void 0 ? _a : []; });
426
426
  }
427
427
  catch (error) {
428
428
  throw toApiError(`Failed to get datatable rows`, error);
@@ -537,7 +537,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
537
537
  planOverrides.deployment_ids = options.deploymentIds;
538
538
  }
539
539
  if ((_h = options.httpHeaders) === null || _h === void 0 ? void 0 : _h.length) {
540
- planOverrides.http_headers = options.httpHeaders.map(header => {
540
+ planOverrides.http_headers = options.httpHeaders.map((header) => {
541
541
  const parts = header.split(':', 2);
542
542
  return {
543
543
  name: parts[0],
@@ -22,10 +22,7 @@ class AuthClient {
22
22
  .replace(/=/g, '');
23
23
  }
24
24
  sha256(input) {
25
- return crypto_1.default
26
- .createHash('sha256')
27
- .update(input)
28
- .digest();
25
+ return crypto_1.default.createHash('sha256').update(input).digest();
29
26
  }
30
27
  buildAuthorizationUrl(codeChallenge, redirectUri, idpType) {
31
28
  const loginQueryString = query_string_1.default.stringify({
@@ -73,12 +73,12 @@ class PlaywrightBrowser extends events_1.default {
73
73
  async pages() {
74
74
  return Promise.all(this.getDefaultContext()
75
75
  .pages()
76
- .map(page => this.getOrCreatePage(page)));
76
+ .map((page) => this.getOrCreatePage(page)));
77
77
  }
78
78
  async getExtensionBackgroundPage(extensionId) {
79
79
  const backgroundExtensionPage = this.defaultContext
80
80
  .backgroundPages()
81
- .find(page => page.url().includes(extensionId));
81
+ .find((page) => page.url().includes(extensionId));
82
82
  if (!backgroundExtensionPage) {
83
83
  throw new Error('mabl test initialization failure, unable to locate mabl extension page, please try again');
84
84
  }
@@ -19,12 +19,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
19
19
  return result;
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.PlaywrightElementHandle = exports.PlaywrightJsHandle = void 0;
22
+ exports.PlaywrightElementHandle = exports.PlaywrightJsHandle = exports.DEFAULT_TEXT_INPUT_TIMEOUT_MS = void 0;
23
23
  const playwright = __importStar(require("@playwright/test"));
24
24
  const utils_1 = require("../utils");
25
25
  const logUtils_1 = require("../../util/logUtils");
26
26
  const elementHandle_1 = require("../elementHandle");
27
27
  const testsUtil_1 = require("../../commands/tests/testsUtil");
28
+ exports.DEFAULT_TEXT_INPUT_TIMEOUT_MS = 30000;
28
29
  class PlaywrightJsHandle {
29
30
  constructor(handle, page) {
30
31
  this.handle = handle;
@@ -41,12 +42,12 @@ class PlaywrightJsHandle {
41
42
  }
42
43
  async evaluateHandle(code, arg) {
43
44
  const handle = await this.handle.evaluateHandle(code, PlaywrightJsHandle.unwrapProperties(arg));
44
- return utils_1.mapIfNotNull(handle, handle => handle.asElement()
45
+ return utils_1.mapIfNotNull(handle, (handle) => handle.asElement()
45
46
  ? new PlaywrightElementHandle(handle.asElement(), this.page)
46
47
  : new PlaywrightJsHandle(handle, this.page));
47
48
  }
48
49
  async getProperty(propertyName) {
49
- return utils_1.mapIfNotNull(await this.handle.getProperty(propertyName), handle => new PlaywrightJsHandle(handle, this.page));
50
+ return utils_1.mapIfNotNull(await this.handle.getProperty(propertyName), (handle) => new PlaywrightJsHandle(handle, this.page));
50
51
  }
51
52
  jsonValue() {
52
53
  return this.handle.jsonValue();
@@ -67,12 +68,12 @@ class PlaywrightJsHandle {
67
68
  result = arg;
68
69
  }
69
70
  else if (typeof arg === 'object' &&
70
- !Object.keys(arg).some(key => arg[key] instanceof PlaywrightJsHandle)) {
71
+ !Object.keys(arg).some((key) => arg[key] instanceof PlaywrightJsHandle)) {
71
72
  result = arg;
72
73
  }
73
74
  else if (typeof arg === 'object' && !Array.isArray(arg)) {
74
75
  const unwrapped = { ...arg };
75
- Object.keys(arg).forEach(propertyName => {
76
+ Object.keys(arg).forEach((propertyName) => {
76
77
  const propertyValue = unwrapped[propertyName];
77
78
  if (propertyValue instanceof PlaywrightJsHandle) {
78
79
  unwrapped[propertyName] = propertyValue.getPlaywrightHandle();
@@ -116,13 +117,13 @@ class PlaywrightElementHandle extends PlaywrightJsHandle {
116
117
  return this.element.setInputFiles(filePath);
117
118
  }
118
119
  async $x(xpathQuery) {
119
- return (await this.element.$$(`xpath=${xpathQuery}`)).map(element => new PlaywrightElementHandle(element, this.page));
120
+ return (await this.element.$$(`xpath=${xpathQuery}`)).map((element) => new PlaywrightElementHandle(element, this.page));
120
121
  }
121
122
  asElement() {
122
- return utils_1.mapIfNotNull(this.handle.asElement(), handle => new PlaywrightElementHandle(handle, this.page));
123
+ return utils_1.mapIfNotNull(this.handle.asElement(), (handle) => new PlaywrightElementHandle(handle, this.page));
123
124
  }
124
125
  async boundingBox() {
125
- return utils_1.mapIfNotNull(await this.element.boundingBox(), boundingBox => boundingBox);
126
+ return utils_1.mapIfNotNull(await this.element.boundingBox(), (boundingBox) => boundingBox);
126
127
  }
127
128
  click(options) {
128
129
  var _a, _b;
@@ -144,13 +145,13 @@ class PlaywrightElementHandle extends PlaywrightJsHandle {
144
145
  return clickablePoint;
145
146
  }
146
147
  async contentFrame() {
147
- return utils_1.mapIfNotNull(await this.element.contentFrame(), frame => this.page.getOrCreateFrame(frame));
148
+ return utils_1.mapIfNotNull(await this.element.contentFrame(), (frame) => this.page.getOrCreateFrame(frame));
148
149
  }
149
150
  focus() {
150
151
  return this.element.focus();
151
152
  }
152
153
  async frame() {
153
- return utils_1.mapIfNotNull(await this.element.ownerFrame(), frame => this.page.getOrCreateFrame(frame));
154
+ return utils_1.mapIfNotNull(await this.element.ownerFrame(), (frame) => this.page.getOrCreateFrame(frame));
154
155
  }
155
156
  hover() {
156
157
  return this.element.hover();
@@ -162,9 +163,22 @@ class PlaywrightElementHandle extends PlaywrightJsHandle {
162
163
  return this.element.selectOption(value);
163
164
  }
164
165
  async type(text, options) {
166
+ const timeout = PlaywrightElementHandle.getTypeTimeout(text, options);
165
167
  await this.element.focus();
166
168
  await this.element.selectText({ force: true });
167
- return this.element.type(text, options);
169
+ return this.element.type(text, {
170
+ delay: options === null || options === void 0 ? void 0 : options.delay,
171
+ timeout,
172
+ });
173
+ }
174
+ static getTypeTimeout(text, options) {
175
+ var _a;
176
+ let timeout;
177
+ const newTimeout = text.length * ((_a = options === null || options === void 0 ? void 0 : options.delay) !== null && _a !== void 0 ? _a : 1) * 2;
178
+ if (newTimeout > exports.DEFAULT_TEXT_INPUT_TIMEOUT_MS) {
179
+ timeout = newTimeout;
180
+ }
181
+ return timeout;
168
182
  }
169
183
  press(key) {
170
184
  return this.element.press(key);
@@ -27,6 +27,8 @@ const playwrightHttpResponse_1 = require("./playwrightHttpResponse");
27
27
  const playwrightDom_1 = require("./playwrightDom");
28
28
  const testsUtil_1 = require("../../commands/tests/testsUtil");
29
29
  const WAIT_FOR_CONTEXT_TIMEOUT = 1000;
30
+ const MAIN_CONTEXT = 'main';
31
+ const UTILITY_CONTEXT = 'utility';
30
32
  class PlaywrightFrame extends browserLauncher_1.Frame {
31
33
  constructor(frame, parentPage) {
32
34
  super();
@@ -37,18 +39,21 @@ class PlaywrightFrame extends browserLauncher_1.Frame {
37
39
  injectSecondaryWorld() {
38
40
  const serverFrame = this.getFrameImpl();
39
41
  serverFrame.checkWorldFunction = async function (arg) {
40
- let forcedWorld = 'main';
42
+ let forcedWorld = MAIN_CONTEXT;
41
43
  if (this.utilityWorldAvailable === undefined) {
42
44
  await Promise.race([
43
- this._contextData.get('utility').contextPromise,
45
+ this._contextData.get(UTILITY_CONTEXT).contextPromise,
44
46
  testsUtil_1.sleep(WAIT_FOR_CONTEXT_TIMEOUT),
45
47
  ]);
46
48
  this.utilityWorldAvailable =
47
- this._contextData.get('utility').context !== null;
49
+ this._contextData.get(UTILITY_CONTEXT).context !== null;
48
50
  }
49
- if ((arg === null || arg === void 0 ? void 0 : arg.hasOwnProperty('secondaryWorldValue')) &&
50
- this.utilityWorldAvailable) {
51
- forcedWorld = 'utility';
51
+ if (arg === null || arg === void 0 ? void 0 : arg.hasOwnProperty('secondaryWorldValue')) {
52
+ forcedWorld = UTILITY_CONTEXT;
53
+ if (!this.utilityWorldAvailable) {
54
+ this._contextData.set(UTILITY_CONTEXT, this._contextData.get(MAIN_CONTEXT));
55
+ this.utilityWorldAvailable = true;
56
+ }
52
57
  arg = arg.secondaryWorldValue;
53
58
  }
54
59
  return { world: forcedWorld, value: arg };
@@ -58,43 +63,45 @@ class PlaywrightFrame extends browserLauncher_1.Frame {
58
63
  const { world, value } = await this.checkWorldFunction(arg);
59
64
  return originalEvaluateExpressionFunction(expression, isFunction, value, world);
60
65
  };
61
- serverFrame.evaluateExpressionAndWaitForSignals = functionOverride.bind(serverFrame);
66
+ serverFrame.evaluateExpressionAndWaitForSignals =
67
+ functionOverride.bind(serverFrame);
62
68
  const originalEvaluateExpressionHandleFunction = serverFrame.evaluateExpressionHandleAndWaitForSignals.bind(serverFrame);
63
69
  const functionHandleOverride = async function (expression, isFunction, arg, _world) {
64
70
  const { world, value } = await this.checkWorldFunction(arg);
65
71
  return originalEvaluateExpressionHandleFunction(expression, isFunction, value, world);
66
72
  };
67
- serverFrame.evaluateExpressionHandleAndWaitForSignals = functionHandleOverride.bind(serverFrame);
73
+ serverFrame.evaluateExpressionHandleAndWaitForSignals =
74
+ functionHandleOverride.bind(serverFrame);
68
75
  }
69
76
  async $(selector) {
70
- return utils_1.mapIfNotNull(await this.frame.$(selector), handle => new playwrightDom_1.PlaywrightElementHandle(handle, this.parentPage));
77
+ return utils_1.mapIfNotNull(await this.frame.$(selector), (handle) => new playwrightDom_1.PlaywrightElementHandle(handle, this.parentPage));
71
78
  }
72
79
  async $$(selector) {
73
80
  const maybePlaywrightHandles = await this.frame.$$(selector);
74
81
  if (!maybePlaywrightHandles.length) {
75
82
  return [];
76
83
  }
77
- return maybePlaywrightHandles.map(handle => new playwrightDom_1.PlaywrightElementHandle(handle, this.parentPage));
84
+ return maybePlaywrightHandles.map((handle) => new playwrightDom_1.PlaywrightElementHandle(handle, this.parentPage));
78
85
  }
79
86
  async $$eval(selector, pageFunction, ...args) {
80
- const result = await this.frame.$$eval(selector, pageFunction, ...args === null || args === void 0 ? void 0 : args.map(argument => argument instanceof playwrightDom_1.PlaywrightJsHandle
87
+ const result = await this.frame.$$eval(selector, pageFunction, ...args === null || args === void 0 ? void 0 : args.map((argument) => argument instanceof playwrightDom_1.PlaywrightJsHandle
81
88
  ? argument.getPlaywrightHandle()
82
89
  : argument));
83
90
  return result;
84
91
  }
85
92
  async $eval(selector, pageFunction, ...args) {
86
- const result = await this.frame.$eval(selector, pageFunction, ...args === null || args === void 0 ? void 0 : args.map(argument => argument instanceof playwrightDom_1.PlaywrightJsHandle
93
+ const result = await this.frame.$eval(selector, pageFunction, ...args === null || args === void 0 ? void 0 : args.map((argument) => argument instanceof playwrightDom_1.PlaywrightJsHandle
87
94
  ? argument.getPlaywrightHandle()
88
95
  : argument));
89
96
  return result;
90
97
  }
91
98
  async $x(xpathQuery) {
92
- return (await this.frame.$$(`xpath=${xpathQuery}`)).map(element => new playwrightDom_1.PlaywrightElementHandle(element, this.parentPage));
99
+ return (await this.frame.$$(`xpath=${xpathQuery}`)).map((element) => new playwrightDom_1.PlaywrightElementHandle(element, this.parentPage));
93
100
  }
94
101
  childFrames() {
95
102
  return this.frame
96
103
  .childFrames()
97
- .map(frame => this.parentPage.getOrCreateFrame(frame));
104
+ .map((frame) => this.parentPage.getOrCreateFrame(frame));
98
105
  }
99
106
  evaluate(pageFunction, arg, addSecondaryWorldFlag = false) {
100
107
  return this.frame.evaluate(pageFunction, playwrightDom_1.PlaywrightJsHandle.unwrapProperties(arg, addSecondaryWorldFlag));
@@ -111,7 +118,7 @@ class PlaywrightFrame extends browserLauncher_1.Frame {
111
118
  async goto(url, options) {
112
119
  try {
113
120
  const response = await this.frame.goto(url, options);
114
- return utils_1.mapIfNotNull(response, response => new playwrightHttpResponse_1.PlaywrightHttpResponse(this.parentPage, response));
121
+ return utils_1.mapIfNotNull(response, (response) => new playwrightHttpResponse_1.PlaywrightHttpResponse(this.parentPage, response));
115
122
  }
116
123
  catch (e) {
117
124
  if (e instanceof playwright.errors.TimeoutError) {
@@ -127,13 +134,13 @@ class PlaywrightFrame extends browserLauncher_1.Frame {
127
134
  return this.frame.name();
128
135
  }
129
136
  parentFrame() {
130
- return utils_1.mapIfNotNull(this.frame.parentFrame(), frame => this.parentPage.getOrCreateFrame(frame));
137
+ return utils_1.mapIfNotNull(this.frame.parentFrame(), (frame) => this.parentPage.getOrCreateFrame(frame));
131
138
  }
132
139
  url() {
133
140
  return this.frame.url();
134
141
  }
135
142
  async waitForSelector(selector, options) {
136
- return utils_1.mapIfNotNull(await this.frame.waitForSelector(selector, options), handle => new playwrightDom_1.PlaywrightElementHandle(handle, this.parentPage));
143
+ return utils_1.mapIfNotNull(await this.frame.waitForSelector(selector, options), (handle) => new playwrightDom_1.PlaywrightElementHandle(handle, this.parentPage));
137
144
  }
138
145
  page() {
139
146
  return this.parentPage;
@@ -68,7 +68,7 @@ class PlaywrightPage extends events_1.default {
68
68
  });
69
69
  }
70
70
  async waitForInitialization() {
71
- this.openerPage = await utils_1.mapIfNotNull(await this.page.opener(), page => this.browser.getOrCreatePage(page));
71
+ this.openerPage = await utils_1.mapIfNotNull(await this.page.opener(), (page) => this.browser.getOrCreatePage(page));
72
72
  }
73
73
  on(event, listener) {
74
74
  this.wireEvents(event);
@@ -83,7 +83,7 @@ class PlaywrightPage extends events_1.default {
83
83
  wireEvents(event) {
84
84
  if (event === browserLauncher_1.PageEvent.RequestWillBeSentExtraInfo &&
85
85
  !this.listenerCount(event)) {
86
- void this.getCdpSession().then(session => session.on('Network.requestWillBeSentExtraInfo', (event) => {
86
+ void this.getCdpSession().then((session) => session.on('Network.requestWillBeSentExtraInfo', (event) => {
87
87
  this.emit(browserLauncher_1.PageEvent.RequestWillBeSentExtraInfo, event);
88
88
  }));
89
89
  }
@@ -93,7 +93,7 @@ class PlaywrightPage extends events_1.default {
93
93
  });
94
94
  }
95
95
  if (event === browserLauncher_1.PageEvent.Request && !this.listenerCount(event)) {
96
- void this.page.route('**/*', route => {
96
+ void this.page.route('**/*', (route) => {
97
97
  this.emit(browserLauncher_1.PageEvent.Request, new playwrightHttpRequest_1.PlaywrightHttpRequest(this, route.request(), route));
98
98
  });
99
99
  }
@@ -108,33 +108,33 @@ class PlaywrightPage extends events_1.default {
108
108
  });
109
109
  }
110
110
  if (event === browserLauncher_1.PageEvent.Console && !this.listenerCount(event)) {
111
- this.page.on('console', console => {
111
+ this.page.on('console', (console) => {
112
112
  this.emit(browserLauncher_1.PageEvent.Console, new wrappers_1.PlaywrightWrappedConsoleMessage(console, this));
113
113
  });
114
114
  }
115
115
  if (event === browserLauncher_1.PageEvent.PageError && !this.listenerCount(event)) {
116
- this.page.on('pageerror', error => {
116
+ this.page.on('pageerror', (error) => {
117
117
  this.emit(browserLauncher_1.PageEvent.PageError, error);
118
118
  });
119
119
  }
120
120
  if (event === browserLauncher_1.PageEvent.Error && !this.listenerCount(event)) {
121
- this.page.on('crash', error => {
121
+ this.page.on('crash', (error) => {
122
122
  this.emit(browserLauncher_1.PageEvent.Error, error);
123
123
  });
124
124
  }
125
125
  if (event === browserLauncher_1.PageEvent.TracingBufferUsage && !this.listenerCount(event)) {
126
- void this.getCdpSession().then(session => session.on('Tracing.bufferUsage', (tracing) => {
126
+ void this.getCdpSession().then((session) => session.on('Tracing.bufferUsage', (tracing) => {
127
127
  this.emit(browserLauncher_1.PageEvent.TracingBufferUsage, tracing);
128
128
  }));
129
129
  }
130
130
  if (event === browserLauncher_1.PageEvent.TracingComplete && !this.listenerCount(event)) {
131
- void this.getCdpSession().then(session => session.on('Tracing.tracingComplete', (tracingComplete) => {
131
+ void this.getCdpSession().then((session) => session.on('Tracing.tracingComplete', (tracingComplete) => {
132
132
  this.emit(browserLauncher_1.PageEvent.TracingComplete, tracingComplete);
133
133
  }));
134
134
  }
135
135
  }
136
- async screenshot() {
137
- return { data: (await this.page.screenshot()).toString('base64') };
136
+ async screenshot(clip) {
137
+ return { data: (await this.page.screenshot({ clip })).toString('base64') };
138
138
  }
139
139
  sendCharacter(key) {
140
140
  return this.page.keyboard.insertText(key);
@@ -182,7 +182,7 @@ class PlaywrightPage extends events_1.default {
182
182
  return result;
183
183
  }
184
184
  async $x(xpathQuery) {
185
- return (await this.page.$$(`xpath=${xpathQuery}`)).map(element => new playwrightDom_1.PlaywrightElementHandle(element, this));
185
+ return (await this.page.$$(`xpath=${xpathQuery}`)).map((element) => new playwrightDom_1.PlaywrightElementHandle(element, this));
186
186
  }
187
187
  authenticate(_credentials) {
188
188
  throw new Error('PlaywrightPage.authenticate not implemented');
@@ -194,7 +194,7 @@ class PlaywrightPage extends events_1.default {
194
194
  return this.page.context().cookies();
195
195
  }
196
196
  async deleteCookie(...cookies) {
197
- const finalCookies = (await this.cookies()).filter((cookie) => !cookies.find(c => c.name === cookie.name && c.domain === cookie.domain));
197
+ const finalCookies = (await this.cookies()).filter((cookie) => !cookies.find((c) => c.name === cookie.name && c.domain === cookie.domain));
198
198
  await this.page.context().clearCookies();
199
199
  await this.page.context().addCookies(finalCookies);
200
200
  }
@@ -205,7 +205,7 @@ class PlaywrightPage extends events_1.default {
205
205
  return new playwrightDom_1.PlaywrightJsHandle(await this.page.evaluateHandle(code, playwrightDom_1.PlaywrightJsHandle.unwrapProperties(arg, true)), this);
206
206
  }
207
207
  frames() {
208
- return this.page.frames().map(frame => this.getOrCreateFrame(frame));
208
+ return this.page.frames().map((frame) => this.getOrCreateFrame(frame));
209
209
  }
210
210
  async getBrowserBounds() {
211
211
  const windowInfo = await this.getWindowInfo();
@@ -214,7 +214,7 @@ class PlaywrightPage extends events_1.default {
214
214
  async goto(url, options) {
215
215
  try {
216
216
  const response = await this.page.goto(url, options);
217
- return utils_1.mapIfNotNull(response, response => new playwrightHttpResponse_1.PlaywrightHttpResponse(this, response));
217
+ return utils_1.mapIfNotNull(response, (response) => new playwrightHttpResponse_1.PlaywrightHttpResponse(this, response));
218
218
  }
219
219
  catch (e) {
220
220
  if (e instanceof playwright.errors.TimeoutError) {
@@ -249,7 +249,7 @@ class PlaywrightPage extends events_1.default {
249
249
  }
250
250
  async reload(options) {
251
251
  try {
252
- return utils_1.mapIfNotNull(await this.page.reload(options), response => new playwrightHttpResponse_1.PlaywrightHttpResponse(this, response));
252
+ return utils_1.mapIfNotNull(await this.page.reload(options), (response) => new playwrightHttpResponse_1.PlaywrightHttpResponse(this, response));
253
253
  }
254
254
  catch (e) {
255
255
  if (e instanceof playwright.errors.TimeoutError) {
@@ -275,7 +275,7 @@ class PlaywrightPage extends events_1.default {
275
275
  async setCookie(...cookies) {
276
276
  const pageUrl = this.url();
277
277
  const startsWithHTTP = pageUrl.startsWith('http');
278
- await this.page.context().addCookies(cookies.map(cookie => {
278
+ await this.page.context().addCookies(cookies.map((cookie) => {
279
279
  const item = { ...cookie };
280
280
  if (!item.url && startsWithHTTP) {
281
281
  item.url = pageUrl;
@@ -307,7 +307,7 @@ class PlaywrightPage extends events_1.default {
307
307
  async waitForNavigation(options) {
308
308
  try {
309
309
  const result = await this.page.waitForNavigation(options);
310
- return utils_1.mapIfNotNull(result, result => new playwrightHttpResponse_1.PlaywrightHttpResponse(this, result));
310
+ return utils_1.mapIfNotNull(result, (result) => new playwrightHttpResponse_1.PlaywrightHttpResponse(this, result));
311
311
  }
312
312
  catch (e) {
313
313
  if (e instanceof playwright.errors.TimeoutError) {
@@ -317,7 +317,7 @@ class PlaywrightPage extends events_1.default {
317
317
  }
318
318
  }
319
319
  async waitForSelector(selector, options) {
320
- return utils_1.mapIfNotNull(await this.page.waitForSelector(selector, options), handle => new playwrightDom_1.PlaywrightElementHandle(handle, this));
320
+ return utils_1.mapIfNotNull(await this.page.waitForSelector(selector, options), (handle) => new playwrightDom_1.PlaywrightElementHandle(handle, this));
321
321
  }
322
322
  acceptDialogs(dialog) {
323
323
  return dialog.accept();
@@ -329,7 +329,7 @@ class PlaywrightPage extends events_1.default {
329
329
  throw new Error('PlaywrightPage.setExtraHTTPHeaders not implemented');
330
330
  }
331
331
  makeCdpCall(method, paramArgs) {
332
- return this.getCdpSession().then(session => session.send(method, paramArgs));
332
+ return this.getCdpSession().then((session) => session.send(method, paramArgs));
333
333
  }
334
334
  async getCdpSession() {
335
335
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
@@ -13,7 +13,7 @@ class PlaywrightWrappedConsoleMessage {
13
13
  args() {
14
14
  return this.message
15
15
  .args()
16
- .map(handle => new playwrightDom_1.PlaywrightJsHandle(handle, this.page));
16
+ .map((handle) => new playwrightDom_1.PlaywrightJsHandle(handle, this.page));
17
17
  }
18
18
  type() {
19
19
  return this.message.type();
@@ -71,11 +71,11 @@ class PuppeteerBrowser extends events_1.default {
71
71
  }
72
72
  async pages() {
73
73
  const pages = await this.browser.pages();
74
- return Promise.all(pages.map(page => this.getOrCreatePage(page)));
74
+ return Promise.all(pages.map((page) => this.getOrCreatePage(page)));
75
75
  }
76
76
  async getExtensionBackgroundPage(extensionId) {
77
77
  const targets = this.browser.targets();
78
- const target = targets.find(target => target.type() === 'background_page' &&
78
+ const target = targets.find((target) => target.type() === 'background_page' &&
79
79
  target.url().includes(extensionId));
80
80
  if (target) {
81
81
  const backgroundPage = await target.page();
@@ -89,7 +89,7 @@ class PuppeteerBrowser extends events_1.default {
89
89
  async waitForPage(opener, options) {
90
90
  try {
91
91
  const pageTarget = opener.getPuppeteerPage().target();
92
- const newTarget = await this.browser.waitForTarget(target => target.opener() === pageTarget, puppeteerBrowserLauncher_1.convertWaitForOptions(options));
92
+ const newTarget = await this.browser.waitForTarget((target) => target.opener() === pageTarget, puppeteerBrowserLauncher_1.convertWaitForOptions(options));
93
93
  return this.getOrCreatePage((await newTarget.page()));
94
94
  }
95
95
  catch (e) {
@@ -17,7 +17,7 @@ class PuppeteerElementHandle extends puppeteerJsHandle_1.PuppeteerJsHandle {
17
17
  }
18
18
  async contentFrame() {
19
19
  const frame = await this.element.contentFrame();
20
- return utils_1.mapIfNotNull(frame, frame => this.parentPage.getOrCreateFrame(frame));
20
+ return utils_1.mapIfNotNull(frame, (frame) => this.parentPage.getOrCreateFrame(frame));
21
21
  }
22
22
  focus() {
23
23
  return this.element.focus();
@@ -43,20 +43,20 @@ class PuppeteerElementHandle extends puppeteerJsHandle_1.PuppeteerJsHandle {
43
43
  return this.element.click({ clickCount: 2 });
44
44
  }
45
45
  asElement() {
46
- return utils_1.mapIfNotNull(this.handle.asElement(), handle => new PuppeteerElementHandle(handle, this.parentPage));
46
+ return utils_1.mapIfNotNull(this.handle.asElement(), (handle) => new PuppeteerElementHandle(handle, this.parentPage));
47
47
  }
48
48
  type(text, options) {
49
49
  return this.element.type(text, options);
50
50
  }
51
51
  async $x(xpathQuery) {
52
- return (await this.element.$x(xpathQuery)).map(element => new PuppeteerElementHandle(element, this.parentPage));
52
+ return (await this.element.$x(xpathQuery)).map((element) => new PuppeteerElementHandle(element, this.parentPage));
53
53
  }
54
54
  async boundingBox() {
55
55
  const boundingBox = await this.element.boundingBox();
56
- return utils_1.mapIfNotNull(boundingBox, boundingBox => boundingBox);
56
+ return utils_1.mapIfNotNull(boundingBox, (boundingBox) => boundingBox);
57
57
  }
58
58
  frame() {
59
- return Promise.resolve(utils_1.mapIfNotNull(this.element.executionContext().frame(), frame => this.parentPage.getOrCreateFrame(frame)));
59
+ return Promise.resolve(utils_1.mapIfNotNull(this.element.executionContext().frame(), (frame) => this.parentPage.getOrCreateFrame(frame)));
60
60
  }
61
61
  press(key) {
62
62
  return this.element.press(key);
@@ -115,7 +115,7 @@ class PuppeteerElementHandle extends puppeteerJsHandle_1.PuppeteerJsHandle {
115
115
  return this.getCdpClient().send(method, paramArgs);
116
116
  }
117
117
  getValue() {
118
- return this.element.evaluate(el => el.value);
118
+ return this.element.evaluate((el) => el.value);
119
119
  }
120
120
  }
121
121
  exports.PuppeteerElementHandle = PuppeteerElementHandle;
@@ -31,7 +31,7 @@ class PuppeteerFrame extends browserLauncher_1.Frame {
31
31
  childFrames() {
32
32
  return this.frame
33
33
  .childFrames()
34
- .map(frame => this.parentPage.getOrCreateFrame(frame));
34
+ .map((frame) => this.parentPage.getOrCreateFrame(frame));
35
35
  }
36
36
  async $eval(selector, pageFunction, arg) {
37
37
  const result = await this.frame.$eval(selector, pageFunction, puppeteerJsHandle_1.PuppeteerJsHandle.unwrapProperties(arg));
@@ -43,13 +43,13 @@ class PuppeteerFrame extends browserLauncher_1.Frame {
43
43
  }
44
44
  async $(selector) {
45
45
  const handle = await this.frame.$(selector);
46
- return utils_1.mapIfNotNull(handle, handle => new puppeteerElementHandle_1.PuppeteerElementHandle(handle, this.parentPage));
46
+ return utils_1.mapIfNotNull(handle, (handle) => new puppeteerElementHandle_1.PuppeteerElementHandle(handle, this.parentPage));
47
47
  }
48
48
  async $$(selector) {
49
- return (await this.frame.$$(selector)).map(element => new puppeteerElementHandle_1.PuppeteerElementHandle(element, this.parentPage));
49
+ return (await this.frame.$$(selector)).map((element) => new puppeteerElementHandle_1.PuppeteerElementHandle(element, this.parentPage));
50
50
  }
51
51
  async $x(xpathQuery) {
52
- return (await this.frame.$x(xpathQuery)).map(element => new puppeteerElementHandle_1.PuppeteerElementHandle(element, this.parentPage));
52
+ return (await this.frame.$x(xpathQuery)).map((element) => new puppeteerElementHandle_1.PuppeteerElementHandle(element, this.parentPage));
53
53
  }
54
54
  id() {
55
55
  return this.frame._id;
@@ -63,7 +63,7 @@ class PuppeteerFrame extends browserLauncher_1.Frame {
63
63
  async goto(url, options) {
64
64
  try {
65
65
  const response = await this.frame.goto(url, puppeteerBrowserLauncher_1.convertWaitForOptions(options));
66
- return utils_1.mapIfNotNull(response, response => new puppeteerHttpResponse_1.PuppeteerHttpResponse(response, this.parentPage));
66
+ return utils_1.mapIfNotNull(response, (response) => new puppeteerHttpResponse_1.PuppeteerHttpResponse(response, this.parentPage));
67
67
  }
68
68
  catch (e) {
69
69
  if (e instanceof puppeteer_core_1.default.errors.TimeoutError) {
@@ -73,7 +73,7 @@ class PuppeteerFrame extends browserLauncher_1.Frame {
73
73
  }
74
74
  }
75
75
  parentFrame() {
76
- return utils_1.mapIfNotNull(this.frame.parentFrame(), frame => this.parentPage.getOrCreateFrame(frame));
76
+ return utils_1.mapIfNotNull(this.frame.parentFrame(), (frame) => this.parentPage.getOrCreateFrame(frame));
77
77
  }
78
78
  evaluate(pageFunction, arg) {
79
79
  return this.frame.evaluate(pageFunction, puppeteerJsHandle_1.PuppeteerJsHandle.unwrapProperties(arg));
@@ -99,7 +99,7 @@ class PuppeteerFrame extends browserLauncher_1.Frame {
99
99
  }
100
100
  async waitForSelector(selector, options) {
101
101
  const handle = await this.frame.waitForSelector(selector, puppeteerBrowserLauncher_1.convertWaitForOptions(options));
102
- return utils_1.mapIfNotNull(handle, handle => new puppeteerElementHandle_1.PuppeteerElementHandle(handle, this.parentPage));
102
+ return utils_1.mapIfNotNull(handle, (handle) => new puppeteerElementHandle_1.PuppeteerElementHandle(handle, this.parentPage));
103
103
  }
104
104
  async getFrameOwnerElement() {
105
105
  const parentFrame = this.parentFrame();
@@ -23,7 +23,7 @@ class PuppeteerHttpRequest {
23
23
  });
24
24
  }
25
25
  frame() {
26
- return utils_1.mapIfNotNull(this.request.frame(), frame => this.parentPage.getOrCreateFrame(frame));
26
+ return utils_1.mapIfNotNull(this.request.frame(), (frame) => this.parentPage.getOrCreateFrame(frame));
27
27
  }
28
28
  url() {
29
29
  return this.request.url();
@@ -15,7 +15,7 @@ class PuppeteerHttpResponse {
15
15
  return this.response.url();
16
16
  }
17
17
  frame() {
18
- return utils_1.mapIfNotNull(this.response.frame(), frame => this.parentPage.getOrCreateFrame(frame));
18
+ return utils_1.mapIfNotNull(this.response.frame(), (frame) => this.parentPage.getOrCreateFrame(frame));
19
19
  }
20
20
  request() {
21
21
  return new puppeteerHttpRequest_1.PuppeteerHttpRequest(this.response.request(), this.parentPage);