automation_model 1.0.433-dev → 1.0.433-stage

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/lib/network.js ADDED
@@ -0,0 +1,123 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+ function _getNetworkFile(world = null, stable = null, context = null) {
4
+ let networkFile = null;
5
+ if (world && world.reportFolder) {
6
+ networkFile = path.join(world.reportFolder, "network.json");
7
+ }
8
+ else if (stable.reportFolder) {
9
+ networkFile = path.join(stable.reportFolder, "network.json");
10
+ }
11
+ else if (context && context.reportFolder) {
12
+ networkFile = path.join(context.reportFolder, "network.json");
13
+ }
14
+ else {
15
+ networkFile = "network.json";
16
+ }
17
+ return networkFile;
18
+ }
19
+ function registerNetworkEvents(world, stable, context, page) {
20
+ const networkFile = _getNetworkFile(world, stable, context);
21
+ function saveNetworkData() {
22
+ if (context && context.networkData) {
23
+ fs.writeFileSync(networkFile, JSON.stringify(context.networkData, null, 2), "utf8");
24
+ }
25
+ }
26
+ if (!context) {
27
+ console.error("No context found to register network events");
28
+ return;
29
+ }
30
+ // Map to hold request start times and IDs
31
+ const requestTimes = new Map();
32
+ let requestIdCounter = 0;
33
+ if (page) {
34
+ if (!context.networkData) {
35
+ context.networkData = [];
36
+ const networkData = context.networkData;
37
+ // Event listener for when a request is made
38
+ page.on("request", (request) => {
39
+ const requestId = requestIdCounter++;
40
+ request.requestId = requestId; // Assign a unique ID to the request
41
+ const startTime = Date.now();
42
+ requestTimes.set(requestId, startTime);
43
+ // Initialize data for this request
44
+ networkData.push({
45
+ requestId,
46
+ requestStart: startTime,
47
+ requestUrl: request.url(),
48
+ method: request.method(),
49
+ status: "Pending",
50
+ responseTime: null,
51
+ responseReceived: null,
52
+ responseEnd: null,
53
+ size: null,
54
+ });
55
+ saveNetworkData();
56
+ });
57
+ // Event listener for when a response is received
58
+ page.on("response", async (response) => {
59
+ const request = response.request();
60
+ const requestId = request.requestId;
61
+ const receivedTime = Date.now();
62
+ // Find the corresponding data object
63
+ const data = networkData.find((item) => item.requestId === requestId);
64
+ if (data) {
65
+ data.status = response.status();
66
+ data.responseReceived = receivedTime;
67
+ saveNetworkData();
68
+ }
69
+ else {
70
+ console.error("No data found for request ID", requestId);
71
+ }
72
+ });
73
+ // Event listener for when a request is finished
74
+ page.on("requestfinished", async (request) => {
75
+ const requestId = request.requestId;
76
+ const endTime = Date.now();
77
+ const startTime = requestTimes.get(requestId);
78
+ const response = await request.response();
79
+ // Find the corresponding data object
80
+ const data = networkData.find((item) => item.requestId === requestId);
81
+ if (data) {
82
+ data.responseEnd = endTime;
83
+ data.responseTime = endTime - startTime;
84
+ // Get response size
85
+ try {
86
+ const body = await response.body();
87
+ data.size = body.length;
88
+ }
89
+ catch (e) {
90
+ data.size = 0;
91
+ }
92
+ saveNetworkData();
93
+ }
94
+ else {
95
+ console.error("No data found for request ID", requestId);
96
+ }
97
+ });
98
+ // Event listener for when a request fails
99
+ page.on("requestfailed", (request) => {
100
+ const requestId = request.requestId;
101
+ const endTime = Date.now();
102
+ const startTime = requestTimes.get(requestId);
103
+ // Find the corresponding data object
104
+ const data = networkData.find((item) => item.requestId === requestId);
105
+ if (data) {
106
+ data.responseEnd = endTime;
107
+ data.responseTime = endTime - startTime;
108
+ data.status = "Failed";
109
+ data.size = 0;
110
+ saveNetworkData();
111
+ }
112
+ else {
113
+ console.error("No data found for request ID", requestId);
114
+ }
115
+ });
116
+ }
117
+ }
118
+ else {
119
+ console.error("No page found to register network events");
120
+ }
121
+ }
122
+ export { registerNetworkEvents };
123
+ //# sourceMappingURL=network.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network.js","sourceRoot":"","sources":["../../src/network.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,SAAS,eAAe,CAAC,QAAa,IAAI,EAAE,SAAc,IAAI,EAAE,UAAe,IAAI;IACjF,IAAI,WAAW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C3B,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;gBAE9C,qCAAqC;gBACrC,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC;gBAE3E,IAAI,IAAI,EAAE;oBACR,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;oBAC3B,IAAI,CAAC,YAAY,GAAG,OAAO,GAAG,SAAS,CAAC;oBACxC,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC;oBACvB,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;oBACd,eAAe,EAAE,CAAC;iBACnB;qBAAM;oBACL,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,SAAS,CAAC,CAAC;iBAC1D;YACH,CAAC,CAAC,CAAC;SACJ;KACF;SAAM;QACL,OAAO,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;KAC3D;AACH,CAAC;AACD,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
@@ -1,19 +1,25 @@
1
1
  import type { Browser, Page } from "playwright";
2
2
  type Params = Record<string, string>;
3
+ export declare const apps: {};
3
4
  declare class StableBrowser {
4
5
  browser: Browser;
5
6
  page: Page;
6
7
  logger: any;
7
8
  context: any;
9
+ world?: any;
8
10
  project_path: null;
9
11
  webLogFile: null;
12
+ networkLogger: null;
10
13
  configuration: null;
11
- constructor(browser: Browser, page: Page, logger?: any, context?: any);
14
+ appName: string;
15
+ constructor(browser: Browser, page: Page, logger?: any, context?: any, world?: any);
16
+ registerEventListeners(context: any): void;
17
+ switchApp(appName: any): Promise<void>;
18
+ _copyContext(from: any, to: any): void;
12
19
  getWebLogFile(logFolder: string): string;
13
- registerConsoleLogListener(page: Page, context: any, logFile: string): void;
14
- registerRequestListener(): void;
20
+ registerConsoleLogListener(page: Page, context: any): void;
21
+ registerRequestListener(page: Page, context: any, logFile: string): void;
15
22
  goto(url: string): Promise<void>;
16
- _validateSelectors(selectors: any): void;
17
23
  _fixUsingParams(text: any, _params: Params): any;
18
24
  _fixLocatorUsingParams(locator: any, _params: Params): any;
19
25
  _isObject(value: any): any;
@@ -25,20 +31,24 @@ declare class StableBrowser {
25
31
  closeUnexpectedPopups(info: any, _params: any): Promise<{
26
32
  rerun: boolean;
27
33
  }>;
28
- _locate(selectors: any, info: any, _params?: Params, timeout?: number): Promise<any>;
34
+ _locate(selectors: any, info: any, _params?: Params, timeout: any): Promise<any>;
35
+ _findFrameScope(selectors: any, timeout?: number): Promise<any>;
36
+ _getDocumentBody(selectors: any, timeout?: number): Promise<any>;
29
37
  _locate_internal(selectors: any, info: any, _params?: Params, timeout?: number): Promise<any>;
30
38
  _scanLocatorsGroup(locatorsGroup: any, scope: any, _params: any, info: any, visibleOnly: any): Promise<{
31
39
  foundElements: any[];
32
40
  }>;
33
- click(selectors: any, _params?: Params, options?: {}, world?: null): Promise<{}>;
34
- setCheck(selectors: any, checked?: boolean, _params?: Params, options?: {}, world?: null): Promise<{}>;
35
- hover(selectors: any, _params?: Params, options?: {}, world?: null): Promise<{}>;
36
- selectOption(selectors: any, values: any, _params?: null, options?: {}, world?: null): Promise<{}>;
37
- type(_value: any, _params?: null, options?: {}, world?: null): Promise<{}>;
41
+ simpleClick(elementDescription: any, _params?: Params, options?: {}, world?: null): Promise<void>;
42
+ simpleClickType(elementDescription: any, value: any, _params?: Params, options?: {}, world?: null): Promise<void>;
43
+ click(selectors: any, _params?: Params, options?: {}, world?: null): Promise<any>;
44
+ setCheck(selectors: any, checked?: boolean, _params?: Params, options?: {}, world?: null): Promise<any>;
45
+ hover(selectors: any, _params?: Params, options?: {}, world?: null): Promise<any>;
46
+ selectOption(selectors: any, values: any, _params?: null, options?: {}, world?: null): Promise<any>;
47
+ type(_value: any, _params?: null, options?: {}, world?: null): Promise<any>;
38
48
  setInputValue(selectors: any, value: any, _params?: null, options?: {}, world?: null): Promise<void>;
39
49
  setDateTime(selectors: any, value: any, format?: null, enter?: boolean, _params?: null, options?: {}, world?: null): Promise<void>;
40
- clickType(selectors: any, _value: any, enter?: boolean, _params?: null, options?: {}, world?: null): Promise<{}>;
41
- fill(selectors: any, value: any, enter?: boolean, _params?: null, options?: {}, world?: null): Promise<{}>;
50
+ clickType(selectors: any, _value: any, enter?: boolean, _params?: null, options?: {}, world?: null): Promise<any>;
51
+ fill(selectors: any, value: any, enter?: boolean, _params?: null, options?: {}, world?: null): Promise<any>;
42
52
  getText(selectors: any, _params?: null, options?: {}, info?: {}, world?: null): Promise<{
43
53
  text: any;
44
54
  screenshotId: any;
@@ -65,8 +75,8 @@ declare class StableBrowser {
65
75
  value: any;
66
76
  element?: undefined;
67
77
  }>;
68
- containsPattern(selectors: any, pattern: any, text: any, _params?: null, options?: {}, world?: null): Promise<{}>;
69
- containsText(selectors: any, text: any, climb: any, _params?: null, options?: {}, world?: null): Promise<{}>;
78
+ containsPattern(selectors: any, pattern: any, text: any, _params?: null, options?: {}, world?: null): Promise<any>;
79
+ containsText(selectors: any, text: any, climb: any, _params?: null, options?: {}, world?: null): Promise<any>;
70
80
  _getDataFile(world?: null): string;
71
81
  waitForUserInput(message: any, world?: null): Promise<void>;
72
82
  setTestData(testData: any, world?: null): void;
@@ -81,7 +91,7 @@ declare class StableBrowser {
81
91
  getTestData(world?: null): {};
82
92
  _screenShot(options?: {}, world?: null, info?: null): Promise<{}>;
83
93
  takeScreenshot(screenshotPath: any): Promise<any>;
84
- verifyElementExistInPage(selectors: any, _params?: null, options?: {}, world?: null): Promise<{}>;
94
+ verifyElementExistInPage(selectors: any, _params?: null, options?: {}, world?: null): Promise<any>;
85
95
  extractAttribute(selectors: any, attribute: any, variable: any, _params?: null, options?: {}, world?: null): Promise<{}>;
86
96
  extractEmailData(emailAddress: any, options: any, world: any): Promise<{
87
97
  emailUrl: any;
@@ -95,7 +105,7 @@ declare class StableBrowser {
95
105
  verifyTableData(selectors: any, data: any, _params?: null, options?: {}, world?: null): Promise<void>;
96
106
  getTableData(selectors: any, _params?: null, options?: {}, world?: null): Promise<any>;
97
107
  analyzeTable(selectors: any, query: any, operator: any, value: any, _params?: null, options?: {}, world?: null): Promise<{}>;
98
- _replaceWithLocalData(value: any, world: any, _decrypt?: boolean, totpWait?: boolean): Promise<any>;
108
+ _replaceWithLocalData(value: any, world: any, _decrypt?: boolean, totpWait?: boolean): Promise<string>;
99
109
  _getLoadTimeout(options: any): number;
100
110
  waitForPageLoad(options?: {}, world?: null): Promise<void>;
101
111
  closePage(options?: {}, world?: null): Promise<void>;