artes 1.0.32 → 1.0.34
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 +9 -11
- package/package.json +1 -1
- package/src/helper/contextManager/browserManager.js +1 -1
- package/src/helper/pomController/elementController.js +12 -10
- package/src/helper/stepFunctions/browserActions.js +11 -0
- package/src/helper/stepFunctions/exporter.js +2 -0
- package/src/helper/stepFunctions/frameActions.js +1 -1
- package/src/helper/stepFunctions/mouseActions.js +3 -2
- package/src/hooks/context.js +1 -0
- package/src/hooks/hooks.js +1 -1
- package/src/stepDefinitions/assertions.steps.js +20 -2
- package/src/stepDefinitions/browser.steps.js +7 -0
- package/src/stepDefinitions/keyboardActions.steps.js +11 -3
- package/src/stepDefinitions/mouseActions.steps.js +12 -1
- /package/{documents → docs}/functionDefinitions.md +0 -0
- /package/{documents → docs}/stepDefinitions.md +0 -0
package/README.md
CHANGED
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
## 🚀 Summary
|
|
8
8
|
|
|
9
|
-
Artes is a test runner for Playwright that executes [predefined Cucumber tests](./
|
|
9
|
+
Artes is a test runner for Playwright that executes [predefined Cucumber tests](./docs/stepDefinitions.md) and can generate Allure reports for test results. It simplifies setting up Playwright with Cucumber in your automation workflow. With Artes, you can easily run tests without writing step definitions, generate reports, and customize your testing environment.
|
|
10
10
|
|
|
11
11
|

|
|
12
12
|
|
|
13
|
-
|
|
14
13
|
## 🧑💻 Installation
|
|
15
14
|
|
|
16
15
|
You can install **Artes** via npm. To install it globally**(RECOMMENDED)**, run the following command:
|
|
@@ -43,14 +42,13 @@ npx artes [options]
|
|
|
43
42
|
|
|
44
43
|
### Options
|
|
45
44
|
|
|
46
|
-
| Option | Description | Usage Example
|
|
47
|
-
|
|
48
|
-
| 🆘 `-h, --help` | Show the usage options | `artes -h` or `artes --help`
|
|
49
|
-
| 🏷️ `-v, --version` | Show the current version of Artes | `artes -v` or `artes --version`
|
|
50
|
-
| 🏗️ `-c, --create` | Create an example project with Artes | `artes -c` or `artes --create`
|
|
51
|
-
| ✅ `-y, --yes` | Skip the confirmation prompt when creating an example project | `artes -c -y` or `artes --create --yes`
|
|
52
|
-
| 📊 `-r, --report` | Run tests and generate Allure report | `artes -r` or `artes --report`
|
|
53
|
-
|
|
45
|
+
| Option | Description | Usage Example |
|
|
46
|
+
| ------------------ | ------------------------------------------------------------- | --------------------------------------- |
|
|
47
|
+
| 🆘 `-h, --help` | Show the usage options | `artes -h` or `artes --help` |
|
|
48
|
+
| 🏷️ `-v, --version` | Show the current version of Artes | `artes -v` or `artes --version` |
|
|
49
|
+
| 🏗️ `-c, --create` | Create an example project with Artes | `artes -c` or `artes --create` |
|
|
50
|
+
| ✅ `-y, --yes` | Skip the confirmation prompt when creating an example project | `artes -c -y` or `artes --create --yes` |
|
|
51
|
+
| 📊 `-r, --report` | Run tests and generate Allure report | `artes -r` or `artes --report` |
|
|
54
52
|
|
|
55
53
|
\*\* To just run the tests: <br>
|
|
56
54
|
Globally: artes <br>
|
|
@@ -242,7 +240,7 @@ const { mouse, keyboard, frame, elementInteractions, page } = require("artes");
|
|
|
242
240
|
|
|
243
241
|
---
|
|
244
242
|
|
|
245
|
-
For a detailed explanation of each function, please refer to the [functionDefinitions.md](./
|
|
243
|
+
For a detailed explanation of each function, please refer to the [functionDefinitions.md](./docs/functionDefinitions.md).
|
|
246
244
|
|
|
247
245
|
---
|
|
248
246
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "artes",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.34",
|
|
4
4
|
"description": "The package provide step definitions and user writes feature files, and the package handles automation, with optional POM files and custom step definitions.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -43,34 +43,36 @@ class Elements {
|
|
|
43
43
|
let locator;
|
|
44
44
|
switch (selector[0]) {
|
|
45
45
|
case "xpath":
|
|
46
|
-
locator = context.page.locator(`xpath=${selector[1]}
|
|
46
|
+
locator = context.page.locator(`xpath=${selector[1]}`, { exact: true });
|
|
47
47
|
break;
|
|
48
48
|
case "name":
|
|
49
|
-
locator = context.page.locator(`[name=${selector[1]}]
|
|
49
|
+
locator = context.page.locator(`[name=${selector[1]}]`, {
|
|
50
|
+
exact: true,
|
|
51
|
+
});
|
|
50
52
|
break;
|
|
51
53
|
case "placeholder":
|
|
52
|
-
locator = context.page.getByPlaceholder(selector[1]);
|
|
54
|
+
locator = context.page.getByPlaceholder(selector[1], { exact: true });
|
|
53
55
|
break;
|
|
54
56
|
case "text":
|
|
55
|
-
locator = context.page.getByText(selector[1]);
|
|
57
|
+
locator = context.page.getByText(selector[1], { exact: true });
|
|
56
58
|
break;
|
|
57
59
|
case "label":
|
|
58
|
-
locator = context.page.getByLabel(selector[1]);
|
|
60
|
+
locator = context.page.getByLabel(selector[1], { exact: true });
|
|
59
61
|
break;
|
|
60
62
|
case "role":
|
|
61
|
-
locator = context.page.getByRole(selector[1]);
|
|
63
|
+
locator = context.page.getByRole(selector[1], { exact: true });
|
|
62
64
|
break;
|
|
63
65
|
case "alt":
|
|
64
|
-
locator = context.page.getByAltText(selector[1]);
|
|
66
|
+
locator = context.page.getByAltText(selector[1], { exact: true });
|
|
65
67
|
break;
|
|
66
68
|
case "title":
|
|
67
|
-
locator = context.page.getByTitle(selector[1]);
|
|
69
|
+
locator = context.page.getByTitle(selector[1], { exact: true });
|
|
68
70
|
break;
|
|
69
71
|
case "testid":
|
|
70
|
-
locator = context.page.getByTestId(selector[1]);
|
|
72
|
+
locator = context.page.getByTestId(selector[1], { exact: true });
|
|
71
73
|
break;
|
|
72
74
|
default:
|
|
73
|
-
locator = context.page.locator(selector[0]);
|
|
75
|
+
locator = context.page.locator(selector[0], { exact: true });
|
|
74
76
|
break;
|
|
75
77
|
}
|
|
76
78
|
|
|
@@ -5,6 +5,7 @@ const { frame } = require("./frameActions");
|
|
|
5
5
|
const { elementInteractions } = require("./elementInteractions");
|
|
6
6
|
const { page } = require("./pageActions");
|
|
7
7
|
const { api } = require("./APIActions");
|
|
8
|
+
const { browser } = require("./browserActions");
|
|
8
9
|
|
|
9
10
|
module.exports = {
|
|
10
11
|
assert,
|
|
@@ -14,4 +15,5 @@ module.exports = {
|
|
|
14
15
|
elementInteractions,
|
|
15
16
|
page,
|
|
16
17
|
api,
|
|
18
|
+
browser,
|
|
17
19
|
};
|
|
@@ -14,7 +14,7 @@ const frame = {
|
|
|
14
14
|
return await element(selector).frameLocator();
|
|
15
15
|
},
|
|
16
16
|
nth: async (selector, index) => {
|
|
17
|
-
return await element(selector).nth(index);
|
|
17
|
+
return await element(selector).nth(index - 1);
|
|
18
18
|
},
|
|
19
19
|
first: async (selector) => {
|
|
20
20
|
return await element(selector).first();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { element } = require("../imports/commons");
|
|
2
2
|
const { frame } = require("../stepFunctions/frameActions");
|
|
3
|
+
|
|
3
4
|
const mouse = {
|
|
4
5
|
click: async (selector) => {
|
|
5
6
|
await element(selector).click();
|
|
@@ -96,10 +97,10 @@ const mouse = {
|
|
|
96
97
|
},
|
|
97
98
|
selectByValue: async (selector, value) => {
|
|
98
99
|
const valueArray = value.split(",");
|
|
99
|
-
await element(selector).selectOption(valueArray);
|
|
100
|
+
value !== "" ? await element(selector).selectOption(valueArray) : "";
|
|
100
101
|
},
|
|
101
102
|
selectByText: async (selector, value) => {
|
|
102
|
-
await element(selector).selectOption(value);
|
|
103
|
+
value !== "" ? await element(selector).selectOption(value) : "";
|
|
103
104
|
},
|
|
104
105
|
check: async (selector) => {
|
|
105
106
|
await element(selector).check();
|
package/src/hooks/context.js
CHANGED
package/src/hooks/hooks.js
CHANGED
|
@@ -11,7 +11,6 @@ const { pomCollector } = require("../helper/pomController/pomCollector");
|
|
|
11
11
|
const cucumberConfig = require("../../cucumber.config");
|
|
12
12
|
const { context } = require("./context");
|
|
13
13
|
const fs = require("fs");
|
|
14
|
-
const { expect } = require("playwright/test");
|
|
15
14
|
const { moduleConfig } = require("artes/src/helper/imports/commons");
|
|
16
15
|
const path = require("path");
|
|
17
16
|
|
|
@@ -28,6 +27,7 @@ Before(async function () {
|
|
|
28
27
|
browser = await invokeBrowser();
|
|
29
28
|
request = await invokeRequest();
|
|
30
29
|
|
|
30
|
+
context.browser = await browser;
|
|
31
31
|
context.page = await browser.newPage();
|
|
32
32
|
await context.page.setDefaultTimeout(cucumberConfig.default.timeout * 1000);
|
|
33
33
|
context.request = await request;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
const {
|
|
2
|
-
|
|
1
|
+
const {
|
|
2
|
+
Then,
|
|
3
|
+
selector,
|
|
4
|
+
expect,
|
|
5
|
+
element,
|
|
6
|
+
} = require("../helper/imports/commons");
|
|
7
|
+
const { assert, frame } = require("../helper/stepFunctions/exporter");
|
|
3
8
|
|
|
4
9
|
// Check if a selector should be attached
|
|
5
10
|
Then("User expects {string} should be attached", async function (selector) {
|
|
@@ -62,6 +67,14 @@ Then(
|
|
|
62
67
|
},
|
|
63
68
|
);
|
|
64
69
|
|
|
70
|
+
Then(
|
|
71
|
+
"User expects default value of {string} should have {string} text",
|
|
72
|
+
async (selector, text) => {
|
|
73
|
+
const defaultValue = await element(selector).inputValue();
|
|
74
|
+
await expect(defaultValue).toContain(text);
|
|
75
|
+
},
|
|
76
|
+
);
|
|
77
|
+
|
|
65
78
|
Then(
|
|
66
79
|
"User expects multiple {string} should have {string} text",
|
|
67
80
|
async (elements, expectedText) => {
|
|
@@ -795,3 +808,8 @@ Then(
|
|
|
795
808
|
await assert.shouldNotStringMatching(selector, new RegExp(regex));
|
|
796
809
|
},
|
|
797
810
|
);
|
|
811
|
+
|
|
812
|
+
Then("User expects should have {int} {string}", async (count, elements) => {
|
|
813
|
+
const elementCount = await frame.count(elements);
|
|
814
|
+
expect(elementCount).toEqual(count);
|
|
815
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const { When } = require("../helper/imports/commons");
|
|
2
|
+
const { browser } = require("../helper/stepFunctions/exporter");
|
|
3
|
+
|
|
4
|
+
// User sets cookies in json format
|
|
5
|
+
When("User sets {string} cookies", async function (cookies) {
|
|
6
|
+
await browser.setCookies(cookies);
|
|
7
|
+
});
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
const { When } = require("../helper/imports/commons");
|
|
2
|
-
const { keyboard } = require("../helper/stepFunctions/exporter");
|
|
2
|
+
const { keyboard, frame } = require("../helper/stepFunctions/exporter");
|
|
3
3
|
|
|
4
4
|
// User presses a key on a specific selector
|
|
5
5
|
When("User presses {string} on {string}", async function (key, selector) {
|
|
6
6
|
await keyboard.press(selector, key);
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
+
When(
|
|
10
|
+
"User types {string} in {int} th of {string}",
|
|
11
|
+
async (text, order, elements) => {
|
|
12
|
+
const nthElement = await frame.nth(elements, order);
|
|
13
|
+
await nthElement.fill(text);
|
|
14
|
+
},
|
|
15
|
+
);
|
|
16
|
+
|
|
9
17
|
// User presses keys sequentially on a specific selector
|
|
10
18
|
When(
|
|
11
19
|
"User presses keys {string} sequentially on {string}",
|
|
@@ -40,8 +48,8 @@ When("User clears {string}", async function (selector) {
|
|
|
40
48
|
});
|
|
41
49
|
|
|
42
50
|
// User selects text in a specific selector
|
|
43
|
-
When("User selects
|
|
44
|
-
await keyboard.selectText(
|
|
51
|
+
When("User selects {string} text", async function (text) {
|
|
52
|
+
await keyboard.selectText(text);
|
|
45
53
|
});
|
|
46
54
|
|
|
47
55
|
// User sets input files for a specific selector
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
const { When } = require("../helper/imports/commons");
|
|
2
|
-
const { mouse } = require("../helper/stepFunctions/exporter");
|
|
2
|
+
const { mouse, frame } = require("../helper/stepFunctions/exporter");
|
|
3
3
|
|
|
4
4
|
// User clicks on a selector
|
|
5
5
|
When("User clicks {string}", async function (selector) {
|
|
6
6
|
await mouse.click(selector);
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
+
When("User clicks last of {string}", async (selector) => {
|
|
10
|
+
const elementCount = await frame.count(selector);
|
|
11
|
+
const lastElement = await frame.nth(selector, elementCount);
|
|
12
|
+
await mouse.click(lastElement);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
When("User clicks {int} th of {string}", async (order, elements) => {
|
|
16
|
+
const nthElement = await frame.nth(elements, order);
|
|
17
|
+
await nthElement.click();
|
|
18
|
+
});
|
|
19
|
+
|
|
9
20
|
When("User clicks multiple {string}", async (elements) => {
|
|
10
21
|
await mouse.multipleElementClick(elements);
|
|
11
22
|
});
|
|
File without changes
|
|
File without changes
|