automation_model 1.0.65 → 1.0.66

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 (49) hide show
  1. package/package.json +1 -1
  2. package/.github/workflows/npm-publish.yml +0 -38
  3. package/.vscode/launch.json +0 -30
  4. package/README.md +0 -3
  5. package/ai_config.json +0 -53
  6. package/build/package.json +0 -33
  7. package/env.json +0 -3
  8. package/src/auto_page.ts +0 -58
  9. package/src/browser_manager.ts +0 -87
  10. package/src/environment.ts +0 -24
  11. package/src/index.ts +0 -6
  12. package/src/init_browser.ts +0 -65
  13. package/src/locator.ts +0 -173
  14. package/src/stable_browser.ts +0 -523
  15. package/src/table_analyze.ts +0 -69
  16. package/src/test_context.ts +0 -16
  17. package/tests/create_new_repository.test.js +0 -62
  18. package/tests/debug.test.js +0 -41
  19. package/tests/gmail_login.test.js +0 -39
  20. package/tests/launch_page.test.js +0 -32
  21. package/tests/navigate_to_new_repository_page.test.js +0 -45
  22. package/tsconfig.json +0 -110
  23. /package/{build/lib → lib}/auto_page.d.ts +0 -0
  24. /package/{build/lib → lib}/auto_page.js +0 -0
  25. /package/{build/lib → lib}/auto_page.js.map +0 -0
  26. /package/{build/lib → lib}/browser_manager.d.ts +0 -0
  27. /package/{build/lib → lib}/browser_manager.js +0 -0
  28. /package/{build/lib → lib}/browser_manager.js.map +0 -0
  29. /package/{build/lib → lib}/environment.d.ts +0 -0
  30. /package/{build/lib → lib}/environment.js +0 -0
  31. /package/{build/lib → lib}/environment.js.map +0 -0
  32. /package/{build/lib → lib}/index.d.ts +0 -0
  33. /package/{build/lib → lib}/index.js +0 -0
  34. /package/{build/lib → lib}/index.js.map +0 -0
  35. /package/{build/lib → lib}/init_browser.d.ts +0 -0
  36. /package/{build/lib → lib}/init_browser.js +0 -0
  37. /package/{build/lib → lib}/init_browser.js.map +0 -0
  38. /package/{build/lib → lib}/locator.d.ts +0 -0
  39. /package/{build/lib → lib}/locator.js +0 -0
  40. /package/{build/lib → lib}/locator.js.map +0 -0
  41. /package/{build/lib → lib}/stable_browser.d.ts +0 -0
  42. /package/{build/lib → lib}/stable_browser.js +0 -0
  43. /package/{build/lib → lib}/stable_browser.js.map +0 -0
  44. /package/{build/lib → lib}/table_analyze.d.ts +0 -0
  45. /package/{build/lib → lib}/table_analyze.js +0 -0
  46. /package/{build/lib → lib}/table_analyze.js.map +0 -0
  47. /package/{build/lib → lib}/test_context.d.ts +0 -0
  48. /package/{build/lib → lib}/test_context.js +0 -0
  49. /package/{build/lib → lib}/test_context.js.map +0 -0
@@ -1,523 +0,0 @@
1
- // @ts-nocheck
2
- import reg_parser from "regex-parser";
3
- import { expect } from "@playwright/test";
4
- import fs from "fs";
5
- import path from "path";
6
- import { getTableCells } from "./table_analyze.js";
7
- import type { Browser, Page } from "playwright";
8
- let configuration = null;
9
- type Params = Record<string, string>;
10
- class StableBrowser {
11
- constructor(public browser:Browser, public page:Page, public logger:any=null) {
12
- // this.browser = browser;
13
- // this.page = page;
14
- // this.logger = logger;
15
- if (!this.logger) {
16
- this.logger = console;
17
- }
18
- }
19
-
20
- async goto(url:string) {
21
- await this.page.goto(url, {
22
- timeout: 60000,
23
- });
24
- }
25
- _fixUsingParams(text, _params:Params) {
26
- if (!_params || typeof text !== "string") {
27
- return text;
28
- }
29
- for (let key in _params) {
30
- text = text.replaceAll(new RegExp("{" + key + "}", "g"), _params[key]);
31
- }
32
- return text;
33
- }
34
- _getLocator(locator, scope, _params:Params) {
35
- if (locator.role) {
36
- if (locator.role[1].nameReg) {
37
- locator.role[1].name = reg_parser(locator.role[1].nameReg);
38
- delete locator.role[1].nameReg;
39
- }
40
- if (locator.role[1].name) {
41
- locator.role[1].name = this._fixUsingParams(locator.role[1].name, _params);
42
- }
43
- return scope.getByRole(locator.role[0], locator.role[1]);
44
- }
45
- if (locator.css) {
46
- return scope.locator(this._fixUsingParams(locator.css, _params));
47
- }
48
- throw new Error("unknown locator type");
49
- }
50
- async _locateElementByText(scope, text1, tag1, regex = false, _params:Params) {
51
- //const stringifyText = JSON.stringify(text);
52
- return await scope.evaluate(
53
- ([text, tag]) => {
54
- function isParent(parent, child) {
55
- let currentNode = child.parentNode;
56
- while (currentNode !== null) {
57
- if (currentNode === parent) {
58
- return true;
59
- }
60
- currentNode = currentNode.parentNode;
61
- }
62
- return false;
63
- }
64
- if (!tag) {
65
- tag = "*";
66
- }
67
- let elements = Array.from(document.querySelectorAll(tag));
68
- let randomToken = null;
69
-
70
- text = text.trim();
71
- const foundElements = [];
72
- for (let i = 0; i < elements.length; i++) {
73
- const element = elements[i];
74
- if (element.innerText && element.innerText.trim() === text) {
75
- foundElements.push(element);
76
- }
77
- }
78
- let noChildElements = [];
79
- for (let i = 0; i < foundElements.length; i++) {
80
- let element = foundElements[i];
81
- let hasChild = false;
82
- for (let j = 0; j < foundElements.length; j++) {
83
- if (i === j) {
84
- continue;
85
- }
86
- if (isParent(element, foundElements[j])) {
87
- hasChild = true;
88
- break;
89
- }
90
- }
91
- if (!hasChild) {
92
- noChildElements.push(element);
93
- }
94
- }
95
- let elementCount = 0;
96
- if (noChildElements.length > 0) {
97
- for (let i = 0; i < noChildElements.length; i++) {
98
- if (randomToken === null) {
99
- randomToken = Math.random().toString(36).substring(7);
100
- }
101
- let element = noChildElements[i];
102
- element.setAttribute("data-blinq-id", "blinq-id-" + randomToken);
103
- elementCount++;
104
- }
105
- }
106
- return { elementCount: elementCount, randomToken: randomToken };
107
- },
108
- [text1, tag1]
109
- );
110
- }
111
-
112
- async _collectLocatorInformation(selectorHierarchy, index = 0, scope, foundLocators, _params:Params) {
113
- if (index === selectorHierarchy.length) {
114
- return;
115
- }
116
- if (selectorHierarchy.length !== 1) {
117
- this.logger.info("only single selector hierarchy supported, will use first selector");
118
- }
119
-
120
- let locatorSearch = selectorHierarchy[index];
121
- let locator = null;
122
- if (locatorSearch.text) {
123
- let result = await this._locateElementByText(scope, locatorSearch.text, locatorSearch.tag, false, _params);
124
- if (result.elementCount === 0) {
125
- return;
126
- }
127
- locatorSearch.css = "[data-blinq-id='blinq-id-" + result.randomToken + "']";
128
- locator = this._getLocator(locatorSearch, scope, _params);
129
- } else {
130
- locator = this._getLocator(locatorSearch, scope, _params);
131
- }
132
-
133
- let count = await locator.count();
134
- //let visibleCount = 0;
135
- let visibleLocator = null;
136
- for (let j = 0; j < count; j++) {
137
- if ((await locator.nth(j).isVisible()) && (await locator.nth(j).isEnabled())) {
138
- //visibleCount++;
139
- // if (index === selectorHierarchy.length - 1) {
140
- foundLocators.push(locator.nth(j));
141
- // } else {
142
- // this._collectLocatorInformation(selectorHierarchy, index + 1, locator.nth(j), foundLocators);
143
- // }
144
- }
145
- }
146
- }
147
- async _locate(selectors, info, _params?:Params, timeout = 30000) {
148
- let locatorsByPriority = [];
149
- let startTime = performance.now();
150
- let locatorsCount = 0;
151
- while (true) {
152
- locatorsCount = 0;
153
- for (let i = 0; i < selectors.length; i++) {
154
- let selectorList = selectors[i];
155
-
156
- let foundLocators = [];
157
- try {
158
- await this._collectLocatorInformation(selectorList, 0, this.page, foundLocators, _params);
159
- } catch (e) {
160
- foundLocators = [];
161
- await this._collectLocatorInformation(selectorList, 0, this.page, foundLocators, _params);
162
- }
163
-
164
- info.log.push("total elements found " + foundLocators.length);
165
- if (foundLocators.length === 1) {
166
- info.log.push("found unique element");
167
- info.box = await foundLocators[0].boundingBox();
168
- return foundLocators[0];
169
- }
170
- locatorsByPriority.push(foundLocators);
171
- locatorsCount += foundLocators.length;
172
- }
173
- if (locatorsCount > 0) {
174
- break;
175
- }
176
- if (performance.now() - startTime > timeout) {
177
- break;
178
- }
179
- await new Promise((resolve) => setTimeout(resolve, 1000));
180
- }
181
- this.logger.debug("unable to locate unique element, total elements found " + locatorsCount);
182
- info.log.push("failed to locate unique element, total elements found " + locatorsCount);
183
- for (let i = 0; i < locatorsByPriority.length; i++) {
184
- let locators = locatorsByPriority[i];
185
- if (locators.length > 0) {
186
- info.box = await locators[0].boundingBox();
187
- return locators[0];
188
- }
189
- }
190
- throw new Error("failed to locate first element no elements found, " + JSON.stringify(info));
191
- }
192
-
193
- async click(selector, _params?:Params, options = {}, world = null) {
194
- const info = {};
195
- info.log = [];
196
- info.operation = "click";
197
- info.selector = selector;
198
- this._reportToWorld(world, { command: "click", params: _params, selector: selector });
199
- try {
200
- let element = await this._locate(selector, info, _params);
201
-
202
- await this._screenShot(options, world);
203
- try {
204
- await element.click({ timeout: 5000 });
205
- } catch (e) {
206
- info.log.push("click failed, will try force click");
207
- this._reportToWorld(world, { message: "click failed, will try force click" });
208
- await element.click({ timeout: 10000, force: true });
209
- }
210
- this._reportToWorld(world, { result: "success", info: info });
211
- await this.waitForPageLoad();
212
- return info;
213
- } catch (e) {
214
- this.logger.error("click failed " + JSON.stringify(info));
215
- this._reportToWorld(world, { result: "failed", info: info, error: e });
216
- Object.assign(e, { info: info });
217
- await this._screenShot(options, world);
218
- throw e;
219
- }
220
- }
221
-
222
- async selectOption(selector, values, _params = null, options = {}, world = null) {
223
- const info = {};
224
- info.log = [];
225
- info.operation = "selectOptions";
226
- info.selector = selector;
227
- this._reportToWorld(world, { command: "select", values, params: _params, selector: selector });
228
- try {
229
- let element = await this._locate(selector, info, _params);
230
-
231
- await this._screenShot(options, world);
232
- try {
233
- await element.selectOption(values, { timeout: 5000 });
234
- } catch (e) {
235
- info.log.push("selectOption failed, will try force");
236
- this._reportToWorld(world, { message: "select failed, will try force select" });
237
- await element.selectOption(values, { timeout: 10000, force: true });
238
- }
239
- await this.waitForPageLoad();
240
- return info;
241
- } catch (e) {
242
- this.logger.error("selectOption failed " + JSON.stringify(info));
243
- this._reportToWorld(world, { result: "failed", info: info, error: e });
244
- Object.assign(e, { info: info });
245
- await this._screenShot(options, world);
246
- throw e;
247
-
248
- this.logger.info("click failed, will try next selector");
249
- }
250
- }
251
-
252
- async fill(selector, value, enter = false, _params = null, options = {}, world = null) {
253
- const info = {};
254
- info.log = [];
255
- info.operation = "fill";
256
- info.selector = selector;
257
- info.value = value;
258
- this._reportToWorld(world, { command: "fill", value, enter, params: _params, selector: selector });
259
- try {
260
- let element = await this._locate(selector, info, _params);
261
- await this._screenShot(options, world);
262
- await element.fill(value, { timeout: 10000 });
263
- await element.dispatchEvent("change");
264
- if (enter) {
265
- await this.page.keyboard.press("Enter");
266
- }
267
- await this.waitForPageLoad();
268
- return info;
269
- } catch (e) {
270
- this.logger.error("fill failed " + JSON.stringify(info));
271
- this._reportToWorld(world, { result: "failed", info: info, error: e });
272
- Object.assign(e, { info: info });
273
- await this._screenShot(options, world);
274
- throw e;
275
- }
276
- }
277
-
278
- async getText(selector, _params = null, options = {}, info = {}, world = null) {
279
- if (!info.log) {
280
- info.log = [];
281
- }
282
- let element = await this._locate(selector, info, _params);
283
- await this._screenShot(options, world);
284
- try {
285
- return await element.innerText();
286
- } catch (e) {
287
- this.logger.info("no innerText will use textContent");
288
- return await element.textContent();
289
- }
290
- }
291
- async containsPattern(selector, pattern, text, _params = null, options = {}, world = null) {
292
- const info = {};
293
- info.log = [];
294
- info.operation = "containsPattern";
295
- info.selector = selector;
296
- info.value = text;
297
- info.pattern = pattern;
298
- let foundText = null;
299
- this._reportToWorld(world, { command: "contains", pattern, text, params: _params, selector: selector });
300
- try {
301
- foundText = await this.getText(selector, _params, options, info, world);
302
- let escapedText = text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
303
- pattern = pattern.replace("{text}", escapedText);
304
- let regex = new RegExp(pattern, "m");
305
- if (!regex.test(foundText)) {
306
- info.foundText = foundText;
307
- throw new Error("element doesn't contain text " + text);
308
- }
309
- return info;
310
- } catch (e) {
311
- this.logger.error("verify element contains text failed " + JSON.stringify(info));
312
- this.logger.error("found text " + foundText + " pattern " + pattern);
313
- this._reportToWorld(world, { result: "failed", info: info, error: e });
314
- Object.assign(e, { info: info });
315
- await this._screenShot(options, world);
316
- throw e;
317
- }
318
- }
319
-
320
- async containsText(selector, text, _params = null, options = {}, world = null) {
321
- const info = {};
322
- info.log = [];
323
- info.operation = "containsText";
324
- info.selector = selector;
325
- info.value = text;
326
- try {
327
- let foundText = await this.getText(selector, _params, options, info, world);
328
- if (!foundText.includes(text)) {
329
- info.foundText = foundText;
330
- throw new Error("element doesn't contain text " + text);
331
- }
332
- return info;
333
- } catch (e) {
334
- this.logger.error("verify element contains text failed " + JSON.stringify(info));
335
- this._reportToWorld(world, { result: "failed", info: info, error: e });
336
- Object.assign(e, { info: info });
337
- await this._screenShot(options, world);
338
- throw e;
339
- }
340
- }
341
- async _screenShot(options = {}, world = null) {
342
- if (world && world.attach && world.screenshot && world.screenshotPath) {
343
- if (!fs.existsSync(world.screenshotPath)) {
344
- fs.mkdirSync(world.screenshotPath, { recursive: true });
345
- }
346
- let nextIndex = 1;
347
- while (fs.existsSync(path.join(world.screenshotPath, nextIndex + ".png"))) {
348
- nextIndex++;
349
- }
350
- const screenshotPath = path.join(world.screenshotPath, nextIndex + ".png");
351
- await this.page.screenshot({ path: screenshotPath });
352
- await world.attach(JSON.stringify({ path: screenshotPath }), {
353
- mediaType: "application/json",
354
- });
355
- } else if (options.screenshot) {
356
- await this.page.screenshot({ path: options.screenshotPath });
357
- }
358
- }
359
- async verifyElementExistInPage(selector, _params = null, options = {}, world = null) {
360
- await new Promise((resolve) => setTimeout(resolve, 2000));
361
- const info = {};
362
- info.log = [];
363
- info.operation = "verify";
364
- info.selector = selector;
365
- this._reportToWorld(world, { command: "verify", params: _params, selector: selector });
366
- try {
367
- const element = await this._locate(selector, info, _params);
368
- await this._screenShot(options, world);
369
- await expect(element).toHaveCount(1, { timeout: 10000 });
370
- return info;
371
- } catch (e) {
372
- this.logger.error("verify failed " + JSON.stringify(info));
373
- this._reportToWorld(world, { result: "failed", info: info, error: e });
374
- Object.assign(e, { info: info });
375
- await this._screenShot(options, world);
376
- throw e;
377
- }
378
- }
379
- async analyzeTable(selector, query, operator, value, _params = null, options = {}, world = null) {
380
- const info = {};
381
- info.log = [];
382
- info.operation = "analyzeTable";
383
- info.selector = selector;
384
- info.query = query;
385
- query = this._fixUsingParams(query, _params);
386
- info.query_fixed = query;
387
- info.operator = operator;
388
- info.value = value;
389
- this._reportToWorld(world, {
390
- command: "analyzeTable",
391
- query,
392
- operator,
393
- value,
394
- params: _params,
395
- selector: selector,
396
- });
397
- try {
398
- let table = await this._locate(selector, info, _params);
399
- await this._screenShot(options, world);
400
- const cells = await getTableCells(this.page, table, query, info);
401
-
402
- if (cells.error) {
403
- throw new Error(cells.error);
404
- }
405
- if (operator === "===" || operator === "==" || operator === "=" || operator === "equals") {
406
- if (cells.length === 0) {
407
- throw new Error("no cells found");
408
- }
409
- for (let i = 0; i < cells.length; i++) {
410
- if (cells[i] !== value) {
411
- throw new Error("table data doesn't match");
412
- }
413
- }
414
- } else if (operator === "!==" || operator === "!=" || operator === "not_equals") {
415
- if (cells.length === 0) {
416
- throw new Error("no cells found");
417
- }
418
- for (let i = 0; i < cells.length; i++) {
419
- if (cells[i] === value) {
420
- throw new Error("table data doesn't match");
421
- }
422
- }
423
- } else if (operator === ">=" || operator === "greater_than_or_equal") {
424
- if (cells.length === 0) {
425
- throw new Error("no cells found");
426
- }
427
- value = Number(value);
428
- for (let i = 0; i < cells.length; i++) {
429
- let foundValue = Number(cells[i]);
430
-
431
- if (foundValue < value) {
432
- throw new Error(`found table cell value ${cells[i]} < ${value}`);
433
- }
434
- }
435
- } else if (operator === ">" || operator === "greater_than") {
436
- if (cells.length === 0) {
437
- throw new Error("no cells found");
438
- }
439
- value = Number(value);
440
- for (let i = 0; i < cells.length; i++) {
441
- let foundValue = Number(cells[i]);
442
- if (foundValue <= value) {
443
- throw new Error(`found table cell value ${cells[i]} <= ${value}`);
444
- }
445
- }
446
- } else if (operator === "<=" || operator === "less_than_or_equal") {
447
- if (cells.length === 0) {
448
- throw new Error("no cells found");
449
- }
450
- value = Number(value);
451
- for (let i = 0; i < cells.length; i++) {
452
- let foundValue = Number(cells[i]);
453
- if (foundValue > value) {
454
- throw new Error(`found table cell value ${cells[i]} > ${value}`);
455
- }
456
- }
457
- } else if (operator === "<" || operator === "less_than") {
458
- if (cells.length === 0) {
459
- throw new Error("no cells found");
460
- }
461
- value = Number(value);
462
- for (let i = 0; i < cells.length; i++) {
463
- let foundValue = Number(cells[i]);
464
- if (foundValue >= value) {
465
- throw new Error(`found table cell value ${cells[i]} >= ${value}`);
466
- }
467
- }
468
- } else {
469
- throw new Error("unknown operator " + operator);
470
- }
471
- return info;
472
- } catch (e) {
473
- this.logger.error("analyzeTable failed " + JSON.stringify(info));
474
- this._reportToWorld(world, { result: "failed", info: info, error: e });
475
- Object.assign(e, { info: info });
476
- await this._screenShot(options, world);
477
- throw e;
478
- }
479
- }
480
- async waitForPageLoad(options = {}, world = null) {
481
- let timeout = 10000;
482
- this._reportToWorld(world, { command: "waitForPageLoade" });
483
- if (!configuration) {
484
- try {
485
- if (fs.existsSync("ai_config.json")) {
486
- configuration = JSON.parse(fs.readFileSync("ai_config.json"));
487
- } else {
488
- configuration = {};
489
- }
490
- } catch (e) {
491
- this.logger.error("unable to read ai_config.json");
492
- }
493
- }
494
- if (configuration.page_timeout) {
495
- timeout = configuration.page_timeout;
496
- }
497
- if (options.page_timeout) {
498
- timeout = options.page_timeout;
499
- }
500
- const waitOptions = {
501
- timeout: timeout,
502
- };
503
- try {
504
- await Promise.all([
505
- this.page.waitForLoadState("networkidle", waitOptions),
506
- this.page.waitForLoadState("load", waitOptions),
507
- this.page.waitForLoadState("domcontentloaded", waitOptions),
508
- ]);
509
- } catch (e) {
510
- console.log("waitForPageLoad error, ignored");
511
- }
512
- await new Promise((resolve) => setTimeout(resolve, 2000));
513
- await this._screenShot(options, world);
514
- }
515
- _reportToWorld(world, properties = {}) {
516
- if (!world || !world.attach) {
517
- return;
518
- }
519
- world.attach(JSON.stringify(properties), { mediaType: "application/json" });
520
- }
521
- }
522
-
523
- export { StableBrowser };
@@ -1,69 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import type { Page, ElementHandle } from "playwright";
4
- // import type {TprocessTableQuery} from "./locator.js"
5
- // type Change = {css:string, changes:{role:string}};
6
- // declare const document: Document & { selectors: Change[] ; tableSelector: string; processTableQuery: TprocessTableQuery };
7
- function stringifyObject(obj:unknown, indentation = 0) {
8
- let result = "";
9
- const indent = " ".repeat(indentation);
10
- if (Array.isArray(obj)) {
11
- result += "[";
12
- for (let i = 0; i < obj.length; i++) {
13
- result += (i > 0 ? ", " : "") + stringifyObject(obj[i], indentation + 2);
14
- }
15
- result += "]";
16
- } else if (typeof obj === "object" && obj !== null) {
17
- result += "{";
18
- let first = true;
19
- for (let key in obj) {
20
- // eslint-disable-next-line no-prototype-builtins
21
- if (obj.hasOwnProperty(key)) {
22
- result +=
23
- (first ? "\n" : ",\n") +
24
- indent +
25
- " " +
26
- JSON.stringify(key) +
27
- ": " +
28
- // @ts-ignore
29
- stringifyObject(obj[key], indentation + 2);
30
- first = false;
31
- }
32
- }
33
- result += "\n" + indent + "}";
34
- } else {
35
- result += JSON.stringify(obj);
36
- }
37
- return result;
38
- }
39
- const __filename = new URL(import.meta.url).pathname;
40
- const currentDir = path.dirname(__filename);
41
- const getTableCells = async (page:Page, element:ElementHandle, tableSelector:any, info:any = {}) => {
42
- let script = fs.readFileSync(path.join(currentDir, "locator.js"), "utf8");
43
- let aiConfigPath = path.join(process.cwd(), "ai_config.json");
44
- if (fs.existsSync(aiConfigPath)) {
45
- let aiConfig = JSON.parse(fs.readFileSync(aiConfigPath, "utf8"));
46
- if (aiConfig.changes) {
47
- script = script.replace("const selectors = null", "const selectors = " + stringifyObject(aiConfig.changes));
48
- }
49
- }
50
- script = script.replace("const tableSelector = null", "const tableSelector = " + stringifyObject(tableSelector));
51
- await page.evaluate(script);
52
- try {
53
- // @ts-ignore
54
- let result = await element.evaluate((_node) => {
55
- // @ts-ignore
56
- console.log("tableSelector", document.tableSelector);
57
- // @ts-ignore
58
- return document.processTableQuery(_node as Element, document.tableSelector);
59
- });
60
- // @ts-ignore
61
- info.box = result.rect;
62
- return result.cells;
63
- } catch (error) {
64
- console.log("error", error);
65
- throw error;
66
- }
67
- };
68
-
69
- export { getTableCells };
@@ -1,16 +0,0 @@
1
- import { BrowserContext, Page, Browser as PlaywrightBrowser } from "playwright";
2
- import { Environment } from "./environment.js";
3
- import { StableBrowser } from "./stable_browser.js";
4
-
5
- class TestContext {
6
- stable: StableBrowser|null = null
7
- browser: PlaywrightBrowser|null = null
8
- playContext: BrowserContext | null = null
9
- page: Page | null = null
10
- environment: Environment|null = null
11
- reportFolder: string|null = null
12
- constructor(
13
- ) {
14
- }
15
- }
16
- export { TestContext };
@@ -1,62 +0,0 @@
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
- textbox_repositoryname: [
31
- [{ role: ["textbox", { name: "Repository name" }] }],
32
- [
33
- {
34
- css: "input[name='repository[name]']",
35
- },
36
- ],
37
- ],
38
- button_create: [
39
- [{ role: ["button", { name: "Create repository" }] }],
40
- [
41
- {
42
- css: "button[type='submit']",
43
- },
44
- ],
45
- ],
46
- };
47
- const context = await initContext(path, true, false);
48
- const loginAndCreateRepo = async function () {
49
- let info = null;
50
- await context.stable.fill(elements.textbox_username, "username");
51
- await context.stable.fill(elements.textbox_password, "password");
52
- info = await context.stable.click(elements.button_signin);
53
- await context.stable.waitForPageLoad();
54
-
55
- await context.stable.fill(elements.textbox_repositoryname, "new-repo");
56
- info = await context.stable.click(elements.button_create);
57
- await context.stable.waitForPageLoad();
58
- };
59
- await loginAndCreateRepo();
60
-
61
- await new Promise((resolve) => setTimeout(resolve, 1000));
62
- await closeBrowser();