@cuppet/core 1.0.0 → 1.0.2

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,95 +1,95 @@
1
- const { BeforeAll, AfterAll, Before, After, AfterStep, Status } = require('@cucumber/cucumber');
2
- const BrowserManager = require('./browserManager');
3
- const AppiumManager = require('./appiumManager');
4
- const fs = require('fs');
5
- const config = require('config');
6
- const dataStore = require('../../src/dataStorage');
7
- const profile = process.env.NODE_CONFIG_ENV;
8
-
9
- let screenshotPath = config.get('screenshotsPath').toString() ?? 'screenshots/';
10
-
11
- // ==== BeforeAll and AfterAll do not have access to test scope 'this'
12
- // ==== Before and After do
13
-
14
- // executed once before any test
15
- BeforeAll(async function () {
16
- await dataStore.createFile();
17
- console.log(`Tests started at: ${new Date()}`);
18
- });
19
-
20
- AfterStep(async function (testCase) {
21
- /**
22
- * If the test is not passed or the test is not tagged with @api, take a screenshot
23
- */
24
- const arrayTags = testCase.pickle.tags;
25
- const found = arrayTags.find((item) => item.name === '@api');
26
- if (testCase.result.status !== Status.PASSED && found === undefined) {
27
- let stepName = testCase.pickle.uri;
28
- const name = stepName.replace(/[/\\.]/g, '_');
29
- const baseScreenshotPath = `${screenshotPath}${profile}`;
30
- if (!fs.existsSync(baseScreenshotPath)) {
31
- fs.mkdirSync(baseScreenshotPath, { recursive: true });
32
- }
33
- let path = `${baseScreenshotPath}/screenshot_${name}.png`;
34
- let screenshot = await this.page.screenshot({ path: path, fullPage: true });
35
- console.log(`Screenshot taken: ${name}`);
36
- // Convert Uint8Array to Buffer because Cucumber cannot work directly with Uint8Arrays
37
- const buffer = Buffer.from(screenshot.buffer, screenshot.byteOffset, screenshot.byteLength);
38
- this.attach(buffer, 'image/png');
39
- }
40
- });
41
-
42
- // executed once after all tests
43
- AfterAll(async function () {
44
- const date = new Date();
45
- console.log(`Tests completed at: ${date.toString()}`);
46
- });
47
-
48
- // executed before every test
49
- Before(async function (testCase) {
50
- // Get Browser config arguments array
51
- const browserArgs = config.get('browserOptions.args');
52
- // Get default browser viewport
53
- const browserViewport = config.get('browserOptions.viewport.default');
54
- // Check for basic auth credentials in config
55
- let credentials;
56
- if (config.has('basicAuth')) {
57
- credentials = {
58
- username: config.get('basicAuth.authUser').toString(),
59
- password: config.get('basicAuth.authPass').toString(),
60
- };
61
- }
62
- // Get Appium capabilities from config
63
- const appiumCapabilities = config.get('appiumCapabilities');
64
-
65
- // Check if the test is tagged with @appium to either use Appium or Chromium
66
- const arrayTags = testCase.pickle.tags;
67
- const found = arrayTags.find((item) => item.name === '@appium');
68
- if (!found) {
69
- const browserManager = new BrowserManager(browserViewport, browserArgs, credentials);
70
- await browserManager.initialize();
71
-
72
- // Assign created browser, page, and scenario name to global variables
73
- this.browserManager = browserManager;
74
- this.browser = browserManager.browser;
75
- this.page = browserManager.page;
76
- this.scenarioName = testCase.pickle.name;
77
- } else {
78
- const appiumManager = new AppiumManager(appiumCapabilities);
79
- await appiumManager.initialize();
80
- this.appiumManager = appiumManager;
81
- this.appiumDriver = appiumManager.appiumDriver;
82
- }
83
- });
84
-
85
- // executed after every test
86
- After(async function (testCase) {
87
- if (testCase.result.status === Status.FAILED) {
88
- console.log(`Scenario: '${testCase.pickle.name}' - has failed...\r\n`);
89
- }
90
- if (this.browser) {
91
- await this.browserManager.stop();
92
- } else if (this.appiumDriver) {
93
- await this.appiumManager.stop();
94
- }
95
- });
1
+ const { BeforeAll, AfterAll, Before, After, AfterStep, Status } = require('@cucumber/cucumber');
2
+ const BrowserManager = require('./browserManager');
3
+ const AppiumManager = require('./appiumManager');
4
+ const fs = require('fs');
5
+ const config = require('config');
6
+ const dataStore = require('../../src/dataStorage');
7
+ const profile = process.env.NODE_CONFIG_ENV;
8
+
9
+ let screenshotPath = config.get('screenshotsPath').toString() ?? 'screenshots/';
10
+
11
+ // ==== BeforeAll and AfterAll do not have access to test scope 'this'
12
+ // ==== Before and After do
13
+
14
+ // executed once before any test
15
+ BeforeAll(async function () {
16
+ await dataStore.createFile();
17
+ console.log(`Tests started at: ${new Date()}`);
18
+ });
19
+
20
+ AfterStep(async function (testCase) {
21
+ /**
22
+ * If the test is not passed or the test is not tagged with @api, take a screenshot
23
+ */
24
+ const arrayTags = testCase.pickle.tags;
25
+ const found = arrayTags.find((item) => item.name === '@api');
26
+ if (testCase.result.status !== Status.PASSED && found === undefined) {
27
+ let stepName = testCase.pickle.uri;
28
+ const name = stepName.replace(/[/\\.]/g, '_');
29
+ const baseScreenshotPath = `${screenshotPath}${profile}`;
30
+ if (!fs.existsSync(baseScreenshotPath)) {
31
+ fs.mkdirSync(baseScreenshotPath, { recursive: true });
32
+ }
33
+ let path = `${baseScreenshotPath}/screenshot_${name}.png`;
34
+ let screenshot = await this.page.screenshot({ path: path, fullPage: true });
35
+ console.log(`Screenshot taken: ${name}`);
36
+ // Convert Uint8Array to Buffer because Cucumber cannot work directly with Uint8Arrays
37
+ const buffer = Buffer.from(screenshot.buffer, screenshot.byteOffset, screenshot.byteLength);
38
+ this.attach(buffer, 'image/png');
39
+ }
40
+ });
41
+
42
+ // executed once after all tests
43
+ AfterAll(async function () {
44
+ const date = new Date();
45
+ console.log(`Tests completed at: ${date.toString()}`);
46
+ });
47
+
48
+ // executed before every test
49
+ Before(async function (testCase) {
50
+ // Get Browser config arguments array
51
+ const browserArgs = config.get('browserOptions.args');
52
+ // Get default browser viewport
53
+ const browserViewport = config.get('browserOptions.viewport.default');
54
+ // Check for basic auth credentials in config
55
+ let credentials;
56
+ if (config.has('basicAuth')) {
57
+ credentials = {
58
+ username: config.get('basicAuth.authUser').toString(),
59
+ password: config.get('basicAuth.authPass').toString(),
60
+ };
61
+ }
62
+ // Get Appium capabilities from config
63
+ const appiumCapabilities = config.get('appiumCapabilities');
64
+
65
+ // Check if the test is tagged with @appium to either use Appium or Chromium
66
+ const arrayTags = testCase.pickle.tags;
67
+ const found = arrayTags.find((item) => item.name === '@appium');
68
+ if (!found) {
69
+ const browserManager = new BrowserManager(browserViewport, browserArgs, credentials);
70
+ await browserManager.initialize();
71
+
72
+ // Assign created browser, page, and scenario name to global variables
73
+ this.browserManager = browserManager;
74
+ this.browser = browserManager.browser;
75
+ this.page = browserManager.page;
76
+ this.scenarioName = testCase.pickle.name;
77
+ } else {
78
+ const appiumManager = new AppiumManager(appiumCapabilities);
79
+ await appiumManager.initialize();
80
+ this.appiumManager = appiumManager;
81
+ this.appiumDriver = appiumManager.appiumDriver;
82
+ }
83
+ });
84
+
85
+ // executed after every test
86
+ After(async function (testCase) {
87
+ if (testCase.result.status === Status.FAILED) {
88
+ console.log(`Scenario: '${testCase.pickle.name}' - has failed...\r\n`);
89
+ }
90
+ if (this.browser) {
91
+ await this.browserManager.stop();
92
+ } else if (this.appiumDriver) {
93
+ await this.appiumManager.stop();
94
+ }
95
+ });
@@ -0,0 +1,20 @@
1
+ module.exports = {
2
+ multilingualStrings: function (lang) {
3
+ const translations = {
4
+ de: {
5
+ Submit: 'Einreichen',
6
+ Delete: 'Löschen',
7
+ Run: 'Laufen',
8
+ everywhere: 'nachgesehen',
9
+ },
10
+ da: {
11
+ 'advanced search': 'avanceret søgning',
12
+ },
13
+ sv: {
14
+ 'advanced search': 'avancerat sök',
15
+ },
16
+ };
17
+ // Return all translations for the given language, or undefined if not found
18
+ return translations[lang];
19
+ },
20
+ };
@@ -1,17 +1,17 @@
1
- /**
2
- * @type {string}
3
- * @name scenarioName - name of the scenario from the Before hook
4
- */
5
- const { Given, When } = require('@cucumber/cucumber');
6
- const accessibilitySteps = require('../../../src/accessibilityTesting');
7
- const dataStorage = require('../../../src/dataStorage');
8
- const main = require('../../../src/mainFunctions');
9
-
10
- Given('I validate the saved page accessibility', async function () {
11
- const path = await dataStorage.getVariable('path');
12
- await accessibilitySteps.validatePageAccessibility(this.browser, this.page, this.scenarioName, path);
13
- });
14
- When('I validate the accessibility of the {string} page', async function (path) {
15
- const preparedPath = main.prepareUrl(path);
16
- await accessibilitySteps.validatePageAccessibility(this.browser, this.page, this.scenarioName, preparedPath);
17
- });
1
+ /**
2
+ * @type {string}
3
+ * @name scenarioName - name of the scenario from the Before hook
4
+ */
5
+ const { Given, When } = require('@cucumber/cucumber');
6
+ const accessibilitySteps = require('../../../src/accessibilityTesting');
7
+ const dataStorage = require('../../../src/dataStorage');
8
+ const main = require('../../../src/mainFunctions');
9
+
10
+ Given('I validate the saved page accessibility', async function () {
11
+ const path = await dataStorage.getVariable('path');
12
+ await accessibilitySteps.validatePageAccessibility(this.browser, this.page, this.scenarioName, path);
13
+ });
14
+ When('I validate the accessibility of the {string} page', async function (path) {
15
+ const preparedPath = main.prepareUrl(path);
16
+ await accessibilitySteps.validatePageAccessibility(this.browser, this.page, this.scenarioName, preparedPath);
17
+ });
@@ -1,52 +1,52 @@
1
- const { Given, When, Then } = require('@cucumber/cucumber');
2
- const apiSteps = require('../../../src/apiFunctions');
3
- const main = require('../../../src/mainFunctions');
4
- const dataStorage = require('../../../src/dataStorage');
5
-
6
- Given('that I send a {string} request to {string}', async function (method, path) {
7
- await apiSteps.sendRequest(method, path);
8
- });
9
- When(
10
- 'I send a {string} request to {string} with http header {string} and value {string}',
11
- async function (method, path, headerName, headerValue) {
12
- const name = await dataStorage.checkForSavedVariable(headerName);
13
- const value = await dataStorage.checkForSavedVariable(headerValue);
14
- const headers = {};
15
- headers[name] = value;
16
- await apiSteps.sendRequest(method, path, headers);
17
- }
18
- );
19
- Given('the response code should be {string}', async function (code) {
20
- await apiSteps.validateResponseCode(code);
21
- });
22
- Then('the response should be an {string}', async function (type) {
23
- await apiSteps.validateResponseType(type);
24
- });
25
- Then('the property {string} should be an {string}', async function (property, type) {
26
- await apiSteps.propertyIs(property, type);
27
- });
28
- Then('the response should have property {string} with value {string}', async function (property, value) {
29
- await apiSteps.propertyHasValue(property, value);
30
- });
31
- When('I store {string} to {string} variable', async function (property, variable) {
32
- await apiSteps.iRememberVariable(property, variable);
33
- });
34
- Given('that I have request body', async function (docString) {
35
- const body = JSON.stringify(docString);
36
- await apiSteps.prepareRequestBody(body);
37
- });
38
- Given(
39
- 'I put {string} to {string} property of {string} element in the body',
40
- async function (value, property, parentObj) {
41
- await apiSteps.iPutValuesInRequestBody(value, property, parentObj);
42
- }
43
- );
44
-
45
- Given('I create json object from {string} file', async function (filePath) {
46
- const checkedPath = await dataStorage.checkForSavedVariable(filePath);
47
- await apiSteps.createRequestBodyFromFile(checkedPath);
48
- });
49
- Given('I validate that the page is a valid XML', async function () {
50
- const currentPath = main.extractPath(this.page, true);
51
- await apiSteps.validateXMLEndpoint(currentPath);
52
- });
1
+ const { Given, When, Then } = require('@cucumber/cucumber');
2
+ const apiSteps = require('../../../src/apiFunctions');
3
+ const main = require('../../../src/mainFunctions');
4
+ const dataStorage = require('../../../src/dataStorage');
5
+
6
+ Given('that I send a {string} request to {string}', async function (method, path) {
7
+ await apiSteps.sendRequest(method, path);
8
+ });
9
+ When(
10
+ 'I send a {string} request to {string} with http header {string} and value {string}',
11
+ async function (method, path, headerName, headerValue) {
12
+ const name = await dataStorage.checkForSavedVariable(headerName);
13
+ const value = await dataStorage.checkForSavedVariable(headerValue);
14
+ const headers = {};
15
+ headers[name] = value;
16
+ await apiSteps.sendRequest(method, path, headers);
17
+ }
18
+ );
19
+ Given('the response code should be {string}', async function (code) {
20
+ await apiSteps.validateResponseCode(code);
21
+ });
22
+ Then('the response should be an {string}', async function (type) {
23
+ await apiSteps.validateResponseType(type);
24
+ });
25
+ Then('the property {string} should be an {string}', async function (property, type) {
26
+ await apiSteps.propertyIs(property, type);
27
+ });
28
+ Then('the response should have property {string} with value {string}', async function (property, value) {
29
+ await apiSteps.propertyHasValue(property, value);
30
+ });
31
+ When('I store {string} to {string} variable', async function (property, variable) {
32
+ await apiSteps.iRememberVariable(property, variable);
33
+ });
34
+ Given('that I have request body', async function (docString) {
35
+ const body = JSON.stringify(docString);
36
+ await apiSteps.prepareRequestBody(body);
37
+ });
38
+ Given(
39
+ 'I put {string} to {string} property of {string} element in the body',
40
+ async function (value, property, parentObj) {
41
+ await apiSteps.iPutValuesInRequestBody(value, property, parentObj);
42
+ }
43
+ );
44
+
45
+ Given('I create json object from {string} file', async function (filePath) {
46
+ const checkedPath = await dataStorage.checkForSavedVariable(filePath);
47
+ await apiSteps.createRequestBodyFromFile(checkedPath);
48
+ });
49
+ Given('I validate that the page is a valid XML', async function () {
50
+ const currentPath = main.extractPath(this.page, true);
51
+ await apiSteps.validateXMLEndpoint(currentPath);
52
+ });
@@ -45,7 +45,8 @@ Given('I log in as {string} {string}', async function (username, password) {
45
45
  await navigationPromise;
46
46
  });
47
47
  Given('I follow {string}', async function (text) {
48
- await utils.followLink(this.page, text);
48
+ const resolvedText = this.mlStrings[text] ?? text;
49
+ await utils.followLink(this.page, resolvedText);
49
50
  });
50
51
  Given('I reload the page', async function () {
51
52
  await main.reloadPage(this.page);
@@ -89,7 +90,8 @@ Given('I set viewport size to {string}', async function (resolution) {
89
90
  });
90
91
  Then('I {string} the alert dialog with text {string}', async function (action, expectedText) {
91
92
  const accept = action.toLowerCase() === 'accept' ? true : false;
92
- await main.handleAlert(this.page, accept, expectedText);
93
+ const resolvedText = this.mlStrings ? this.mlStrings[expectedText] : expectedText;
94
+ await main.handleAlert(this.page, accept, resolvedText);
93
95
  });
94
96
 
95
97
  Then('I {string} the alert dialog', async function (action) {
@@ -6,7 +6,8 @@ Then('I should see {string} if visible', async function (text) {
6
6
  if (config.has('skipSteps') && config.get('skipSteps') === text) {
7
7
  return true;
8
8
  }
9
- await utils.seeTextByXpath(this.page, text);
9
+ const resolvedText = this.mlStrings[text] ?? text;
10
+ await utils.seeTextByXpath(this.page, resolvedText);
10
11
  });
11
12
  When('I type {string} in {string} if visible', async function (text, cssSelector) {
12
13
  const selector = this.commonFields[cssSelector] ?? cssSelector;
@@ -3,15 +3,16 @@ const utils = require('../../../src/elementInteraction');
3
3
  const dataStorage = require('../../../src/dataStorage');
4
4
 
5
5
  Then('I should see {string} in iframe {string}', async function (text, frameSelector) {
6
- const result = await dataStorage.checkForVariable(text);
6
+ const resolvedText = this.mlStrings[text] ?? text;
7
7
  let frame = await utils.getFrameBySelector(this.page, frameSelector);
8
- await utils.seeTextByXpath(frame, result);
8
+ await utils.seeTextByXpath(frame, resolvedText);
9
9
  });
10
10
  Then(
11
11
  'I wait for the text {string} to appear within {string} seconds in iframe {string}',
12
12
  async function (text, time, frameSelector) {
13
13
  let frame = await utils.getFrameBySelector(this.page, frameSelector);
14
- await utils.seeTextByXpath(frame, text, time * 1000);
14
+ const resolvedText = this.mlStrings[text] ?? text;
15
+ await utils.seeTextByXpath(frame, resolvedText, time * 1000);
15
16
  }
16
17
  );
17
18
  When('I click on element {string} in iframe with selector {string}', async function (elementSelector, frameSelector) {
@@ -20,7 +21,8 @@ When('I click on element {string} in iframe with selector {string}', async funct
20
21
  });
21
22
  When('I click on the text {string} in iframe with selector {string}', async function (text, frameSelector) {
22
23
  let frame = await utils.getFrameBySelector(this.page, frameSelector);
23
- await utils.clickByText(frame, text);
24
+ const resolvedText = this.mlStrings[text] ?? text;
25
+ await utils.clickByText(frame, resolvedText);
24
26
  });
25
27
  When(
26
28
  'I type {string} in {string} field in iframe with selector {string}',
@@ -33,7 +35,8 @@ When(
33
35
  'I click on the text {string} in iframe with selector {string} and follow the new tab',
34
36
  async function (text, frameSelector) {
35
37
  let frame = await utils.getFrameBySelector(this.page, frameSelector);
36
- this.page = await utils.clickLinkOpenNewTab(this.browser, frame, text, true);
38
+ const resolvedText = this.mlStrings[text] ?? text;
39
+ this.page = await utils.clickLinkOpenNewTab(this.browser, frame, resolvedText, true);
37
40
  }
38
41
  );
39
42
  When(
@@ -48,7 +51,8 @@ When(
48
51
  'I store the string matching the {string} pattern from the {string} text in iframe {string}',
49
52
  async function (pattern, text, frameSelector) {
50
53
  let frame = await utils.getFrameBySelector(this.page, frameSelector);
51
- await dataStorage.storeTextFromPattern(frame, pattern, text);
54
+ const resolvedText = this.mlStrings[text] ?? text;
55
+ await dataStorage.storeTextFromPattern(frame, pattern, resolvedText);
52
56
  }
53
57
  );
54
58
  Then(
@@ -1,17 +1,17 @@
1
- /**
2
- * @type {string}
3
- * @name scenarioName - name of the scenario from the Before hook
4
- */
5
- const { Given, When } = require('@cucumber/cucumber');
6
- const lighthouseMethods = require('../../../src/lighthouse');
7
- const dataStorage = require('../../../src/dataStorage');
8
- const main = require('../../../src/mainFunctions');
9
-
10
- Given('I generate lighthouse report for the saved page', async function () {
11
- const path = await dataStorage.getVariable('path');
12
- await lighthouseMethods.validatePageSpeed(this.page, path, this.scenarioName);
13
- });
14
- When('I generate lighthouse report for {string} page', async function (path) {
15
- const preparedPath = main.prepareUrl(path);
16
- await lighthouseMethods.validatePageSpeed(this.page, preparedPath, this.scenarioName);
17
- });
1
+ /**
2
+ * @type {string}
3
+ * @name scenarioName - name of the scenario from the Before hook
4
+ */
5
+ const { Given, When } = require('@cucumber/cucumber');
6
+ const lighthouseMethods = require('../../../src/lighthouse');
7
+ const dataStorage = require('../../../src/dataStorage');
8
+ const main = require('../../../src/mainFunctions');
9
+
10
+ Given('I generate lighthouse report for the saved page', async function () {
11
+ const path = await dataStorage.getVariable('path');
12
+ await lighthouseMethods.validatePageSpeed(this.page, path, this.scenarioName);
13
+ });
14
+ When('I generate lighthouse report for {string} page', async function (path) {
15
+ const preparedPath = main.prepareUrl(path);
16
+ await lighthouseMethods.validatePageSpeed(this.page, preparedPath, this.scenarioName);
17
+ });
@@ -23,10 +23,12 @@ When('I click on all the elements with selector {string}', async function (cssSe
23
23
  await utils.clickAllElements(this.page, selector);
24
24
  });
25
25
  When('I click on the text {string}', async function (text) {
26
- await utils.clickByText(this.page, text);
26
+ const resolvedText = this.mlStrings[text] ?? text;
27
+ await utils.clickByText(this.page, resolvedText);
27
28
  });
28
29
  When('I click on the text {string} in the {string} region', async function (text, region) {
29
- await utils.clickTextInRegion(this.page, text, region);
30
+ const resolvedText = this.mlStrings[text] ?? text;
31
+ await utils.clickTextInRegion(this.page, resolvedText, region);
30
32
  });
31
33
 
32
34
  Then('I should see {string} in {string}', async function (value, cssSelector) {
@@ -35,7 +37,8 @@ Then('I should see {string} in {string}', async function (value, cssSelector) {
35
37
  });
36
38
 
37
39
  Then('I should see {string} in {string} region', async function (text, region) {
38
- await utils.seeTextInRegion(this.page, text, region);
40
+ const resolvedText = this.mlStrings[text] ?? text;
41
+ await utils.seeTextInRegion(this.page, resolvedText, region);
39
42
  });
40
43
 
41
44
  Then('I should see the element with selector {string}', async function (cssSelector) {
@@ -59,13 +62,16 @@ Then('I wait for element with {string} selector to appear within {string} second
59
62
  await utils.seeElement(this.page, selector, true, time * 1000);
60
63
  });
61
64
  Then('I should not see {string}', async function (text) {
62
- await utils.notSeeText(this.page, text);
65
+ const resolvedText = this.mlStrings[text] ?? text;
66
+ await utils.notSeeText(this.page, resolvedText);
63
67
  });
64
68
  Then('I wait for the text {string} to appear within {string} seconds', async function (text, time) {
65
- await utils.seeTextByXpath(this.page, text, time * 1000);
69
+ const resolvedText = this.mlStrings[text] ?? text;
70
+ await utils.seeTextByXpath(this.page, resolvedText, time * 1000);
66
71
  });
67
72
  Then('I wait for the text {string} to disappear within {string} seconds', async function (text, time) {
68
- await utils.disappearText(this.page, text, time * 1000);
73
+ const resolvedText = this.mlStrings[text] ?? text;
74
+ await utils.disappearText(this.page, resolvedText, time * 1000);
69
75
  });
70
76
  Then('I upload the {string} in {string} field', async function (fileName, cssSelector) {
71
77
  const selector = this.commonFields[cssSelector] ?? cssSelector;
@@ -95,9 +101,10 @@ Then('I select {string} from {string}', async function (value, cssSelector) {
95
101
  const selector = this.commonFields[cssSelector] ?? cssSelector;
96
102
  await utils.selectOptionByValue(this.page, selector, value);
97
103
  });
98
- Then('I select text {string} from {string}', async function (value, cssSelector) {
104
+ Then('I select text {string} from {string}', async function (text, cssSelector) {
99
105
  const selector = this.commonFields[cssSelector] ?? cssSelector;
100
- await utils.selectOptionByText(this.page, selector, value);
106
+ const resolvedText = this.mlStrings[text] ?? text;
107
+ await utils.selectOptionByText(this.page, selector, resolvedText);
101
108
  });
102
109
 
103
110
  Then('I check if link {string} has href {string}', async function (text, href) {
@@ -118,7 +125,8 @@ Then(
118
125
  Then(
119
126
  'I check if element with text {string} has attribute {string} with {string} value',
120
127
  async function (text, attribute, value) {
121
- await utils.validateValueOfElementAttributeByText(this.page, text, attribute, value);
128
+ const resolvedText = this.mlStrings[text] ?? text;
129
+ await utils.validateValueOfElementAttributeByText(this.page, resolvedText, attribute, value);
122
130
  }
123
131
  );
124
132
  Then('I upload {string} file to dropzone {string} field', async function (file, cssSelector) {
@@ -126,28 +134,34 @@ Then('I upload {string} file to dropzone {string} field', async function (file,
126
134
  await utils.uploadToDropzone(this.page, file, selector);
127
135
  });
128
136
  Then('I should see {string} in the schema markup of the page', async function (text) {
129
- await utils.validateTextInSchemaOrg(this.page, text);
137
+ const resolvedText = this.mlStrings[text] ?? text;
138
+ await utils.validateTextInSchemaOrg(this.page, resolvedText);
130
139
  });
131
140
  Then('I should not see {string} in the schema markup of the page', async function (text) {
132
- await utils.validateTextNotInSchemaOrg(this.page, text);
141
+ const resolvedText = this.mlStrings[text] ?? text;
142
+ await utils.validateTextNotInSchemaOrg(this.page, resolvedText);
133
143
  });
134
144
  Then('I should see {string} in page scripts', async function (text) {
135
- await utils.validateTextInScript(this.page, text);
145
+ const resolvedText = this.mlStrings[text] ?? text;
146
+ await utils.validateTextInScript(this.page, resolvedText);
136
147
  });
137
148
  Then('I should {string} see {string} in the {string} accordion', async function (isVisible, text, cssSelector) {
138
149
  const selector = this.commonFields[cssSelector] ?? cssSelector;
139
150
  if (isVisible === 'not') {
140
151
  isVisible = false;
141
152
  }
142
- await utils.textVisibilityInAccordion(this.page, selector, text, Boolean(isVisible));
153
+ const resolvedText = this.mlStrings[text] ?? text;
154
+ await utils.textVisibilityInAccordion(this.page, selector, resolvedText, Boolean(isVisible));
143
155
  });
144
156
  Then('I select the first autocomplete option for {string} on the {string} field', async function (text, cssSelector) {
145
157
  const selector = this.commonFields[cssSelector] ?? cssSelector;
146
- await utils.selectOptionFirstAutocomplete(this.page, text, selector);
158
+ const resolvedText = this.mlStrings[text] ?? text;
159
+ await utils.selectOptionFirstAutocomplete(this.page, resolvedText, selector);
147
160
  });
148
161
  Then('I select {string} from chosen {string}', async function (text, cssSelector) {
149
162
  const selector = this.commonFields[cssSelector] ?? cssSelector;
150
- await utils.selectOptionFromChosen(this.page, text, selector);
163
+ const resolvedText = this.mlStrings[text] ?? text;
164
+ await utils.selectOptionFromChosen(this.page, resolvedText, selector);
151
165
  });
152
166
 
153
167
  Then('I set date {string} in flatpickr with selector {string}', async function (date, cssSelector) {
@@ -186,7 +200,8 @@ Given('I check if checkbox options with locator {string} are not in alphabetical
186
200
  await utils.iCheckIfCheckboxOptionsAreInAlphabeticalOrder(this.page, selector, false);
187
201
  });
188
202
  When('I click on the text {string} and follow the new tab', async function (text) {
189
- this.page = await utils.clickLinkOpenNewTab(this.browser, this.page, text, true);
203
+ const resolvedText = this.mlStrings[text] ?? text;
204
+ this.page = await utils.clickLinkOpenNewTab(this.browser, this.page, resolvedText, true);
190
205
  });
191
206
  When('I click on the element {string} and follow the new tab', async function (cssSelector) {
192
207
  const selector = this.commonFields[cssSelector] ?? cssSelector;
@@ -1,26 +1,26 @@
1
- /**
2
- * @type {string}
3
- * @name scenarioName - name of the scenario from the Before hook
4
- */
5
- const { Given, Then } = require('@cucumber/cucumber');
6
- const imageCompare = require('../../../src/visualRegression');
7
- const main = require('../../../src/mainFunctions');
8
- const dataStorage = require('../../../src/dataStorage');
9
- Given('I generate reference screenshot for {string}', async function (path) {
10
- const storedUrl = await dataStorage.checkForVariable(path);
11
- const url = await main.prepareUrl(storedUrl);
12
- await imageCompare.runBackStopSingleScenario(this.scenarioName, url, 'reference');
13
- });
14
- Then('I compare {string} to reference screenshot', async function (path) {
15
- const storedUrl = await dataStorage.checkForVariable(path);
16
- const url = await main.prepareUrl(storedUrl);
17
- await imageCompare.runBackStopSingleScenario(this.scenarioName, url, 'test');
18
- });
19
- Given('I generate reference screenshot for multiple pages', async function (docString) {
20
- const pages = JSON.parse(docString);
21
- await imageCompare.runBackstopMultiplePages(pages, 'reference');
22
- });
23
- Then('I compare multiple pages to their references', async function (docString) {
24
- const pages = JSON.parse(docString);
25
- await imageCompare.runBackstopMultiplePages(pages, 'test');
26
- });
1
+ /**
2
+ * @type {string}
3
+ * @name scenarioName - name of the scenario from the Before hook
4
+ */
5
+ const { Given, Then } = require('@cucumber/cucumber');
6
+ const imageCompare = require('../../../src/visualRegression');
7
+ const main = require('../../../src/mainFunctions');
8
+ const dataStorage = require('../../../src/dataStorage');
9
+ Given('I generate reference screenshot for {string}', async function (path) {
10
+ const storedUrl = await dataStorage.checkForVariable(path);
11
+ const url = await main.prepareUrl(storedUrl);
12
+ await imageCompare.runBackStopSingleScenario(this.scenarioName, url, 'reference');
13
+ });
14
+ Then('I compare {string} to reference screenshot', async function (path) {
15
+ const storedUrl = await dataStorage.checkForVariable(path);
16
+ const url = await main.prepareUrl(storedUrl);
17
+ await imageCompare.runBackStopSingleScenario(this.scenarioName, url, 'test');
18
+ });
19
+ Given('I generate reference screenshot for multiple pages', async function (docString) {
20
+ const pages = JSON.parse(docString);
21
+ await imageCompare.runBackstopMultiplePages(pages, 'reference');
22
+ });
23
+ Then('I compare multiple pages to their references', async function (docString) {
24
+ const pages = JSON.parse(docString);
25
+ await imageCompare.runBackstopMultiplePages(pages, 'test');
26
+ });