artes 1.0.19 → 1.0.20

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.19",
3
+ "version": "1.0.20",
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": {
@@ -11,10 +11,42 @@ class Elements {
11
11
  if (!context.page) {
12
12
  throw new Error("Page context is not initialized.");
13
13
  }
14
+
15
+ const selectorType =
16
+ this.elements?.[element]?.selector?.split("=")[0] ||
17
+ this.elements?.[element]?.split("=")[0] ||
18
+ element?.split("=")[0];
14
19
  const selector =
15
- this.elements?.[element]?.selector || this.elements?.[element] || element;
20
+ this.elements?.[element]?.selector?.split("=")[1] ||
21
+ this.elements?.[element]?.split("=")[1] ||
22
+ element?.split("=")[1];
23
+
24
+ const locator = [selectorType, selector];
25
+
16
26
  const waitTime = this.elements[element]?.waitTime * 1000 || 0;
17
- return context.page.locator(selector);
27
+
28
+ switch (locator[0]) {
29
+ case "xpath":
30
+ return context.page.locator(`xpath=${locator[1]}`);
31
+ case "name":
32
+ return context.page.locator(`[name=${locator[1]}]`);
33
+ case "placeholder":
34
+ return context.page.getByPlaceholder(locator[1]);
35
+ case "text":
36
+ return context.page.getByText(locator[1]);
37
+ case "label":
38
+ return context.page.getByLabel(locator[1]);
39
+ case "role":
40
+ return context.page.getByRole(locator[1]);
41
+ case "alt":
42
+ return context.page.getByAltText(locator[1]);
43
+ case "title":
44
+ return context.page.getByTitle(locator[1]);
45
+ case "testid":
46
+ return context.page.getByTestId(locator[1]);
47
+ default:
48
+ return context.page.locator(locator[0]);
49
+ }
18
50
  }
19
51
 
20
52
  static getSelector(element) {
@@ -20,12 +20,6 @@ setDefaultTimeout(cucumberConfig.default.cucumberTimeout * 1000);
20
20
 
21
21
  BeforeAll(async function () {
22
22
  pomCollector();
23
-
24
- // browser.tracing.start({
25
- // sources: true,
26
- // screenshots: true,
27
- // snapshots: true,
28
- // });
29
23
  });
30
24
 
31
25
  Before(async function () {
@@ -33,6 +27,11 @@ Before(async function () {
33
27
  request = await invokeRequest();
34
28
  context.page = await browser.newPage();
35
29
  context.request = await request;
30
+ await browser.tracing.start({
31
+ sources: true,
32
+ screenshots: true,
33
+ snapshots: true,
34
+ });
36
35
  });
37
36
 
38
37
  After(async function ({ pickle, result }) {
@@ -46,10 +45,10 @@ After(async function ({ pickle, result }) {
46
45
  await this.attach(img, "image/png");
47
46
  }
48
47
 
48
+ await browser.tracing.stop({ path: "./trace.zip" });
49
49
  await context.page.close();
50
50
  await browser.close();
51
51
 
52
- // await browser.tracing.stop({ path: 'trace.zip' });
53
52
  if (result?.status != Status.PASSED) {
54
53
  const videoPath = await context.page.video().path();
55
54
  const webmBuffer = await fs.readFileSync(videoPath);