transit-core-taf 1.0.2 → 1.0.3

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.
@@ -1,92 +1,78 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const cucumber_1 = require("@cucumber/cucumber");
4
- const basepageactions_1 = require("../base/basepageactions");
5
4
  (0, cucumber_1.When)('I click the element {string}', async function (selector) {
6
- if (!this.page)
7
- throw new Error('Page not found');
8
- const basePageActions = new basepageactions_1.BasePageActions(this.page, this.logger);
5
+ if (!this.page || !this.basePageActions)
6
+ throw new Error('Page or basePageActions not found');
9
7
  const element = this.page.locator(selector);
10
- await basePageActions.clickElement(element);
8
+ await this.basePageActions.clickElement(element);
11
9
  });
12
10
  (0, cucumber_1.When)('I click the locator {string}', async function (selector) {
13
- if (!this.page)
14
- throw new Error('Page not found');
15
- const basePageActions = new basepageactions_1.BasePageActions(this.page, this.logger);
11
+ if (!this.page || !this.basePageActions)
12
+ throw new Error('Page or basePageActions not found');
16
13
  const element = this.page.locator(selector);
17
- await basePageActions.clickByLocator(element);
14
+ await this.basePageActions.clickByLocator(element);
18
15
  });
19
16
  (0, cucumber_1.When)('I click the button with text {string}', async function (buttonText) {
20
- if (!this.page)
21
- throw new Error('Page not found');
22
- const basePageActions = new basepageactions_1.BasePageActions(this.page, this.logger);
23
- await basePageActions.clickButtonByText(buttonText);
17
+ if (!this.page || !this.basePageActions)
18
+ throw new Error('Page or basePageActions not found');
19
+ await this.basePageActions.clickButtonByText(buttonText);
24
20
  });
25
21
  (0, cucumber_1.When)('I click the element with ID {string}', async function (id) {
26
- if (!this.page)
27
- throw new Error('Page not found');
28
- const basePageActions = new basepageactions_1.BasePageActions(this.page, this.logger);
29
- await basePageActions.clickById(id);
22
+ if (!this.page || !this.basePageActions)
23
+ throw new Error('Page or basePageActions not found');
24
+ await this.basePageActions.clickById(id);
30
25
  });
31
26
  (0, cucumber_1.When)('I fill the input {string} with {string}', async function (selector, value) {
32
- if (!this.page)
33
- throw new Error('Page not found');
34
- const basePageActions = new basepageactions_1.BasePageActions(this.page, this.logger);
27
+ if (!this.page || !this.basePageActions)
28
+ throw new Error('Page or basePageActions not found');
35
29
  const element = this.page.locator(selector);
36
- await basePageActions.fillInput(element, value);
30
+ await this.basePageActions.fillInput(element, value);
37
31
  });
38
32
  (0, cucumber_1.When)('I clear the input {string}', async function (selector) {
39
- if (!this.page)
40
- throw new Error('Page not found');
41
- const basePageActions = new basepageactions_1.BasePageActions(this.page, this.logger);
33
+ if (!this.page || !this.basePageActions)
34
+ throw new Error('Page or basePageActions not found');
42
35
  const element = this.page.locator(selector);
43
- await basePageActions.clearInput(element);
36
+ await this.basePageActions.clearInput(element);
44
37
  });
45
38
  (0, cucumber_1.When)('I type {string} into {string} slowly', async function (text, selector) {
46
- if (!this.page)
47
- throw new Error('Page not found');
48
- const basePageActions = new basepageactions_1.BasePageActions(this.page, this.logger);
39
+ if (!this.page || !this.basePageActions)
40
+ throw new Error('Page or basePageActions not found');
49
41
  const element = this.page.locator(selector);
50
- await basePageActions.typeSlowly(element, text);
42
+ await this.basePageActions.typeSlowly(element, text);
51
43
  });
52
44
  (0, cucumber_1.When)('I hover over the element {string}', async function (selector) {
53
- if (!this.page)
54
- throw new Error('Page not found');
55
- const basePageActions = new basepageactions_1.BasePageActions(this.page, this.logger);
45
+ if (!this.page || !this.basePageActions)
46
+ throw new Error('Page or basePageActions not found');
56
47
  const element = this.page.locator(selector);
57
- await basePageActions.hoverOverElement(element);
48
+ await this.basePageActions.hoverOverElement(element);
58
49
  });
59
50
  (0, cucumber_1.When)('I press the {string} key on {string}', async function (key, selector) {
60
- if (!this.page)
61
- throw new Error('Page not found');
62
- const basePageActions = new basepageactions_1.BasePageActions(this.page, this.logger);
51
+ if (!this.page || !this.basePageActions)
52
+ throw new Error('Page or basePageActions not found');
63
53
  const element = this.page.locator(selector);
64
- await basePageActions.pressKey(element, key);
54
+ await this.basePageActions.pressKey(element, key);
65
55
  });
66
56
  (0, cucumber_1.When)('I check the checkbox {string}', async function (selector) {
67
- if (!this.page)
68
- throw new Error('Page not found');
69
- const basePageActions = new basepageactions_1.BasePageActions(this.page, this.logger);
57
+ if (!this.page || !this.basePageActions)
58
+ throw new Error('Page or basePageActions not found');
70
59
  const element = this.page.locator(selector);
71
- await basePageActions.checkCheckbox(element);
60
+ await this.basePageActions.checkCheckbox(element);
72
61
  });
73
62
  (0, cucumber_1.When)('I uncheck the checkbox {string}', async function (selector) {
74
- if (!this.page)
75
- throw new Error('Page not found');
76
- const basePageActions = new basepageactions_1.BasePageActions(this.page, this.logger);
63
+ if (!this.page || !this.basePageActions)
64
+ throw new Error('Page or basePageActions not found');
77
65
  const element = this.page.locator(selector);
78
- await basePageActions.uncheckCheckbox(element);
66
+ await this.basePageActions.uncheckCheckbox(element);
79
67
  });
80
68
  (0, cucumber_1.When)('I select the option {string} from {string}', async function (value, selector) {
81
- if (!this.page)
82
- throw new Error('Page not found');
83
- const basePageActions = new basepageactions_1.BasePageActions(this.page, this.logger);
69
+ if (!this.page || !this.basePageActions)
70
+ throw new Error('Page or basePageActions not found');
84
71
  const element = this.page.locator(selector);
85
- await basePageActions.selectOption(element, value);
72
+ await this.basePageActions.selectOption(element, value);
86
73
  });
87
74
  (0, cucumber_1.When)('I reload the page', async function () {
88
- if (!this.page)
89
- throw new Error('Page not found');
90
- const basePageActions = new basepageactions_1.BasePageActions(this.page, this.logger);
91
- await basePageActions.reloadPage();
75
+ if (!this.page || !this.basePageActions)
76
+ throw new Error('Page or basePageActions not found');
77
+ await this.basePageActions.reloadPage();
92
78
  });
@@ -1,11 +1,13 @@
1
1
  import { IWorldOptions, World } from '@cucumber/cucumber';
2
2
  import { Page, Browser, BrowserContext } from '@playwright/test';
3
+ import { BasePageActions } from '../base/basepageactions';
3
4
  import { Logger } from '../base/logger';
4
5
  export declare class CustomWorld extends World {
5
6
  browser: Browser | null;
6
7
  context: BrowserContext | null;
7
8
  page: Page | null;
8
9
  logger: Logger;
10
+ basePageActions: BasePageActions | null;
9
11
  constructor(options: IWorldOptions);
10
12
  openBrowser(): Promise<void>;
11
13
  closeBrowser(): Promise<void>;
@@ -3,23 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CustomWorld = void 0;
4
4
  const cucumber_1 = require("@cucumber/cucumber");
5
5
  const test_1 = require("@playwright/test");
6
+ const basepageactions_1 = require("../base/basepageactions");
6
7
  const logger_1 = require("../base/logger");
7
8
  class CustomWorld extends cucumber_1.World {
8
9
  browser;
9
10
  context;
10
11
  page;
11
12
  logger;
13
+ basePageActions;
12
14
  constructor(options) {
13
15
  super(options);
14
16
  this.browser = null;
15
17
  this.context = null;
16
18
  this.page = null;
17
19
  this.logger = new logger_1.Logger('Default Test');
20
+ this.basePageActions = null;
18
21
  }
19
22
  async openBrowser() {
20
23
  this.browser = await test_1.chromium.launch({ headless: false });
21
24
  this.context = await this.browser.newContext();
22
25
  this.page = await this.context.newPage();
26
+ if (this.page) {
27
+ this.basePageActions = new basepageactions_1.BasePageActions(this.page, this.logger);
28
+ }
23
29
  }
24
30
  async closeBrowser() {
25
31
  if (this.page) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "transit-core-taf",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Transit Core Automation Framework",
5
5
  "main": "dist/transit-core-taf/index.js",
6
6
  "types": "dist/transit-core-taf/index.d.ts",