automation_model 1.0.67 → 1.0.69

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 (47) hide show
  1. package/.github/workflows/npm-publish.yml +38 -0
  2. package/.vscode/launch.json +30 -0
  3. package/README.md +3 -0
  4. package/ai_config.json +53 -0
  5. package/env.json +3 -0
  6. package/package.json +3 -2
  7. package/src/auto_page.ts +58 -0
  8. package/src/browser_manager.ts +87 -0
  9. package/src/environment.ts +24 -0
  10. package/{lib/index.d.ts → src/index.ts} +6 -6
  11. package/src/init_browser.ts +65 -0
  12. package/src/locator.ts +173 -0
  13. package/src/stable_browser.ts +523 -0
  14. package/src/table_analyze.ts +69 -0
  15. package/src/test_context.ts +16 -0
  16. package/tests/create_new_repository.test.js +62 -0
  17. package/tests/debug.test.js +41 -0
  18. package/tests/gmail_login.test.js +39 -0
  19. package/tests/launch_page.test.js +32 -0
  20. package/tests/navigate_to_new_repository_page.test.js +45 -0
  21. package/tsconfig.json +110 -0
  22. package/lib/auto_page.d.ts +0 -5
  23. package/lib/auto_page.js +0 -56
  24. package/lib/auto_page.js.map +0 -1
  25. package/lib/browser_manager.d.ts +0 -28
  26. package/lib/browser_manager.js +0 -72
  27. package/lib/browser_manager.js.map +0 -1
  28. package/lib/environment.d.ts +0 -23
  29. package/lib/environment.js +0 -12
  30. package/lib/environment.js.map +0 -1
  31. package/lib/index.js +0 -7
  32. package/lib/index.js.map +0 -1
  33. package/lib/init_browser.d.ts +0 -7
  34. package/lib/init_browser.js +0 -59
  35. package/lib/init_browser.js.map +0 -1
  36. package/lib/locator.d.ts +0 -15
  37. package/lib/locator.js +0 -172
  38. package/lib/locator.js.map +0 -1
  39. package/lib/stable_browser.d.ts +0 -26
  40. package/lib/stable_browser.js +0 -526
  41. package/lib/stable_browser.js.map +0 -1
  42. package/lib/table_analyze.d.ts +0 -3
  43. package/lib/table_analyze.js +0 -71
  44. package/lib/table_analyze.js.map +0 -1
  45. package/lib/test_context.d.ts +0 -13
  46. package/lib/test_context.js +0 -12
  47. package/lib/test_context.js.map +0 -1
@@ -0,0 +1,41 @@
1
+ import { initContext } from "../build/auto_page.js";
2
+ import { closeBrowser } from "../build/init_browser.js";
3
+ import { getTableCells } from "../build/table_analyze.js";
4
+
5
+ const name = "login";
6
+ const path = "/";
7
+ const elements = {
8
+ textbox_username: [
9
+ [{ role: ["textbox", { name: "Username" }] }],
10
+ [
11
+ {
12
+ css: "[name='loginForm'] > div > div.inputs-container > gb-login-input.username.ng-pristine.ng-invalid.ng-touched > input",
13
+ },
14
+ ],
15
+ ],
16
+ textbox_password: [
17
+ [{ role: ["textbox", { name: "Password" }] }],
18
+ [
19
+ {
20
+ css: "[name='loginForm'] > div > div.inputs-container > gb-login-input.password.ng-invalid.ng-touched.ng-dirty > input",
21
+ },
22
+ ],
23
+ ],
24
+ button_login: [[{ role: ["button", { name: "Login" }] }], [{ css: "[name='loginForm'] > button" }]],
25
+ table: [[{ css: "gb-simple-table" }]],
26
+ };
27
+ const context = await initContext(path, true, false);
28
+ const login = async function () {
29
+ let info = null;
30
+ await context.stable.goto("https://sandbox-ext-6.glassboxcloud.com:8443/webinterface/webui/#/application-summary");
31
+ await context.stable.fill(elements.textbox_username, "BlinqIO");
32
+ await context.stable.fill(elements.textbox_password, "G11assb0x12!");
33
+ info = await context.stable.click(elements.button_login);
34
+ await context.stable.waitForPageLoad();
35
+ await new Promise((resolve) => setTimeout(resolve, 1000));
36
+ await context.stable.analyzeTable(elements.table, "table[*][Availability].text", "equals", "100%");
37
+ };
38
+ await login();
39
+
40
+ await new Promise((resolve) => setTimeout(resolve, 1000));
41
+ await closeBrowser();
@@ -0,0 +1,39 @@
1
+ import { initContext } from "../build/auto_page.js";
2
+ import { closeBrowser } from "../build/init_browser.js";
3
+
4
+ const path = "https://accounts.google.com/signin/v2/identifier?flowName=GlifWebSignIn&flowEntry=ServiceLogin";
5
+ const elements = {
6
+ textbox_username: [
7
+ [{ role: ["textbox", { name: "Email or phone" }] }],
8
+ [
9
+ {
10
+ css: "input[type='email']",
11
+ },
12
+ ],
13
+ ],
14
+ button_next: [[{ role: ["button",
15
+ { name: "Next" }] }], [{ css: "#identifierNext" }]],
16
+ textbox_password: [
17
+ [{ role: ["textbox", { name: "Enter your password" }] }],
18
+ [
19
+ {
20
+ css: "input[type='password']",
21
+ },
22
+ ],
23
+ ],
24
+ button_login: [[{ role: ["button", { name: "Next" }] }], [{ css: "#passwordNext" }]],
25
+ };
26
+ const context = await initContext(path, true, false);
27
+ const login = async function () {
28
+ let info = null;
29
+ await context.stable.fill(elements.textbox_username, "username");
30
+ info = await context.stable.click(elements.button_next);
31
+ await context.stable.waitForPageLoad();
32
+ await context.stable.fill(elements.textbox_password, "password");
33
+ info = await context.stable.click(elements.button_login);
34
+ await context.stable.waitForPageLoad();
35
+ };
36
+ await login();
37
+
38
+ await new Promise((resolve) => setTimeout(resolve, 1000));
39
+ await closeBrowser();
@@ -0,0 +1,32 @@
1
+ import { initContext } from "../build/auto_page.js";
2
+ import { closeBrowser } from "../build/init_browser.js";
3
+
4
+ const name = "login";
5
+ const path = "/";
6
+ const elements = {
7
+ sign_in: [[{ role: ["link", { name: "{signin}" }] }]],
8
+ username: [[{ css: 'input[name="login"]' }]],
9
+ loginButton: [[{ role: ["button", { name: "Sign in" }] }]],
10
+ };
11
+ const context = await initContext(path, true, true);
12
+ const login = async function () {
13
+ let info = null;
14
+ info = await context.stable.click(elements.sign_in, { signin: "Sign in" });
15
+ console.log("info click sign in", JSON.stringify(info, null, 2));
16
+ info = await context.stable.fill(elements.username, "guy");
17
+ console.log("info fill username", JSON.stringify(info, null, 2));
18
+ info = await context.stable.click(elements.loginButton);
19
+ console.log("info click login", JSON.stringify(info, null, 2));
20
+ info = await context.stable.verifyElementExistInPage([
21
+ [
22
+ {
23
+ text: "Incorrect username or password.",
24
+ },
25
+ ],
26
+ ]);
27
+ console.log("info verify", JSON.stringify(info, null, 2));
28
+ };
29
+ await login();
30
+
31
+ await new Promise((resolve) => setTimeout(resolve, 1000));
32
+ await closeBrowser();
@@ -0,0 +1,45 @@
1
+ import { initContext } from "../build/auto_page.js";
2
+ import { closeBrowser } from "../build/init_browser.js";
3
+
4
+ const path = "https://github.com/login";
5
+ const elements = {
6
+ textbox_username: [
7
+ [{ role: ["textbox", { name: "Username or email address" }] }],
8
+ [
9
+ {
10
+ css: "input[name='login']",
11
+ },
12
+ ],
13
+ ],
14
+ textbox_password: [
15
+ [{ role: ["textbox", { name: "Password" }] }],
16
+ [
17
+ {
18
+ css: "input[name='password']",
19
+ },
20
+ ],
21
+ ],
22
+ button_signin: [
23
+ [{ role: ["button", { name: "Sign in" }] }],
24
+ [
25
+ {
26
+ css: "input[type='submit']",
27
+ },
28
+ ],
29
+ ],
30
+ };
31
+ const context = await initContext(path, true, false);
32
+ const loginAndNavigate = async function () {
33
+ let info = null;
34
+ await context.stable.fill(elements.textbox_username, "username");
35
+ await context.stable.fill(elements.textbox_password, "password");
36
+ info = await context.stable.click(elements.button_signin);
37
+ await context.stable.waitForPageLoad();
38
+
39
+ await context.stable.goto("https://github.com/new");
40
+ await context.stable.waitForPageLoad();
41
+ };
42
+ await loginAndNavigate();
43
+
44
+ await new Promise((resolve) => setTimeout(resolve, 1000));
45
+ await closeBrowser();
package/tsconfig.json ADDED
@@ -0,0 +1,110 @@
1
+ {
2
+ "include": ["src/**/*"],
3
+ "compilerOptions": {
4
+ /* Visit https://aka.ms/tsconfig to read more about this file */
5
+
6
+ /* Projects */
7
+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
8
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
9
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
10
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
11
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
12
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
13
+
14
+ /* Language and Environment */
15
+ "target": "ES2017" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
16
+ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
17
+ // "jsx": "preserve", /* Specify what JSX code is generated. */
18
+ // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
19
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
20
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
21
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
22
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
23
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
24
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
25
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
26
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
27
+
28
+ /* Modules */
29
+ "module": "NodeNext" /* Specify what module code is generated. */,
30
+ // "rootDir": "./src", /* Specify the root folder within your source files. */
31
+ "moduleResolution": "NodeNext", /* Specify how TypeScript looks up a file from a given module specifier. */
32
+ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
33
+ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
34
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
35
+ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
36
+ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
37
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
38
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
39
+ // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
40
+ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
41
+ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
42
+ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
43
+ // "resolveJsonModule": true, /* Enable importing .json files. */
44
+ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
45
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
46
+
47
+ /* JavaScript Support */
48
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
49
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
50
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
51
+
52
+ /* Emit */
53
+ "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
54
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
55
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
56
+ "sourceMap": true, /* Create source map files for emitted JavaScript files. */
57
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
58
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
59
+ "outDir": "build/lib", /* Specify an output folder for all emitted files. */
60
+ // "removeComments": true, /* Disable emitting comments. */
61
+ // "noEmit": true, /* Disable emitting files from a compilation. */
62
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
63
+ // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
64
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
65
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
66
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
67
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
68
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
69
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
70
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
71
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
72
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
73
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
74
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
75
+ // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
76
+
77
+ /* Interop Constraints */
78
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
79
+ // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
80
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
81
+ "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
82
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
83
+ "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
84
+
85
+ /* Type Checking */
86
+ "strict": true /* Enable all strict type-checking options. */,
87
+ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
88
+ // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
89
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
90
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
91
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
92
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
93
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
94
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
95
+ // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
96
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
97
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
98
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
99
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
100
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
101
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
102
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
103
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
104
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
105
+
106
+ /* Completeness */
107
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
108
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
109
+ }
110
+ }
@@ -1,5 +0,0 @@
1
- import type { TestContext } from "./test_context.js";
2
- declare const navigate: (path?: string) => Promise<void>;
3
- declare const initContext: (path: string, doNavigate?: boolean, headless?: boolean, world?: any) => Promise<TestContext>;
4
- declare const closeContext: () => Promise<void>;
5
- export { initContext, navigate, closeContext };
package/lib/auto_page.js DELETED
@@ -1,56 +0,0 @@
1
- import { browserManager } from "./browser_manager.js";
2
- import { getContext } from "./init_browser.js";
3
- import fs from "fs";
4
- import path from "path";
5
- let context = null;
6
- const navigate = async (path = "") => {
7
- let url = null;
8
- if (path === null) {
9
- url = context.environment.baseUrl;
10
- }
11
- else {
12
- url = new URL(path, context.environment.baseUrl).href;
13
- }
14
- await context.stable.goto(url);
15
- await context.stable.waitForPageLoad();
16
- };
17
- const _findEmptyFolder = (folder) => {
18
- if (!folder) {
19
- folder = "./runs";
20
- }
21
- if (!fs.existsSync(folder)) {
22
- fs.mkdirSync(folder);
23
- }
24
- let nextIndex = 1;
25
- while (fs.existsSync(path.join(folder, nextIndex.toString()))) {
26
- nextIndex++;
27
- }
28
- return path.join(folder, nextIndex.toString());
29
- };
30
- const initContext = async (path, doNavigate = true, headless = false, world = null) => {
31
- if (context) {
32
- return context;
33
- }
34
- context = await getContext(null, headless);
35
- if (world) {
36
- world.screenshot = true;
37
- const reportFolder = _findEmptyFolder();
38
- if (world.attach) {
39
- world.attach(reportFolder, { mediaType: "text/plain" });
40
- }
41
- world.screenshotPath = reportFolder;
42
- context.reportFolder = reportFolder;
43
- }
44
- if (doNavigate) {
45
- await navigate(path);
46
- }
47
- return context;
48
- };
49
- const closeContext = async () => {
50
- if (context && context.browser) {
51
- await browserManager.closeBrowser(context.browser);
52
- }
53
- context = null;
54
- };
55
- export { initContext, navigate, closeContext };
56
- //# sourceMappingURL=auto_page.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auto_page.js","sourceRoot":"","sources":["../../src/auto_page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,IAAI,OAAO,GAAoB,IAAI,CAAC;AACpC,MAAM,QAAQ,GAAG,KAAK,EAAE,IAAI,GAAG,EAAE,EAAE,EAAE;IACnC,IAAI,GAAG,GAAG,IAAI,CAAC;IACf,IAAI,IAAI,KAAK,IAAI,EAAE;QACjB,GAAG,GAAG,OAAQ,CAAC,WAAY,CAAC,OAAQ,CAAC;KACtC;SAAM;QACL,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,OAAQ,CAAC,WAAY,CAAC,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,GAAG,YAAY,CAAC;KACrC;IAED,IAAI,UAAU,EAAE;QACd,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;KACtB;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AACF,MAAM,YAAY,GAAG,KAAK,IAAI,EAAE;IAC9B,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO,EAAE;QAC9B,MAAM,cAAc,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;KACpD;IACD,OAAO,GAAG,IAAI,CAAC;AACjB,CAAC,CAAC;AACF,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC"}
@@ -1,28 +0,0 @@
1
- import { Browser as PlaywrightBrowser, BrowserContext, Page } from "playwright";
2
- import type { Cookie, LocalStorage } from "./environment.js";
3
- type StorageState = {
4
- cookies: Cookie[];
5
- origins: {
6
- origin: string;
7
- localStorage: LocalStorage;
8
- }[];
9
- };
10
- declare class BrowserManager {
11
- browsers: Browser[];
12
- constructor(browsers?: Browser[]);
13
- closeAll(): Promise<void>;
14
- closeBrowser(browser?: PlaywrightBrowser | Browser): Promise<void>;
15
- createBrowser(headless?: boolean, storageState?: StorageState): Promise<Browser>;
16
- getBrowser(headless?: boolean, storageState?: StorageState): Promise<Browser>;
17
- }
18
- declare class Browser {
19
- browser: PlaywrightBrowser | null;
20
- context: BrowserContext | null;
21
- page: Page | null;
22
- constructor();
23
- init(headless?: boolean, storageState?: StorageState): Promise<void>;
24
- close(): Promise<void>;
25
- }
26
- declare const browserManager: BrowserManager;
27
- export { browserManager };
28
- export type { BrowserManager, Browser };
@@ -1,72 +0,0 @@
1
- import { chromium } from "playwright";
2
- class BrowserManager {
3
- constructor(browsers = []) {
4
- this.browsers = browsers;
5
- }
6
- async closeAll() {
7
- await Promise.all(this.browsers.map((browser) => browser.close()));
8
- this.browsers = [];
9
- }
10
- async closeBrowser(browser) {
11
- if (!browser && this.browsers.length > 0) {
12
- browser = this.browsers[0];
13
- }
14
- if (browser) {
15
- await browser.close();
16
- for (let i = 0; i < this.browsers.length; i++) {
17
- if (this.browsers[i].browser === browser || this.browsers[i] === browser) {
18
- this.browsers.splice(i, 1);
19
- i--;
20
- break;
21
- }
22
- }
23
- }
24
- }
25
- async createBrowser(headless = false, storageState) {
26
- const browser = new Browser();
27
- await browser.init(headless, storageState);
28
- this.browsers.push(browser);
29
- return browser;
30
- }
31
- async getBrowser(headless = false, storageState) {
32
- if (this.browsers.length === 0) {
33
- return await this.createBrowser(headless, storageState);
34
- }
35
- return this.browsers[0];
36
- }
37
- }
38
- class Browser {
39
- constructor() {
40
- this.browser = null;
41
- this.context = null;
42
- this.page = null;
43
- }
44
- async init(headless = false, storageState) {
45
- this.browser = await chromium.launch({
46
- headless: headless,
47
- timeout: 0,
48
- args: ["--ignore-https-errors"],
49
- });
50
- const contextOptions = !!storageState ? { storageState } : undefined;
51
- this.context = await this.browser.newContext(contextOptions);
52
- this.page = await this.context.newPage();
53
- }
54
- async close() {
55
- if (this.browser !== null) {
56
- await this.browser.close();
57
- this.browser = null;
58
- this.context = null;
59
- this.page = null;
60
- }
61
- }
62
- }
63
- const browserManager = new BrowserManager();
64
- export { browserManager };
65
- // let browser = await browserManager.createBrowser();
66
- // browser.page.goto("https://www.cnn.com");
67
- // let browser2 = await browserManager.createBrowser();
68
- // await browser2.page.goto("https://www.google.com");
69
- // // sleep for 2 seconds
70
- // await new Promise((r) => setTimeout(r, 1000));
71
- // await browserManager.closeAll();
72
- //# sourceMappingURL=browser_manager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"browser_manager.js","sourceRoot":"","sources":["../../src/browser_manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA6E,MAAM,YAAY,CAAC;AAOjH,MAAM,cAAc;IAClB,YAAmB,WAAsB,EAAE;QAAxB,aAAQ,GAAR,QAAQ,CAAgB;IAC3C,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,OAAO,CAAC,GAA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tD,yBAAyB;AACzB,iDAAiD;AACjD,mCAAmC"}
@@ -1,23 +0,0 @@
1
- type Cookie = {
2
- name: string;
3
- value: string;
4
- domain?: string;
5
- path?: string;
6
- expires?: number;
7
- httpOnly?: boolean;
8
- secure?: boolean;
9
- sameSite?: string;
10
- };
11
- type LocalStorage = Record<string, string>;
12
- declare class Environment {
13
- baseUrl?: string | undefined;
14
- cookies: Cookie[];
15
- origins: {
16
- origin: string;
17
- localStorage: LocalStorage;
18
- }[];
19
- constructor(baseUrl?: string | undefined);
20
- setBaseUrl(url: string): void;
21
- }
22
- export { Environment };
23
- export type { Cookie, LocalStorage };
@@ -1,12 +0,0 @@
1
- class Environment {
2
- constructor(baseUrl) {
3
- this.baseUrl = baseUrl;
4
- this.cookies = [];
5
- this.origins = [];
6
- }
7
- setBaseUrl(url) {
8
- this.baseUrl = url;
9
- }
10
- }
11
- export { Environment };
12
- //# sourceMappingURL=environment.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/environment.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW;IAGf,YAAmB,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;QAFnC,YAAO,GAAY,EAAE,CAAA;QACrB,YAAO,GAAgD,EAAE,CAAA;IAEzD,CAAC;IACD,UAAU,CAAC,GAAW;QACpB,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;IACrB,CAAC;CACF;AACD,OAAO,EAAE,WAAW,EAAE,CAAC"}
package/lib/index.js DELETED
@@ -1,7 +0,0 @@
1
- export * from "./auto_page.js";
2
- export * from "./init_browser.js";
3
- export * from "./stable_browser.js";
4
- export * from "./environment.js";
5
- export * from "./auto_page.js";
6
- export * from "./browser_manager.js";
7
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC"}
@@ -1,7 +0,0 @@
1
- import { Environment } from "./environment.js";
2
- import { TestContext } from "./test_context.js";
3
- import { Browser as PlaywrightBrowser } from "playwright";
4
- import { Browser } from "./browser_manager.js";
5
- declare const getContext: (environment: Environment | null, headless?: boolean, logger?: null) => Promise<TestContext>;
6
- declare const closeBrowser: (browser?: Browser | PlaywrightBrowser) => Promise<void>;
7
- export { getContext, closeBrowser };
@@ -1,59 +0,0 @@
1
- import fs from "node:fs";
2
- import { Environment } from "./environment.js";
3
- import { browserManager } from "./browser_manager.js";
4
- import { TestContext } from "./test_context.js";
5
- import { StableBrowser } from "./stable_browser.js";
6
- // let environment = null;
7
- // init browser create context and page, if context and page are not null
8
- const getContext = async function (environment, headless = false, logger) {
9
- if (environment === null) {
10
- environment = initEnvironment();
11
- }
12
- const { cookies, origins } = environment;
13
- const storageState = { cookies, origins };
14
- let browser = await browserManager.getBrowser(headless, storageState);
15
- let context = new TestContext();
16
- context.browser = browser.browser;
17
- context.playContext = browser.context;
18
- context.page = browser.page;
19
- context.environment = environment;
20
- context.stable = new StableBrowser(context.browser, context.page, logger);
21
- // await _initCookies(context);
22
- return context;
23
- };
24
- // const _initCookies = async function (context) {
25
- // if (context.environment.cookies) {
26
- // const cookies = [];
27
- // for (let i = 0; i < context.environment.cookies.length; i++) {
28
- // const cookie = context.environment.cookies[i];
29
- // if (cookie.expires && cookie.expires == "undefined") {
30
- // delete cookie.expires;
31
- // }
32
- // cookies.push(cookie);
33
- // }
34
- // await context.playContext.addCookies(cookies);
35
- // }
36
- // };
37
- const closeBrowser = async function (browser) {
38
- await browserManager.closeBrowser(browser);
39
- };
40
- const initEnvironment = function () {
41
- // if (environment === null) {
42
- const environment = new Environment();
43
- try {
44
- const data = fs.readFileSync("env.json", "utf8");
45
- //console.log("data", data);
46
- const envObject = JSON.parse(data);
47
- //console.log("envObject", envObject);
48
- Object.assign(environment, envObject);
49
- //console.log("env", environment);
50
- console.log("Base url: " + environment.baseUrl);
51
- }
52
- catch (err) {
53
- console.error("Error reading env.json", err);
54
- }
55
- // }
56
- return environment;
57
- };
58
- export { getContext, closeBrowser };
59
- //# sourceMappingURL=init_browser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"init_browser.js","sourceRoot":"","sources":["../../src/init_browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD,0BAA0B;AAE1B,yEAAyE;AACzE,MAAM,UAAU,GAAG,KAAK,WAAW,WAA6B,EAAE,QAAQ,GAAG,KAAK,EAAE,MAAa;IAC/F,IAAI,WAAW,KAAK,IAAI,EAAE;QACxB,WAAW,GAAG,eAAe,EAAE,CAAC;KACjC;IACD,MAAM,EAAC,OAAO,EAAE,OAAO,EAAC,GAAG,WAAW,CAAC;IACvC,MAAM,YAAY,GAAG,EAAC,OAAO,EAAE,OAAO,EAAC,CAAC;IACxC,IAAI,OAAO,GAAG,MAAM,cAAc,CAAC,UAAU,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IACtE,IAAI,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAChC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAClC,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IACtC,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC5B,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC;IAElC,OAAO,CAAC,MAAM,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,OAAQ,EAAE,OAAO,CAAC,IAAK,EAAE,MAAM,CAAC,CAAC;IAC5E,+BAA+B;IAC/B,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AACF,kDAAkD;AAClD,uCAAuC;AACvC,0BAA0B;AAC1B,qEAAqE;AACrE,uDAAuD;AACvD,+DAA+D;AAC/D,iCAAiC;AACjC,UAAU;AACV,8BAA8B;AAC9B,QAAQ;AACR,qDAAqD;AACrD,MAAM;AACN,KAAK;AAEL,MAAM,YAAY,GAAG,KAAK,WAAW,OAAmC;IACtE,MAAM,cAAc,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG;IACtB,8BAA8B;IAC5B,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;IACtC,IAAI;QACF,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACjD,4BAA4B;QAC5B,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACnC,sCAAsC;QACtC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QACtC,kCAAkC;QAClC,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;KACjD;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAC;KAC9C;IACH,IAAI;IACJ,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC"}
package/lib/locator.d.ts DELETED
@@ -1,15 +0,0 @@
1
- declare function processTableQuery(table: Element, query: string): {
2
- cells: any[];
3
- error?: undefined;
4
- rect?: undefined;
5
- } | {
6
- error: string;
7
- cells?: undefined;
8
- rect?: undefined;
9
- } | {
10
- cells: any[];
11
- rect: DOMRect | null;
12
- error?: undefined;
13
- };
14
- type TprocessTableQuery = typeof processTableQuery;
15
- export type { TprocessTableQuery };