gpt-driver-node 1.0.3 → 1.0.5
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.
- package/dist/index.cjs +643 -119
- package/dist/index.d.cts +161 -11
- package/dist/index.mjs +643 -119
- package/package.json +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -155,21 +155,36 @@ declare const SavableTestStoreSchema: z.ZodObject<{
|
|
|
155
155
|
id: z.ZodOptional<z.ZodNumber>;
|
|
156
156
|
descriptionText: z.ZodOptional<z.ZodString>;
|
|
157
157
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
158
|
+
direction: z.ZodEnum<["left", "right", "up", "down"]>;
|
|
159
|
+
x1: z.ZodOptional<z.ZodNumber>;
|
|
160
|
+
y1: z.ZodOptional<z.ZodNumber>;
|
|
161
|
+
x2: z.ZodOptional<z.ZodNumber>;
|
|
162
|
+
y2: z.ZodOptional<z.ZodNumber>;
|
|
163
|
+
duration: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
158
164
|
} & {
|
|
159
165
|
type: z.ZodLiteral<"scroll">;
|
|
160
|
-
direction: z.ZodEnum<["up", "down"]>;
|
|
161
166
|
}, "strip", z.ZodTypeAny, {
|
|
162
167
|
type: "scroll";
|
|
163
|
-
direction: "up" | "down";
|
|
168
|
+
direction: "left" | "right" | "up" | "down";
|
|
169
|
+
duration: number;
|
|
164
170
|
id?: number | undefined;
|
|
165
171
|
descriptionText?: string | undefined;
|
|
166
172
|
optional?: boolean | undefined;
|
|
173
|
+
x1?: number | undefined;
|
|
174
|
+
y1?: number | undefined;
|
|
175
|
+
x2?: number | undefined;
|
|
176
|
+
y2?: number | undefined;
|
|
167
177
|
}, {
|
|
168
178
|
type: "scroll";
|
|
169
|
-
direction: "up" | "down";
|
|
179
|
+
direction: "left" | "right" | "up" | "down";
|
|
170
180
|
id?: number | undefined;
|
|
171
181
|
descriptionText?: string | undefined;
|
|
172
182
|
optional?: boolean | undefined;
|
|
183
|
+
x1?: number | undefined;
|
|
184
|
+
y1?: number | undefined;
|
|
185
|
+
x2?: number | undefined;
|
|
186
|
+
y2?: number | undefined;
|
|
187
|
+
duration?: number | undefined;
|
|
173
188
|
}>, z.ZodObject<{
|
|
174
189
|
id: z.ZodOptional<z.ZodNumber>;
|
|
175
190
|
descriptionText: z.ZodOptional<z.ZodString>;
|
|
@@ -259,6 +274,25 @@ declare const SavableTestStoreSchema: z.ZodObject<{
|
|
|
259
274
|
id: z.ZodOptional<z.ZodNumber>;
|
|
260
275
|
descriptionText: z.ZodOptional<z.ZodString>;
|
|
261
276
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
277
|
+
} & {
|
|
278
|
+
type: z.ZodLiteral<"enter">;
|
|
279
|
+
delayNextStep: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
280
|
+
}, "strip", z.ZodTypeAny, {
|
|
281
|
+
type: "enter";
|
|
282
|
+
delayNextStep: number;
|
|
283
|
+
id?: number | undefined;
|
|
284
|
+
descriptionText?: string | undefined;
|
|
285
|
+
optional?: boolean | undefined;
|
|
286
|
+
}, {
|
|
287
|
+
type: "enter";
|
|
288
|
+
id?: number | undefined;
|
|
289
|
+
descriptionText?: string | undefined;
|
|
290
|
+
optional?: boolean | undefined;
|
|
291
|
+
delayNextStep?: number | undefined;
|
|
292
|
+
}>, z.ZodObject<{
|
|
293
|
+
id: z.ZodOptional<z.ZodNumber>;
|
|
294
|
+
descriptionText: z.ZodOptional<z.ZodString>;
|
|
295
|
+
optional: z.ZodOptional<z.ZodBoolean>;
|
|
262
296
|
} & {
|
|
263
297
|
type: z.ZodLiteral<"fileRef">;
|
|
264
298
|
path: z.ZodString;
|
|
@@ -318,10 +352,15 @@ declare const SavableTestStoreSchema: z.ZodObject<{
|
|
|
318
352
|
y2?: number | undefined;
|
|
319
353
|
} | {
|
|
320
354
|
type: "scroll";
|
|
321
|
-
direction: "up" | "down";
|
|
355
|
+
direction: "left" | "right" | "up" | "down";
|
|
356
|
+
duration: number;
|
|
322
357
|
id?: number | undefined;
|
|
323
358
|
descriptionText?: string | undefined;
|
|
324
359
|
optional?: boolean | undefined;
|
|
360
|
+
x1?: number | undefined;
|
|
361
|
+
y1?: number | undefined;
|
|
362
|
+
x2?: number | undefined;
|
|
363
|
+
y2?: number | undefined;
|
|
325
364
|
} | {
|
|
326
365
|
type: "zoom";
|
|
327
366
|
direction: "in" | "out";
|
|
@@ -349,6 +388,12 @@ declare const SavableTestStoreSchema: z.ZodObject<{
|
|
|
349
388
|
id?: number | undefined;
|
|
350
389
|
descriptionText?: string | undefined;
|
|
351
390
|
optional?: boolean | undefined;
|
|
391
|
+
} | {
|
|
392
|
+
type: "enter";
|
|
393
|
+
delayNextStep: number;
|
|
394
|
+
id?: number | undefined;
|
|
395
|
+
descriptionText?: string | undefined;
|
|
396
|
+
optional?: boolean | undefined;
|
|
352
397
|
} | {
|
|
353
398
|
path: string;
|
|
354
399
|
type: "fileRef";
|
|
@@ -397,10 +442,15 @@ declare const SavableTestStoreSchema: z.ZodObject<{
|
|
|
397
442
|
duration?: number | undefined;
|
|
398
443
|
} | {
|
|
399
444
|
type: "scroll";
|
|
400
|
-
direction: "up" | "down";
|
|
445
|
+
direction: "left" | "right" | "up" | "down";
|
|
401
446
|
id?: number | undefined;
|
|
402
447
|
descriptionText?: string | undefined;
|
|
403
448
|
optional?: boolean | undefined;
|
|
449
|
+
x1?: number | undefined;
|
|
450
|
+
y1?: number | undefined;
|
|
451
|
+
x2?: number | undefined;
|
|
452
|
+
y2?: number | undefined;
|
|
453
|
+
duration?: number | undefined;
|
|
404
454
|
} | {
|
|
405
455
|
type: "zoom";
|
|
406
456
|
direction: "in" | "out";
|
|
@@ -428,6 +478,12 @@ declare const SavableTestStoreSchema: z.ZodObject<{
|
|
|
428
478
|
id?: number | undefined;
|
|
429
479
|
descriptionText?: string | undefined;
|
|
430
480
|
optional?: boolean | undefined;
|
|
481
|
+
} | {
|
|
482
|
+
type: "enter";
|
|
483
|
+
id?: number | undefined;
|
|
484
|
+
descriptionText?: string | undefined;
|
|
485
|
+
optional?: boolean | undefined;
|
|
486
|
+
delayNextStep?: number | undefined;
|
|
431
487
|
} | {
|
|
432
488
|
path: string;
|
|
433
489
|
type: "fileRef";
|
|
@@ -456,7 +512,11 @@ declare class GptDriver {
|
|
|
456
512
|
private step_number;
|
|
457
513
|
private organisationId?;
|
|
458
514
|
private configFilePath?;
|
|
515
|
+
private _stats_startTime;
|
|
516
|
+
private _stats_executedSteps;
|
|
517
|
+
private _stats_cacheHits;
|
|
459
518
|
private globalActionHistory;
|
|
519
|
+
private pendingLogPromises;
|
|
460
520
|
/**
|
|
461
521
|
* Creates an instance of the GptDriver class.
|
|
462
522
|
*
|
|
@@ -500,7 +560,35 @@ declare class GptDriver {
|
|
|
500
560
|
*
|
|
501
561
|
* @throws {Error} If the request to stop the session fails.
|
|
502
562
|
*/
|
|
503
|
-
|
|
563
|
+
/**
|
|
564
|
+
* Marks the current GPTDriver session as succeeded.
|
|
565
|
+
*
|
|
566
|
+
* This method stops the session and logs it as "succeeded"
|
|
567
|
+
*
|
|
568
|
+
* @throws {Error} If the request to stop the session fails.
|
|
569
|
+
*/
|
|
570
|
+
setSessionSucceeded(): Promise<void>;
|
|
571
|
+
/**
|
|
572
|
+
* Marks the current GPTDriver session as failed.
|
|
573
|
+
*
|
|
574
|
+
* This method stops the session and logs it as "failed."
|
|
575
|
+
*
|
|
576
|
+
* @throws {Error} If the request to stop the session fails.
|
|
577
|
+
*/
|
|
578
|
+
setSessionFailed(): Promise<void>;
|
|
579
|
+
/**
|
|
580
|
+
* Stops the current GPTDriver session and update its state.
|
|
581
|
+
*
|
|
582
|
+
* This method sends a request to the GPT Driver server to stop the session and logs the session status as either "failed" or "success."
|
|
583
|
+
*
|
|
584
|
+
* @param {"failed" | "success"} status - Indicates the outcome of the session.
|
|
585
|
+
* Use "success" if the session completed as expected,
|
|
586
|
+
* or "failed" if the session encountered an error or issue.
|
|
587
|
+
*
|
|
588
|
+
* @throws {Error} If the request to stop the session fails.
|
|
589
|
+
*/
|
|
590
|
+
setSessionStatus(status: "failed" | "succeeded"): Promise<void>;
|
|
591
|
+
private printSessionSummary;
|
|
504
592
|
/**
|
|
505
593
|
* Creates a SmartLoopContext for the current session.
|
|
506
594
|
* This context provides all the callbacks needed by the smart loop executor.
|
|
@@ -517,6 +605,7 @@ declare class GptDriver {
|
|
|
517
605
|
*/
|
|
518
606
|
private performTap;
|
|
519
607
|
private performType;
|
|
608
|
+
private performPressEnter;
|
|
520
609
|
private clamp;
|
|
521
610
|
private scaleForIOS;
|
|
522
611
|
private performSwipe;
|
|
@@ -641,10 +730,32 @@ declare class GptDriver {
|
|
|
641
730
|
* If the assertion fails, an error is thrown.
|
|
642
731
|
*
|
|
643
732
|
* @param {string} assertion - The condition to be asserted.
|
|
644
|
-
* @param
|
|
733
|
+
* @param {Object} options - Optional configuration object
|
|
734
|
+
* @param {CachingMode} options.cachingMode - The caching mode to be used for the assertion.
|
|
735
|
+
* @param {boolean} options.useSmartLoop - If true, uses the smart loop execution for optimized caching. Default: false
|
|
645
736
|
* @throws {Error} If the assertion fails.
|
|
737
|
+
*
|
|
738
|
+
* @example
|
|
739
|
+
* // Basic usage
|
|
740
|
+
* await driver.assert('Login button is visible');
|
|
741
|
+
*
|
|
742
|
+
* @example
|
|
743
|
+
* // With caching mode
|
|
744
|
+
* await driver.assert('Login button is visible', {
|
|
745
|
+
* cachingMode: "FULL_SCREEN"
|
|
746
|
+
* });
|
|
747
|
+
*
|
|
748
|
+
* @example
|
|
749
|
+
* // With smart loop enabled
|
|
750
|
+
* await driver.assert('Login button is visible', {
|
|
751
|
+
* useSmartLoop: true,
|
|
752
|
+
* cachingMode: "FULL_SCREEN"
|
|
753
|
+
* });
|
|
646
754
|
*/
|
|
647
|
-
assert(assertion: string, cachingMode
|
|
755
|
+
assert(assertion: string, { cachingMode, useSmartLoop }: {
|
|
756
|
+
cachingMode?: CachingMode;
|
|
757
|
+
useSmartLoop?: boolean;
|
|
758
|
+
}): Promise<void>;
|
|
648
759
|
/**
|
|
649
760
|
* Asserts multiple conditions using the GPTDriver.
|
|
650
761
|
*
|
|
@@ -652,10 +763,33 @@ declare class GptDriver {
|
|
|
652
763
|
* If any assertion fails, an error is thrown listing all failed assertions.
|
|
653
764
|
*
|
|
654
765
|
* @param {string[]} assertions - An array of conditions to be asserted.
|
|
655
|
-
* @param
|
|
766
|
+
* @param {Object} options - Optional configuration object
|
|
767
|
+
* @param {CachingMode} options.cachingMode - The caching mode to be used for the assertions.
|
|
768
|
+
* @param {boolean} options.useSmartLoop - If true, uses the smart loop execution. Default: false
|
|
656
769
|
* @throws {Error} If any of the assertions fail.
|
|
770
|
+
*
|
|
771
|
+
* @example
|
|
772
|
+
* // Basic usage
|
|
773
|
+
* await driver.assertBulk(['Login button is visible', 'Username field is enabled']);
|
|
774
|
+
*
|
|
775
|
+
* @example
|
|
776
|
+
* // With caching mode
|
|
777
|
+
* await driver.assertBulk(['Login button is visible'], {
|
|
778
|
+
* cachingMode: "FULL_SCREEN"
|
|
779
|
+
* });
|
|
780
|
+
*
|
|
781
|
+
* @example
|
|
782
|
+
* // With smart loop enabled
|
|
783
|
+
* await driver.assertBulk(['Login button is visible'], {
|
|
784
|
+
* useSmartLoop: true,
|
|
785
|
+
* cachingMode: "FULL_SCREEN"
|
|
786
|
+
* });
|
|
657
787
|
*/
|
|
658
|
-
assertBulk(assertions: Array<string>, cachingMode
|
|
788
|
+
assertBulk(assertions: Array<string>, { cachingMode, useSmartLoop }: {
|
|
789
|
+
cachingMode?: CachingMode;
|
|
790
|
+
useSmartLoop?: boolean;
|
|
791
|
+
useMiddleLayerAssertFunction?: boolean;
|
|
792
|
+
}): Promise<void>;
|
|
659
793
|
/**
|
|
660
794
|
* Checks multiple conditions and returns their results using the GPTDriver.
|
|
661
795
|
*
|
|
@@ -666,10 +800,26 @@ declare class GptDriver {
|
|
|
666
800
|
* @param {CachingMode} cachingMode - The caching mode to be used for the conditions.
|
|
667
801
|
* @param {number} maxRetries - The maximum number of retries if any condition fails (default: 2).
|
|
668
802
|
* @param {number} retryDelayMs - The delay in milliseconds between retries (default: 1000).
|
|
803
|
+
* @param {boolean} useSmartLoop - If true, uses the smart loop execution for optimized caching. Default: false
|
|
669
804
|
* @returns {Promise<Record<string, boolean>>} A promise that resolves with an object mapping each condition
|
|
670
805
|
* to a boolean indicating whether the condition was met.
|
|
806
|
+
*
|
|
807
|
+
* @example
|
|
808
|
+
* // Basic usage
|
|
809
|
+
* const results = await driver.checkBulk(['Login button is visible', 'Username field is enabled']);
|
|
810
|
+
* console.log(results); // { 'Login button is visible': true, 'Username field is enabled': false }
|
|
811
|
+
*
|
|
812
|
+
* @example
|
|
813
|
+
* // With smart loop enabled
|
|
814
|
+
* const results = await driver.checkBulk(
|
|
815
|
+
* ['Login button is visible'],
|
|
816
|
+
* "FULL_SCREEN",
|
|
817
|
+
* 2,
|
|
818
|
+
* 1000,
|
|
819
|
+
* true
|
|
820
|
+
* );
|
|
671
821
|
*/
|
|
672
|
-
checkBulk(conditions: Array<string>, cachingMode?: CachingMode, maxRetries?: number, retryDelayMs?: number): Promise<Record<string, boolean>>;
|
|
822
|
+
checkBulk(conditions: Array<string>, cachingMode?: CachingMode, maxRetries?: number, retryDelayMs?: number, useSmartLoop?: boolean): Promise<Record<string, boolean>>;
|
|
673
823
|
/**
|
|
674
824
|
* Internal method to check conditions once without retry logic.
|
|
675
825
|
*
|