@samsara-dev/appwright 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/.eslintrc.js +4 -0
  2. package/CHANGELOG.md +538 -0
  3. package/LICENSE +202 -0
  4. package/README.md +183 -0
  5. package/dist/bin/index.d.ts +3 -0
  6. package/dist/bin/index.d.ts.map +1 -0
  7. package/dist/bin/index.js +53 -0
  8. package/dist/config.d.ts +4 -0
  9. package/dist/config.d.ts.map +1 -0
  10. package/dist/config.js +65 -0
  11. package/dist/device/index.d.ts +171 -0
  12. package/dist/device/index.d.ts.map +1 -0
  13. package/dist/device/index.js +415 -0
  14. package/dist/fixture/index.d.ts +38 -0
  15. package/dist/fixture/index.d.ts.map +1 -0
  16. package/dist/fixture/index.js +78 -0
  17. package/dist/fixture/workerInfo.d.ts +27 -0
  18. package/dist/fixture/workerInfo.d.ts.map +1 -0
  19. package/dist/fixture/workerInfo.js +87 -0
  20. package/dist/global-setup.d.ts +5 -0
  21. package/dist/global-setup.d.ts.map +1 -0
  22. package/dist/global-setup.js +30 -0
  23. package/dist/index.d.ts +5 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +25 -0
  26. package/dist/locator/index.d.ts +25 -0
  27. package/dist/locator/index.d.ts.map +1 -0
  28. package/dist/locator/index.js +296 -0
  29. package/dist/logger.d.ts +9 -0
  30. package/dist/logger.d.ts.map +1 -0
  31. package/dist/logger.js +19 -0
  32. package/dist/providers/appium.d.ts +15 -0
  33. package/dist/providers/appium.d.ts.map +1 -0
  34. package/dist/providers/appium.js +274 -0
  35. package/dist/providers/browserstack/index.d.ts +26 -0
  36. package/dist/providers/browserstack/index.d.ts.map +1 -0
  37. package/dist/providers/browserstack/index.js +272 -0
  38. package/dist/providers/browserstack/utils.d.ts +2 -0
  39. package/dist/providers/browserstack/utils.d.ts.map +1 -0
  40. package/dist/providers/browserstack/utils.js +34 -0
  41. package/dist/providers/emulator/index.d.ts +13 -0
  42. package/dist/providers/emulator/index.d.ts.map +1 -0
  43. package/dist/providers/emulator/index.js +86 -0
  44. package/dist/providers/index.d.ts +5 -0
  45. package/dist/providers/index.d.ts.map +1 -0
  46. package/dist/providers/index.js +31 -0
  47. package/dist/providers/lambdatest/index.d.ts +27 -0
  48. package/dist/providers/lambdatest/index.d.ts.map +1 -0
  49. package/dist/providers/lambdatest/index.js +280 -0
  50. package/dist/providers/lambdatest/utils.d.ts +3 -0
  51. package/dist/providers/lambdatest/utils.d.ts.map +1 -0
  52. package/dist/providers/lambdatest/utils.js +36 -0
  53. package/dist/providers/local/index.d.ts +13 -0
  54. package/dist/providers/local/index.d.ts.map +1 -0
  55. package/dist/providers/local/index.js +86 -0
  56. package/dist/reporter.d.ts +13 -0
  57. package/dist/reporter.d.ts.map +1 -0
  58. package/dist/reporter.js +216 -0
  59. package/dist/tests/locator.spec.d.ts +2 -0
  60. package/dist/tests/locator.spec.d.ts.map +1 -0
  61. package/dist/tests/locator.spec.js +89 -0
  62. package/dist/tests/regex.spec.d.ts +2 -0
  63. package/dist/tests/regex.spec.d.ts.map +1 -0
  64. package/dist/tests/regex.spec.js +19 -0
  65. package/dist/tests/vitest.config.d.mts +3 -0
  66. package/dist/tests/vitest.config.d.mts.map +1 -0
  67. package/dist/tests/vitest.config.mjs +6 -0
  68. package/dist/types/errors.d.ts +7 -0
  69. package/dist/types/errors.d.ts.map +1 -0
  70. package/dist/types/errors.js +15 -0
  71. package/dist/types/index.d.ts +234 -0
  72. package/dist/types/index.d.ts.map +1 -0
  73. package/dist/types/index.js +22 -0
  74. package/dist/utils.d.ts +8 -0
  75. package/dist/utils.d.ts.map +1 -0
  76. package/dist/utils.js +66 -0
  77. package/dist/vision/index.d.ts +64 -0
  78. package/dist/vision/index.d.ts.map +1 -0
  79. package/dist/vision/index.js +106 -0
  80. package/package.json +63 -0
  81. package/tsconfig.json +15 -0
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const providers_1 = require("./providers");
4
+ async function globalSetup(config) {
5
+ const args = process.argv;
6
+ const projects = [];
7
+ args.forEach((arg, index) => {
8
+ if (arg === "--project") {
9
+ const project = args[index + 1];
10
+ if (project) {
11
+ projects.push(project);
12
+ }
13
+ else {
14
+ throw new Error("Project name is required with --project flag");
15
+ }
16
+ }
17
+ });
18
+ if (projects.length == 0) {
19
+ // Capability to run all projects is not supported currently
20
+ // This will be added after support for using same appium server for multiple projects is added
21
+ throw new Error("Capability to run all projects is not supported. Please specify the project name with --project flag.");
22
+ }
23
+ for (let i = 0; i < config.projects.length; i++) {
24
+ if (projects.includes(config.projects[i].name)) {
25
+ const provider = (0, providers_1.createDeviceProvider)(config.projects[i]);
26
+ await provider.globalSetup?.();
27
+ }
28
+ }
29
+ }
30
+ exports.default = globalSetup;
@@ -0,0 +1,5 @@
1
+ export { test, expect } from "./fixture";
2
+ export { defineConfig } from "./config";
3
+ export { Device } from "./device";
4
+ export * from "./types";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,cAAc,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = 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);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Device = exports.defineConfig = exports.expect = exports.test = void 0;
18
+ var fixture_1 = require("./fixture");
19
+ Object.defineProperty(exports, "test", { enumerable: true, get: function () { return fixture_1.test; } });
20
+ Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return fixture_1.expect; } });
21
+ var config_1 = require("./config");
22
+ Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return config_1.defineConfig; } });
23
+ var device_1 = require("./device");
24
+ Object.defineProperty(exports, "Device", { enumerable: true, get: function () { return device_1.Device; } });
25
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,25 @@
1
+ import { Client as WebDriverClient } from "webdriver";
2
+ import { ElementReference, ScrollDirection, TimeoutOptions, ActionOptions } from "../types";
3
+ export declare class Locator {
4
+ private webDriverClient;
5
+ private timeoutOpts;
6
+ private selector;
7
+ private findStrategy;
8
+ private textToMatch?;
9
+ constructor(webDriverClient: WebDriverClient, timeoutOpts: TimeoutOptions, selector: string, findStrategy: string, textToMatch?: (string | RegExp) | undefined);
10
+ fill(value: string, options?: ActionOptions): Promise<void>;
11
+ sendKeyStrokes(value: string, options?: ActionOptions): Promise<void>;
12
+ isVisible(options?: ActionOptions): Promise<boolean>;
13
+ waitFor(state: "attached" | "visible", options?: ActionOptions): Promise<void>;
14
+ private waitUntil;
15
+ tap(options?: ActionOptions): Promise<void>;
16
+ getText(options?: ActionOptions): Promise<string>;
17
+ scroll(direction: ScrollDirection): Promise<void>;
18
+ /**
19
+ * Retrieves the element reference based on the `selector`.
20
+ *
21
+ * @returns
22
+ */
23
+ getElement(): Promise<ElementReference | null>;
24
+ }
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/locator/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,aAAa,EAEd,MAAM,UAAU,CAAC;AAIlB,qBAAa,OAAO;IAEhB,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,WAAW;IAEnB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,YAAY;IAEpB,OAAO,CAAC,WAAW,CAAC;gBANZ,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,cAAc,EAE3B,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EAEpB,WAAW,CAAC,GAAE,MAAM,GAAG,MAAM,aAAA;IAIjC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB3D,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAqCrE,SAAS,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAYpD,OAAO,CACX,KAAK,EAAE,UAAU,GAAG,SAAS,EAC7B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,IAAI,CAAC;YAgCF,SAAS;IAiCjB,GAAG,CAAC,OAAO,CAAC,EAAE,aAAa;IAiB3B,OAAO,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAqBjD,MAAM,CAAC,SAAS,EAAE,eAAe;IAuBvC;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;CAkDrD"}
@@ -0,0 +1,296 @@
1
+ "use strict";
2
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
3
+ var useValue = arguments.length > 2;
4
+ for (var i = 0; i < initializers.length; i++) {
5
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
6
+ }
7
+ return useValue ? value : void 0;
8
+ };
9
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
10
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
11
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
12
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
13
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
14
+ var _, done = false;
15
+ for (var i = decorators.length - 1; i >= 0; i--) {
16
+ var context = {};
17
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
18
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
19
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
20
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
21
+ if (kind === "accessor") {
22
+ if (result === void 0) continue;
23
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
24
+ if (_ = accept(result.get)) descriptor.get = _;
25
+ if (_ = accept(result.set)) descriptor.set = _;
26
+ if (_ = accept(result.init)) initializers.unshift(_);
27
+ }
28
+ else if (_ = accept(result)) {
29
+ if (kind === "field") initializers.unshift(_);
30
+ else descriptor[key] = _;
31
+ }
32
+ }
33
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
34
+ done = true;
35
+ };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.Locator = void 0;
41
+ const async_retry_1 = __importDefault(require("async-retry"));
42
+ const types_1 = require("../types");
43
+ const utils_1 = require("../utils");
44
+ const errors_1 = require("../types/errors");
45
+ let Locator = (() => {
46
+ let _instanceExtraInitializers = [];
47
+ let _fill_decorators;
48
+ let _sendKeyStrokes_decorators;
49
+ let _tap_decorators;
50
+ let _getText_decorators;
51
+ let _scroll_decorators;
52
+ return class Locator {
53
+ static {
54
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
55
+ _fill_decorators = [utils_1.boxedStep];
56
+ _sendKeyStrokes_decorators = [utils_1.boxedStep];
57
+ _tap_decorators = [utils_1.boxedStep];
58
+ _getText_decorators = [utils_1.boxedStep];
59
+ _scroll_decorators = [utils_1.boxedStep];
60
+ __esDecorate(this, null, _fill_decorators, { kind: "method", name: "fill", static: false, private: false, access: { has: obj => "fill" in obj, get: obj => obj.fill }, metadata: _metadata }, null, _instanceExtraInitializers);
61
+ __esDecorate(this, null, _sendKeyStrokes_decorators, { kind: "method", name: "sendKeyStrokes", static: false, private: false, access: { has: obj => "sendKeyStrokes" in obj, get: obj => obj.sendKeyStrokes }, metadata: _metadata }, null, _instanceExtraInitializers);
62
+ __esDecorate(this, null, _tap_decorators, { kind: "method", name: "tap", static: false, private: false, access: { has: obj => "tap" in obj, get: obj => obj.tap }, metadata: _metadata }, null, _instanceExtraInitializers);
63
+ __esDecorate(this, null, _getText_decorators, { kind: "method", name: "getText", static: false, private: false, access: { has: obj => "getText" in obj, get: obj => obj.getText }, metadata: _metadata }, null, _instanceExtraInitializers);
64
+ __esDecorate(this, null, _scroll_decorators, { kind: "method", name: "scroll", static: false, private: false, access: { has: obj => "scroll" in obj, get: obj => obj.scroll }, metadata: _metadata }, null, _instanceExtraInitializers);
65
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
66
+ }
67
+ webDriverClient = __runInitializers(this, _instanceExtraInitializers);
68
+ timeoutOpts;
69
+ selector;
70
+ findStrategy;
71
+ textToMatch;
72
+ constructor(webDriverClient, timeoutOpts,
73
+ // Used for find elements request that is sent to Appium server
74
+ selector, findStrategy,
75
+ // Used to filter elements received from Appium server
76
+ textToMatch) {
77
+ this.webDriverClient = webDriverClient;
78
+ this.timeoutOpts = timeoutOpts;
79
+ this.selector = selector;
80
+ this.findStrategy = findStrategy;
81
+ this.textToMatch = textToMatch;
82
+ }
83
+ async fill(value, options) {
84
+ const isElementDisplayed = await this.isVisible(options);
85
+ if (isElementDisplayed) {
86
+ const element = await this.getElement();
87
+ if (element) {
88
+ await this.webDriverClient.elementSendKeys(element["element-6066-11e4-a52e-4f735466cecf"], value);
89
+ }
90
+ else {
91
+ throw new Error(`Failed to fill: Element "${this.selector}" is not found`);
92
+ }
93
+ }
94
+ else {
95
+ throw new Error(`Failed to fill: Element "${this.selector}" not visible`);
96
+ }
97
+ }
98
+ async sendKeyStrokes(value, options) {
99
+ const isElementDisplayed = await this.isVisible(options);
100
+ if (isElementDisplayed) {
101
+ const element = await this.getElement();
102
+ if (element) {
103
+ await this.webDriverClient.elementClick(element["element-6066-11e4-a52e-4f735466cecf"]);
104
+ const actions = value
105
+ .split("")
106
+ .map((char) => [
107
+ { type: "keyDown", value: char },
108
+ { type: "keyUp", value: char },
109
+ ])
110
+ .flat();
111
+ await this.webDriverClient.performActions([
112
+ {
113
+ type: "key",
114
+ id: "keyboard",
115
+ actions: actions,
116
+ },
117
+ ]);
118
+ await this.webDriverClient.releaseActions();
119
+ }
120
+ else {
121
+ throw new Error(`Failed to sendKeyStrokes: Element "${this.selector}" is not found`);
122
+ }
123
+ }
124
+ else {
125
+ throw new Error(`Failed to sendKeyStrokes: Element "${this.selector}" not visible`);
126
+ }
127
+ }
128
+ async isVisible(options) {
129
+ try {
130
+ await this.waitFor("visible", options);
131
+ return true;
132
+ }
133
+ catch (err) {
134
+ if (err instanceof errors_1.TimeoutError) {
135
+ return false;
136
+ }
137
+ throw err;
138
+ }
139
+ }
140
+ async waitFor(state, options) {
141
+ const timeoutFromConfig = this.timeoutOpts.expectTimeout;
142
+ const timeout = options?.timeout || timeoutFromConfig;
143
+ const result = await this.waitUntil(async () => {
144
+ const element = await this.getElement();
145
+ if (element && element["element-6066-11e4-a52e-4f735466cecf"]) {
146
+ if (state === "attached") {
147
+ return true;
148
+ }
149
+ else if (state === "visible") {
150
+ try {
151
+ const isDisplayed = await this.webDriverClient.isElementDisplayed(element["element-6066-11e4-a52e-4f735466cecf"]);
152
+ return isDisplayed;
153
+ }
154
+ catch (error) {
155
+ //@ts-ignore
156
+ const errName = error.name;
157
+ if (errName &&
158
+ errName.includes(types_1.WebDriverErrors.StaleElementReferenceError)) {
159
+ throw new errors_1.RetryableError(`Stale element detected: ${error}`);
160
+ }
161
+ throw error;
162
+ }
163
+ }
164
+ }
165
+ return false;
166
+ }, timeout);
167
+ return result;
168
+ }
169
+ async waitUntil(condition, timeout) {
170
+ const fn = condition.bind(this.webDriverClient);
171
+ try {
172
+ return await (0, async_retry_1.default)(async () => {
173
+ const result = await fn();
174
+ if (result === false) {
175
+ throw new errors_1.RetryableError(`condition returned false`);
176
+ }
177
+ return result;
178
+ }, {
179
+ maxRetryTime: timeout,
180
+ retries: Math.ceil(timeout / 1000),
181
+ factor: 1,
182
+ });
183
+ }
184
+ catch (err) {
185
+ if (err instanceof errors_1.RetryableError) {
186
+ // Last attempt failed, no longer retryable
187
+ throw new errors_1.TimeoutError(`waitUntil condition timed out after ${timeout}ms`);
188
+ }
189
+ else {
190
+ throw err;
191
+ }
192
+ }
193
+ }
194
+ async tap(options) {
195
+ const isElementDisplayed = await this.isVisible(options);
196
+ if (isElementDisplayed) {
197
+ const element = await this.getElement();
198
+ if (element) {
199
+ await this.webDriverClient.elementClick(element["element-6066-11e4-a52e-4f735466cecf"]);
200
+ }
201
+ else {
202
+ throw new Error(`Failed to tap: Element "${this.selector}" not found`);
203
+ }
204
+ }
205
+ else {
206
+ throw new Error(`Failed to tap: Element "${this.selector}" not visible`);
207
+ }
208
+ }
209
+ async getText(options) {
210
+ const isElementDisplayed = await this.isVisible(options);
211
+ if (isElementDisplayed) {
212
+ const element = await this.getElement();
213
+ if (element) {
214
+ return await this.webDriverClient.getElementText(element["element-6066-11e4-a52e-4f735466cecf"]);
215
+ }
216
+ else {
217
+ throw new Error(`Failed to getText: Element "${this.selector}" is not found`);
218
+ }
219
+ }
220
+ else {
221
+ throw new Error(`Failed to getText: Element "${this.selector}" not visible`);
222
+ }
223
+ }
224
+ async scroll(direction) {
225
+ const element = await this.getElement();
226
+ if (!element) {
227
+ throw new Error(`Failed to scroll: Element "${this.selector}" not found`);
228
+ }
229
+ if (this.webDriverClient.isAndroid) {
230
+ await this.webDriverClient.executeScript("mobile: scrollGesture", [
231
+ {
232
+ elementId: element["element-6066-11e4-a52e-4f735466cecf"],
233
+ direction: direction,
234
+ percent: 1,
235
+ },
236
+ ]);
237
+ }
238
+ else {
239
+ await this.webDriverClient.executeScript("mobile: scroll", [
240
+ {
241
+ elementId: element["element-6066-11e4-a52e-4f735466cecf"],
242
+ direction: direction,
243
+ },
244
+ ]);
245
+ }
246
+ }
247
+ /**
248
+ * Retrieves the element reference based on the `selector`.
249
+ *
250
+ * @returns
251
+ */
252
+ async getElement() {
253
+ /**
254
+ * Determine whether `path` is a regex or string, and find elements accordingly.
255
+ *
256
+ * If `path` is a regex:
257
+ * - Iterate through all the elements on the page
258
+ * - Extract text content of each element
259
+ * - Return the first matching element
260
+ *
261
+ * If `path` is a string:
262
+ * - Use `findStrategy` (either XPath, Android UIAutomator, or iOS predicate string) to find elements
263
+ * - Apply regex to clean extra characters from the matched element’s text
264
+ * - Return the first element that matches
265
+ */
266
+ let elements = await this.webDriverClient.findElements(this.findStrategy, this.selector);
267
+ // If there is only one element, return it
268
+ if (elements.length === 1) {
269
+ return elements[0];
270
+ }
271
+ // If there are multiple elements, we reverse the order since the probability
272
+ // of finding the element is higher at higher depth
273
+ const reversedElements = elements.reverse();
274
+ for (const element of reversedElements) {
275
+ let elementText = await this.webDriverClient.getElementText(element["element-6066-11e4-a52e-4f735466cecf"]);
276
+ if (this.textToMatch) {
277
+ if (this.textToMatch instanceof RegExp &&
278
+ this.textToMatch.test(elementText)) {
279
+ return element;
280
+ }
281
+ if (typeof this.textToMatch === "string" &&
282
+ elementText.includes(this.textToMatch)) {
283
+ return element;
284
+ }
285
+ }
286
+ else {
287
+ // This is returned for cases where xpath is findStrategy and we want
288
+ // to return the last element found in the list
289
+ return element;
290
+ }
291
+ }
292
+ return null;
293
+ }
294
+ };
295
+ })();
296
+ exports.Locator = Locator;
@@ -0,0 +1,9 @@
1
+ declare class CustomLogger {
2
+ log(...args: any[]): void;
3
+ warn(...args: any[]): void;
4
+ error(...args: any[]): void;
5
+ logEmptyLine(): void;
6
+ }
7
+ export declare const logger: CustomLogger;
8
+ export {};
9
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAEA,cAAM,YAAY;IAChB,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IAIlB,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IAInB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IAIpB,YAAY;CAGb;AAED,eAAO,MAAM,MAAM,cAAqB,CAAC"}
package/dist/logger.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logger = void 0;
4
+ const picocolors_1 = require("picocolors");
5
+ class CustomLogger {
6
+ log(...args) {
7
+ console.log((0, picocolors_1.cyan)("[INFO]"), ...args);
8
+ }
9
+ warn(...args) {
10
+ console.log((0, picocolors_1.yellow)("[WARN]"), ...args);
11
+ }
12
+ error(...args) {
13
+ console.log((0, picocolors_1.red)("[ERROR]"), ...args);
14
+ }
15
+ logEmptyLine() {
16
+ console.log("\n\n");
17
+ }
18
+ }
19
+ exports.logger = new CustomLogger();
@@ -0,0 +1,15 @@
1
+ import { ChildProcess } from "child_process";
2
+ import { Platform } from "../types";
3
+ export declare function installDriver(driverName: string): Promise<void>;
4
+ export declare function startAppiumServer(provider: string): Promise<ChildProcess>;
5
+ export declare function stopAppiumServer(): Promise<unknown>;
6
+ export declare function isEmulatorInstalled(platform: Platform): Promise<boolean>;
7
+ export declare function startAndroidEmulator(): Promise<void>;
8
+ export declare function getAppBundleId(path: string): Promise<string>;
9
+ export declare function getConnectedIOSDeviceUDID(): Promise<string>;
10
+ export declare function getActiveAndroidDevices(): Promise<number>;
11
+ export declare function getApkDetails(buildPath: string): Promise<{
12
+ packageName: string | undefined;
13
+ launchableActivity: string | undefined;
14
+ }>;
15
+ //# sourceMappingURL=appium.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appium.d.ts","sourceRoot":"","sources":["../../src/providers/appium.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAQpC,wBAAsB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BrE;AAED,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,CAAC,CAgDvB;AAED,wBAAgB,gBAAgB,qBAW/B;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAmCxE;AAED,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAiE1D;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAoB5D;AAED,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,MAAM,CAAC,CAmCjE;AAED,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAAC,CAe/D;AA0BD,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9D,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC,CAAC,CA0CD"}