@cuppet/core 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Core testing framework components for Cuppet - a BDD framework based on Cucumber
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
8
|
+
yarn install @cuppet/core
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
@@ -134,7 +134,7 @@ This package requires the following peer dependencies:
|
|
|
134
134
|
Make sure to install these in your project:
|
|
135
135
|
|
|
136
136
|
```bash
|
|
137
|
-
|
|
137
|
+
yarn install @cucumber/cucumber config
|
|
138
138
|
```
|
|
139
139
|
|
|
140
140
|
## License
|
|
@@ -41,6 +41,11 @@ Then('I should see {string} in {string} region', async function (text, region) {
|
|
|
41
41
|
await utils.seeTextInRegion(this.page, resolvedText, region);
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
+
Then('I should not see {string} in {string} region', async function (text, region) {
|
|
45
|
+
const resolvedText = this.mlStrings[text] ?? text;
|
|
46
|
+
await utils.notSeeTextInRegion(this.page, resolvedText, region);
|
|
47
|
+
});
|
|
48
|
+
|
|
44
49
|
Then('I should see the element with selector {string}', async function (cssSelector) {
|
|
45
50
|
const selector = this.commonFields[cssSelector] ?? cssSelector;
|
|
46
51
|
await utils.seeElement(this.page, selector);
|
package/features/app/world.js
CHANGED
package/package.json
CHANGED
|
@@ -411,6 +411,31 @@ module.exports = {
|
|
|
411
411
|
}
|
|
412
412
|
},
|
|
413
413
|
|
|
414
|
+
/**
|
|
415
|
+
* Validate that text is not visible in specific region (another element).
|
|
416
|
+
* To be used when multiple renders of the same text are shown on the page.
|
|
417
|
+
* @param {Page} page
|
|
418
|
+
* @param text
|
|
419
|
+
* @param region
|
|
420
|
+
* @param time
|
|
421
|
+
* @returns {Promise<void>}
|
|
422
|
+
*/
|
|
423
|
+
notSeeTextInRegion: async function (page, text, region, time = 3000) {
|
|
424
|
+
const regionClass = await helper.getRegion(page, region);
|
|
425
|
+
const selector = 'xpath/' + `//*[contains(@class,'${regionClass}') and .//text()[contains(.,"${text}")]]`;
|
|
426
|
+
const options = {
|
|
427
|
+
visible: true, // With true flag it will fail only if the element is in the dom and visible
|
|
428
|
+
timeout: time, // Maximum time to wait in milliseconds (default is 30s which is a lot for a negative step)
|
|
429
|
+
};
|
|
430
|
+
try {
|
|
431
|
+
await page.waitForSelector(selector, options);
|
|
432
|
+
throw new Error(`Text ${text} is visible in ${regionClass}!`);
|
|
433
|
+
} catch {
|
|
434
|
+
// Element not visible - that's the expected result
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
|
|
414
439
|
/**
|
|
415
440
|
* Hover element based on text content (useful for text inside spans, paragraphs etc. like menu links)
|
|
416
441
|
* @param {Page} page
|