artes 1.0.21 → 1.0.23
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "artes",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
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": {
|
|
@@ -139,10 +139,7 @@ await context.page.goto("https://www.saucedemo.com/");
|
|
|
139
139
|
featureContent,
|
|
140
140
|
);
|
|
141
141
|
fs.writeFileSync(path.join(srcDir, "POMs", "example.pom.json"), pomContent);
|
|
142
|
-
fs.writeFileSync(
|
|
143
|
-
path.join(srcDir, "steps", "example.steps.js"),
|
|
144
|
-
stepsContent,
|
|
145
|
-
);
|
|
142
|
+
fs.writeFileSync(path.join(srcDir, "steps", "common.steps.js"), stepsContent);
|
|
146
143
|
|
|
147
144
|
fs.writeFileSync(
|
|
148
145
|
path.join(projectDir, ".vscode", "settings.json"),
|
|
@@ -7,46 +7,74 @@ class Elements {
|
|
|
7
7
|
this.elements = { ...this.elements, ...elements };
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
// static async locatorExistenceChecker(locator){
|
|
11
|
+
// const locatorCount = await locator.count();
|
|
12
|
+
// console.log(locator, locatorCount)
|
|
13
|
+
// return locatorCount ==0 ? false : true;
|
|
14
|
+
// }
|
|
15
|
+
|
|
10
16
|
static getElement(element) {
|
|
11
17
|
if (!context.page) {
|
|
12
18
|
throw new Error("Page context is not initialized.");
|
|
13
19
|
}
|
|
14
20
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
element?.split("=")[1];
|
|
21
|
+
function selectorSeperator(element) {
|
|
22
|
+
const selector = element?.split("=");
|
|
23
|
+
return [
|
|
24
|
+
selector[0]?.trim(),
|
|
25
|
+
selector[1] !== undefined ? selector[1].trim() : "",
|
|
26
|
+
];
|
|
27
|
+
}
|
|
23
28
|
|
|
24
|
-
|
|
29
|
+
function getSelector(elements, element) {
|
|
30
|
+
if (elements?.[element]?.selector) {
|
|
31
|
+
return selectorSeperator(elements[element].selector);
|
|
32
|
+
} else if (elements?.[element]) {
|
|
33
|
+
return selectorSeperator(elements[element]);
|
|
34
|
+
} else if (typeof element === "string") {
|
|
35
|
+
return selectorSeperator(element);
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
25
39
|
|
|
40
|
+
const selector = getSelector(this.elements, element);
|
|
26
41
|
const waitTime = this.elements[element]?.waitTime * 1000 || 0;
|
|
27
42
|
|
|
28
|
-
|
|
43
|
+
let locator;
|
|
44
|
+
switch (selector[0]) {
|
|
29
45
|
case "xpath":
|
|
30
|
-
|
|
46
|
+
locator = context.page.locator(`xpath=${selector[1]}`);
|
|
47
|
+
break;
|
|
31
48
|
case "name":
|
|
32
|
-
|
|
49
|
+
locator = context.page.locator(`[name=${selector[1]}]`);
|
|
50
|
+
break;
|
|
33
51
|
case "placeholder":
|
|
34
|
-
|
|
52
|
+
locator = context.page.getByPlaceholder(selector[1]);
|
|
53
|
+
break;
|
|
35
54
|
case "text":
|
|
36
|
-
|
|
55
|
+
locator = context.page.getByText(selector[1]);
|
|
56
|
+
break;
|
|
37
57
|
case "label":
|
|
38
|
-
|
|
58
|
+
locator = context.page.getByLabel(selector[1]);
|
|
59
|
+
break;
|
|
39
60
|
case "role":
|
|
40
|
-
|
|
61
|
+
locator = context.page.getByRole(selector[1]);
|
|
62
|
+
break;
|
|
41
63
|
case "alt":
|
|
42
|
-
|
|
64
|
+
locator = context.page.getByAltText(selector[1]);
|
|
65
|
+
break;
|
|
43
66
|
case "title":
|
|
44
|
-
|
|
67
|
+
locator = context.page.getByTitle(selector[1]);
|
|
68
|
+
break;
|
|
45
69
|
case "testid":
|
|
46
|
-
|
|
70
|
+
locator = context.page.getByTestId(selector[1]);
|
|
71
|
+
break;
|
|
47
72
|
default:
|
|
48
|
-
|
|
73
|
+
locator = context.page.locator(selector[0]);
|
|
74
|
+
break;
|
|
49
75
|
}
|
|
76
|
+
|
|
77
|
+
return locator;
|
|
50
78
|
}
|
|
51
79
|
|
|
52
80
|
static getSelector(element) {
|
package/src/hooks/hooks.js
CHANGED
|
@@ -11,6 +11,7 @@ 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");
|
|
14
15
|
|
|
15
16
|
let browser;
|
|
16
17
|
let request;
|
|
@@ -27,7 +28,6 @@ Before(async function () {
|
|
|
27
28
|
|
|
28
29
|
context.page = await browser.newPage();
|
|
29
30
|
await context.page.setDefaultTimeout(cucumberConfig.default.timeout * 1000);
|
|
30
|
-
|
|
31
31
|
context.request = await request;
|
|
32
32
|
|
|
33
33
|
await browser.tracing.start({
|
|
@@ -52,7 +52,7 @@ After(async function ({ pickle, result }) {
|
|
|
52
52
|
await context.page.close();
|
|
53
53
|
await browser.close();
|
|
54
54
|
|
|
55
|
-
if (result?.status != Status.
|
|
55
|
+
if (result?.status != Status.FAILED) {
|
|
56
56
|
const videoPath = await context.page.video().path();
|
|
57
57
|
const webmBuffer = await fs.readFileSync(videoPath);
|
|
58
58
|
await this.attach(webmBuffer, "video/webm");
|