@uuv/playwright 3.47.0 → 3.48.0

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.
@@ -114,6 +114,25 @@ const path_1 = __importDefault(require("path"));
114
114
  (0, world_1.When)(`I enter the value {string}`, async function (textToType) {
115
115
  await type(this, textToType);
116
116
  });
117
+ /**
118
+ * Writes the sentence passed as a parameter in the ag-Grid cell at the specified row and column name (useful for example to fill in a form field in ag-Grid).<br/>Make sure you've selected an ag-Grid element beforehand with the <strong>within...</strong> phrases.
119
+ * */
120
+ (0, world_1.When)(`I type the sentence {string} in aggrid cell at the row {int} and column named {string}`, async function (textToType, lineNumber, columnName) {
121
+ await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
122
+ // Confirm the element is a grid or treegrid
123
+ const elementRole = await element.getAttribute("role");
124
+ (0, test_1.expect)(["grid", "treegrid"], { message: "Focus element doesn't have grid/treegrid role" }).toContain(elementRole);
125
+ // Retrieve column index
126
+ const columnElement = await element.getByRole("columnheader", { name: columnName, exact: true });
127
+ const colIndex = Number(await columnElement.getAttribute("aria-colindex")) - 1;
128
+ // Double click on the cell
129
+ const rows = await element.getByRole("row", { exact: true }).all();
130
+ const cellElement = (await rows[lineNumber].getByRole("gridcell", { exact: true }).all())[colIndex];
131
+ await cellElement.dblclick();
132
+ // Type text in the cell
133
+ await this.page.locator("[aria-label=\"Input Editor\"]").type(textToType);
134
+ });
135
+ });
117
136
  /**
118
137
  * Select the combo box option passed as a parameter (useful for example to fill in a combobox form field).<br/>Make sure you've selected a combo box element beforehand with the <strong>within a combo box named 'yourComboboxNamee'</strong> phrases.
119
138
  * */
@@ -507,9 +526,11 @@ function getConfigDir() {
507
526
  (0, world_1.Then)(`I should see a grid named {string} and containing`, async function (expectedListName, pExpectedElementsOfList) {
508
527
  const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
509
528
  await (0, core_engine_1.findWithRoleAndName)(this, "grid", expectedListName);
529
+ await (0, core_engine_1.addCookie)(this, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT, new core_engine_1.SelectedElementCookie(core_engine_1.FILTER_TYPE.SELECTOR, `role=grid[name="${expectedListName}"]`));
510
530
  await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
511
531
  await expectTableToHaveContent(element, expectedElementsOfList, "gridcell");
512
532
  });
533
+ await (0, core_engine_1.deleteCookieByName)(this, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT);
513
534
  });
514
535
  /**
515
536
  * Checks that there is a treegrid with the specified [name](https://russmaxdesign.github.io/html-elements-names/) containing list items.<br/> <u>Example</u>\n```gherkin\nWhen I visit path "https://e2e-test-quest.github.io/simple-webapp/treegrid.html"\nThen I should see a treegrid named "HTML Treegrid Example" and containing\n| Make | Model | Price |\n| ------------ | ------- | ------ |\n| Toyota | Celica | 35000 |\n| Ford | Mondeo | 32000 |\n| Porsche | Boxster | 72000 |\n| BMW | M50 | 60000 |\n| Aston Martin | DBX | 190000 |\n```
@@ -517,9 +538,11 @@ function getConfigDir() {
517
538
  (0, world_1.Then)(`I should see a treegrid named {string} and containing`, async function (expectedListName, pExpectedElementsOfList) {
518
539
  const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
519
540
  await (0, core_engine_1.findWithRoleAndName)(this, "treegrid", expectedListName);
541
+ await (0, core_engine_1.addCookie)(this, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT, new core_engine_1.SelectedElementCookie(core_engine_1.FILTER_TYPE.SELECTOR, `role=treegrid[name="${expectedListName}"]`));
520
542
  await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
521
543
  await expectTableToHaveContent(element, expectedElementsOfList, "gridcell");
522
544
  });
545
+ await (0, core_engine_1.deleteCookieByName)(this, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT);
523
546
  });
524
547
  /**
525
548
  * Checks that there is a table with the specified [name](https://russmaxdesign.github.io/html-elements-names/) containing list items.<br/> <u>Example</u>\n```gherkin\nWhen I visit path "https://e2e-test-quest.github.io/simple-webapp/table.html"\nThen I should see a table named "test-list" and containing\n| Company | Contact | Country |\n| ----------------------------- | ---------------- | ------- |\n| Alfreds Futterkiste | Maria Anders | Germany |\n| Centro comercial Moctezuma | Francisco Chang | Mexico |\n| Ernst Handel | Roland Mendel | Austria |\n| Island Trading | Helen Bennett | UK |\n| Laughing Bacchus Winecellars | Yoshi Tannamuri | Canada |\n| Magazzini Alimentari Riuniti | Giovanni Rovelli | Italy |\n```
@@ -527,9 +550,11 @@ function getConfigDir() {
527
550
  (0, world_1.Then)(`I should see a table named {string} and containing`, async function (expectedListName, pExpectedElementsOfList) {
528
551
  const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
529
552
  await (0, core_engine_1.findWithRoleAndName)(this, "table", expectedListName);
553
+ await (0, core_engine_1.addCookie)(this, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT, new core_engine_1.SelectedElementCookie(core_engine_1.FILTER_TYPE.SELECTOR, `role=table[name="${expectedListName}"]`));
530
554
  await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
531
555
  await expectTableToHaveContent(element, expectedElementsOfList, "cell");
532
556
  });
557
+ await (0, core_engine_1.deleteCookieByName)(this, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT);
533
558
  });
534
559
  /**
535
560
  * Checks that an Html element exists with [accessible role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles#aria_role_types) `heading`, the specified [name](https://russmaxdesign.github.io/html-elements-names/) and title level
@@ -552,8 +577,8 @@ async function expectTableToHaveContent(element, expectedElementsOfList, pCellAc
552
577
  let cellNumber = 0;
553
578
  return await Promise.all(cellsElement.map((cell) => {
554
579
  const expectedValue = expectedElementsOfList[rowNumber][cellNumber];
555
- (0, test_1.expect)(cell, { message: `${cellAccessibleRole} at index [${rowNumber}, ${cellNumber}] should be ${expectedValue}` }).toHaveAccessibleName(expectedValue);
556
580
  cellNumber++;
581
+ return (0, test_1.expect)(cell, { message: `${cellAccessibleRole} at index [${rowNumber + 1}, ${cellNumber}] should be ${expectedValue}` }).toHaveAccessibleName(expectedValue);
557
582
  }));
558
583
  }));
559
584
  }
@@ -103,7 +103,7 @@ const path_1 = __importDefault(require("path"));
103
103
  await (0, core_engine_1.addCookie)(this, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT, new core_engine_1.SelectedElementCookie(core_engine_1.FILTER_TYPE.SELECTOR, selector));
104
104
  });
105
105
  /**
106
- * Saisit de la phrase passée en paramètre (utile par exemple pour remplir un champ de formulaire).<br/>Assurez vous d'avoir effectué une sélection d'élément avant avec les phrases <strong>je vais à l'intérieur...</strong>.
106
+ * Saisie de la phrase passée en paramètre (utile par exemple pour remplir un champ de formulaire).<br/>Assurez vous d'avoir effectué une sélection d'élément avant avec les phrases <strong>je vais à l'intérieur...</strong>.
107
107
  * */
108
108
  (0, world_1.When)(`je saisie le(s) mot(s) {string}`, async function (textToType) {
109
109
  await type(this, textToType);
@@ -114,6 +114,25 @@ const path_1 = __importDefault(require("path"));
114
114
  (0, world_1.When)(`j'entre la valeur {string}`, async function (textToType) {
115
115
  await type(this, textToType);
116
116
  });
117
+ /**
118
+ * Saisie de la phrase passée en paramètre dans une cellule d'une grille ag-Grid (utile par exemple pour remplir une cellule dans une grille).<br/>Assurez vous d'avoir effectué une sélection d'élément avant avec les phrases <strong>je vais à l'intérieur...</strong>.
119
+ * */
120
+ (0, world_1.When)(`je saisie le(s) mot(s) {string} dans la cellule aggrid à la ligne {int} et la colonne nommée {string}`, async function (textToType, lineNumber, columnName) {
121
+ await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
122
+ // Confirm the element is a grid or treegrid
123
+ const elementRole = await element.getAttribute("role");
124
+ (0, test_1.expect)(["grid", "treegrid"], { message: "Focus element doesn't have grid/treegrid role" }).toContain(elementRole);
125
+ // Retrieve column index
126
+ const columnElement = await element.getByRole("columnheader", { name: columnName, exact: true });
127
+ const colIndex = Number(await columnElement.getAttribute("aria-colindex")) - 1;
128
+ // Double click on the cell
129
+ const rows = await element.getByRole("row", { exact: true }).all();
130
+ const cellElement = (await rows[lineNumber].getByRole("gridcell", { exact: true }).all())[colIndex];
131
+ await cellElement.dblclick();
132
+ // Type text in the cell
133
+ await this.page.locator("[aria-label=\"Input Editor\"]").type(textToType);
134
+ });
135
+ });
117
136
  /**
118
137
  * Sélectionne l'option passée en paramètre (utile par exemple pour remplir un champ le liste déroulante).<br/>Assurez vous d'avoir effectué une sélection d'élément avant avec les phrases <strong>je vais à l'intérieur de la liste déroulante nommée 'maListeDeroulante'</strong>.
119
138
  * */
@@ -507,9 +526,11 @@ function getConfigDir() {
507
526
  (0, world_1.Then)(`je dois voir une grille nommée {string} et contenant`, async function (expectedListName, pExpectedElementsOfList) {
508
527
  const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
509
528
  await (0, core_engine_1.findWithRoleAndName)(this, "grid", expectedListName);
529
+ await (0, core_engine_1.addCookie)(this, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT, new core_engine_1.SelectedElementCookie(core_engine_1.FILTER_TYPE.SELECTOR, `role=grid[name="${expectedListName}"]`));
510
530
  await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
511
531
  await expectTableToHaveContent(element, expectedElementsOfList, "gridcell");
512
532
  });
533
+ await (0, core_engine_1.deleteCookieByName)(this, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT);
513
534
  });
514
535
  /**
515
536
  * Vérifie qu'il existe une grille arborescente (treegrid) avec le nom et les éléments spécifiés.<br/> <u>Exemple</u>\n```gherkin\nQuand je visite l'Url "https://e2e-test-quest.github.io/simple-webapp/treegrid.html"\nAlors je dois voir une liste nommée "HTML Treegrid Example" et contenant\n| Make | Model | Price |\n| ------------ | ------- | ------ |\n| Toyota | Celica | 35000 |\n| Ford | Mondeo | 32000 |\n| Porsche | Boxster | 72000 |\n| BMW | M50 | 60000 |\n| Aston Martin | DBX | 190000 |\n```
@@ -517,9 +538,11 @@ function getConfigDir() {
517
538
  (0, world_1.Then)(`je dois voir une grille arborescente nommée {string} et contenant`, async function (expectedListName, pExpectedElementsOfList) {
518
539
  const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
519
540
  await (0, core_engine_1.findWithRoleAndName)(this, "treegrid", expectedListName);
541
+ await (0, core_engine_1.addCookie)(this, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT, new core_engine_1.SelectedElementCookie(core_engine_1.FILTER_TYPE.SELECTOR, `role=treegrid[name="${expectedListName}"]`));
520
542
  await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
521
543
  await expectTableToHaveContent(element, expectedElementsOfList, "gridcell");
522
544
  });
545
+ await (0, core_engine_1.deleteCookieByName)(this, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT);
523
546
  });
524
547
  /**
525
548
  * Vérifie qu'il existe un tableau (table) avec le nom et les éléments spécifiés.<br/> <u>Exemple</u>\n```gherkin\nQuand je visite l'Url "https://e2e-test-quest.github.io/simple-webapp/table.html"\nAlors je dois voir un tableau nommée "HTML Table Example" et contenant\n| Company | Contact | Country |\n| ----------------------------- | ---------------- | ------- |\n| Alfreds Futterkiste | Maria Anders | Germany |\n| Centro comercial Moctezuma | Francisco Chang | Mexico |\n| Ernst Handel | Roland Mendel | Austria |\n| Island Trading | Helen Bennett | UK |\n| Laughing Bacchus Winecellars | Yoshi Tannamuri | Canada |\n| Magazzini Alimentari Riuniti | Giovanni Rovelli | Italy |\n```
@@ -527,9 +550,11 @@ function getConfigDir() {
527
550
  (0, world_1.Then)(`je dois voir un tableau nommé {string} et contenant`, async function (expectedListName, pExpectedElementsOfList) {
528
551
  const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
529
552
  await (0, core_engine_1.findWithRoleAndName)(this, "table", expectedListName);
553
+ await (0, core_engine_1.addCookie)(this, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT, new core_engine_1.SelectedElementCookie(core_engine_1.FILTER_TYPE.SELECTOR, `role=table[name="${expectedListName}"]`));
530
554
  await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
531
555
  await expectTableToHaveContent(element, expectedElementsOfList, "cell");
532
556
  });
557
+ await (0, core_engine_1.deleteCookieByName)(this, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT);
533
558
  });
534
559
  /**
535
560
  * Vérifie l'existence d'un élément Html ayant le rôle `heading`, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) et le niveau spécifiés
@@ -552,8 +577,8 @@ async function expectTableToHaveContent(element, expectedElementsOfList, pCellAc
552
577
  let cellNumber = 0;
553
578
  return await Promise.all(cellsElement.map((cell) => {
554
579
  const expectedValue = expectedElementsOfList[rowNumber][cellNumber];
555
- (0, test_1.expect)(cell, { message: `${cellAccessibleRole} at index [${rowNumber}, ${cellNumber}] should be ${expectedValue}` }).toHaveAccessibleName(expectedValue);
556
580
  cellNumber++;
581
+ return (0, test_1.expect)(cell, { message: `${cellAccessibleRole} at index [${rowNumber + 1}, ${cellNumber}] should be ${expectedValue}` }).toHaveAccessibleName(expectedValue);
557
582
  }));
558
583
  }));
559
584
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uuv/playwright",
3
- "version": "3.47.0",
3
+ "version": "3.48.0",
4
4
  "type": "commonjs",
5
5
  "author": "Louis Fredice NJAKO MOLOM (https://github.com/luifr10) & Stanley SERVICAL (https://github.com/stanlee974)",
6
6
  "description": "A solution to facilitate the writing and execution of E2E tests understandable by any human being using cucumber(BDD) and playwright",
@@ -46,8 +46,8 @@
46
46
  "@cucumber/cucumber": "11.0.1",
47
47
  "@cucumber/tag-expressions": "6.2.0",
48
48
  "@playwright/test": "^1.55.0",
49
- "@uuv/a11y": "1.0.0-beta.78",
50
- "@uuv/runner-commons": "2.60.0",
49
+ "@uuv/a11y": "1.0.0-beta.79",
50
+ "@uuv/runner-commons": "2.61.0",
51
51
  "axe-core": "4.10.3",
52
52
  "axe-playwright": "2.1.0",
53
53
  "chalk-table": "1.0.2",
@@ -90,7 +90,7 @@
90
90
  },
91
91
  "devDependencies": {
92
92
  "@types/minimist": "1.2.5",
93
- "@types/node": "20.12.12",
93
+ "@types/node": "22.18.0",
94
94
  "@typescript-eslint/eslint-plugin": "7.18.0",
95
95
  "@typescript-eslint/parser": "7.18.0",
96
96
  "chalk": "^4.1.2",
@@ -98,7 +98,7 @@
98
98
  "eslint": "8.56.0",
99
99
  "eslint-plugin-cucumber": "2.0.0",
100
100
  "eslint-plugin-jest": "27.9.0",
101
- "eslint-plugin-playwright": "2.2.0",
101
+ "eslint-plugin-playwright": "2.2.2",
102
102
  "ts-loader": "9.5.2",
103
103
  "tsconfig-paths": "4.2.0",
104
104
  "webpack": "5.99.6"
@@ -151,6 +151,29 @@ When(`I enter the value {string}`, async function(textToType: string) {
151
151
  await type(this, textToType);
152
152
  });
153
153
 
154
+ /**
155
+ * Writes the sentence passed as a parameter in the ag-Grid cell at the specified row and column name (useful for example to fill in a form field in ag-Grid).<br/>Make sure you've selected an ag-Grid element beforehand with the <strong>within...</strong> phrases.
156
+ * */
157
+ When(`I type the sentence {string} in aggrid cell at the row {int} and column named {string}`, async function(textToType: string, lineNumber: number, columnName: string) {
158
+ await getPageOrElement(this).then(async (element: Locator) => {
159
+ // Confirm the element is a grid or treegrid
160
+ const elementRole = await element.getAttribute("role");
161
+ expect(["grid", "treegrid"], { message: "Focus element doesn't have grid/treegrid role" }).toContain(elementRole!);
162
+
163
+ // Retrieve column index
164
+ const columnElement = await element.getByRole("columnheader", { name: columnName, exact: true });
165
+ const colIndex = Number(await columnElement.getAttribute("aria-colindex")) - 1;
166
+
167
+ // Double click on the cell
168
+ const rows = await element.getByRole("row", { exact: true }).all();
169
+ const cellElement = (await rows[lineNumber].getByRole("gridcell", { exact: true }).all())[colIndex];
170
+ await cellElement.dblclick();
171
+
172
+ // Type text in the cell
173
+ await this.page.locator("[aria-label=\"Input Editor\"]").type(textToType);
174
+ });
175
+ });
176
+
154
177
  /**
155
178
  * Select the combo box option passed as a parameter (useful for example to fill in a combobox form field).<br/>Make sure you've selected a combo box element beforehand with the <strong>within a combo box named 'yourComboboxNamee'</strong> phrases.
156
179
  * */
@@ -642,9 +665,11 @@ Then(
642
665
  async function(expectedListName: string, pExpectedElementsOfList: DataTable) {
643
666
  const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
644
667
  await findWithRoleAndName(this, "grid", expectedListName);
668
+ await addCookie(this, COOKIE_NAME.SELECTED_ELEMENT, new SelectedElementCookie(FILTER_TYPE.SELECTOR, `role=grid[name="${expectedListName}"]`));
645
669
  await getPageOrElement(this).then(async (element) => {
646
670
  await expectTableToHaveContent(element, expectedElementsOfList, "gridcell");
647
671
  });
672
+ await deleteCookieByName(this, COOKIE_NAME.SELECTED_ELEMENT);
648
673
  }
649
674
  );
650
675
 
@@ -656,9 +681,11 @@ Then(
656
681
  async function(expectedListName: string, pExpectedElementsOfList: DataTable) {
657
682
  const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
658
683
  await findWithRoleAndName(this, "treegrid", expectedListName);
684
+ await addCookie(this, COOKIE_NAME.SELECTED_ELEMENT, new SelectedElementCookie(FILTER_TYPE.SELECTOR, `role=treegrid[name="${expectedListName}"]`));
659
685
  await getPageOrElement(this).then(async (element) => {
660
686
  await expectTableToHaveContent(element, expectedElementsOfList, "gridcell");
661
687
  });
688
+ await deleteCookieByName(this, COOKIE_NAME.SELECTED_ELEMENT);
662
689
  }
663
690
  );
664
691
 
@@ -670,9 +697,11 @@ Then(
670
697
  async function(expectedListName: string, pExpectedElementsOfList: DataTable) {
671
698
  const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
672
699
  await findWithRoleAndName(this, "table", expectedListName);
700
+ await addCookie(this, COOKIE_NAME.SELECTED_ELEMENT, new SelectedElementCookie(FILTER_TYPE.SELECTOR, `role=table[name="${expectedListName}"]`));
673
701
  await getPageOrElement(this).then(async (element) => {
674
702
  await expectTableToHaveContent(element, expectedElementsOfList, "cell");
675
703
  });
704
+ await deleteCookieByName(this, COOKIE_NAME.SELECTED_ELEMENT);
676
705
  }
677
706
  );
678
707
 
@@ -699,8 +728,8 @@ async function expectTableToHaveContent(element: Locator, expectedElementsOfList
699
728
  let cellNumber = 0;
700
729
  return await Promise.all(cellsElement.map((cell: Locator) => {
701
730
  const expectedValue = expectedElementsOfList[rowNumber][cellNumber];
702
- expect(cell, { message: `${cellAccessibleRole} at index [${rowNumber}, ${cellNumber}] should be ${expectedValue}` }).toHaveAccessibleName(expectedValue);
703
731
  cellNumber++;
732
+ return expect(cell, { message: `${cellAccessibleRole} at index [${rowNumber + 1}, ${cellNumber}] should be ${expectedValue}` }).toHaveAccessibleName(expectedValue);
704
733
  }));
705
734
  }));
706
735
  }
@@ -138,7 +138,7 @@ When(`je vais à l'intérieur de l'élément ayant pour sélecteur {string}`, as
138
138
  });
139
139
 
140
140
  /**
141
- * Saisit de la phrase passée en paramètre (utile par exemple pour remplir un champ de formulaire).<br/>Assurez vous d'avoir effectué une sélection d'élément avant avec les phrases <strong>je vais à l'intérieur...</strong>.
141
+ * Saisie de la phrase passée en paramètre (utile par exemple pour remplir un champ de formulaire).<br/>Assurez vous d'avoir effectué une sélection d'élément avant avec les phrases <strong>je vais à l'intérieur...</strong>.
142
142
  * */
143
143
  When(`je saisie le(s) mot(s) {string}`, async function(textToType: string) {
144
144
  await type(this, textToType);
@@ -151,6 +151,29 @@ When(`j'entre la valeur {string}`, async function(textToType: string) {
151
151
  await type(this, textToType);
152
152
  });
153
153
 
154
+ /**
155
+ * Saisie de la phrase passée en paramètre dans une cellule d'une grille ag-Grid (utile par exemple pour remplir une cellule dans une grille).<br/>Assurez vous d'avoir effectué une sélection d'élément avant avec les phrases <strong>je vais à l'intérieur...</strong>.
156
+ * */
157
+ When(`je saisie le(s) mot(s) {string} dans la cellule aggrid à la ligne {int} et la colonne nommée {string}`, async function(textToType: string, lineNumber: number, columnName: string) {
158
+ await getPageOrElement(this).then(async (element: Locator) => {
159
+ // Confirm the element is a grid or treegrid
160
+ const elementRole = await element.getAttribute("role");
161
+ expect(["grid", "treegrid"], { message: "Focus element doesn't have grid/treegrid role" }).toContain(elementRole!);
162
+
163
+ // Retrieve column index
164
+ const columnElement = await element.getByRole("columnheader", { name: columnName, exact: true });
165
+ const colIndex = Number(await columnElement.getAttribute("aria-colindex")) - 1;
166
+
167
+ // Double click on the cell
168
+ const rows = await element.getByRole("row", { exact: true }).all();
169
+ const cellElement = (await rows[lineNumber].getByRole("gridcell", { exact: true }).all())[colIndex];
170
+ await cellElement.dblclick();
171
+
172
+ // Type text in the cell
173
+ await this.page.locator("[aria-label=\"Input Editor\"]").type(textToType);
174
+ });
175
+ });
176
+
154
177
  /**
155
178
  * Sélectionne l'option passée en paramètre (utile par exemple pour remplir un champ le liste déroulante).<br/>Assurez vous d'avoir effectué une sélection d'élément avant avec les phrases <strong>je vais à l'intérieur de la liste déroulante nommée 'maListeDeroulante'</strong>.
156
179
  * */
@@ -642,9 +665,11 @@ Then(
642
665
  async function(expectedListName: string, pExpectedElementsOfList: DataTable) {
643
666
  const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
644
667
  await findWithRoleAndName(this, "grid", expectedListName);
668
+ await addCookie(this, COOKIE_NAME.SELECTED_ELEMENT, new SelectedElementCookie(FILTER_TYPE.SELECTOR, `role=grid[name="${expectedListName}"]`));
645
669
  await getPageOrElement(this).then(async (element) => {
646
670
  await expectTableToHaveContent(element, expectedElementsOfList, "gridcell");
647
671
  });
672
+ await deleteCookieByName(this, COOKIE_NAME.SELECTED_ELEMENT);
648
673
  }
649
674
  );
650
675
 
@@ -656,9 +681,11 @@ Then(
656
681
  async function(expectedListName: string, pExpectedElementsOfList: DataTable) {
657
682
  const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
658
683
  await findWithRoleAndName(this, "treegrid", expectedListName);
684
+ await addCookie(this, COOKIE_NAME.SELECTED_ELEMENT, new SelectedElementCookie(FILTER_TYPE.SELECTOR, `role=treegrid[name="${expectedListName}"]`));
659
685
  await getPageOrElement(this).then(async (element) => {
660
686
  await expectTableToHaveContent(element, expectedElementsOfList, "gridcell");
661
687
  });
688
+ await deleteCookieByName(this, COOKIE_NAME.SELECTED_ELEMENT);
662
689
  }
663
690
  );
664
691
 
@@ -670,9 +697,11 @@ Then(
670
697
  async function(expectedListName: string, pExpectedElementsOfList: DataTable) {
671
698
  const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
672
699
  await findWithRoleAndName(this, "table", expectedListName);
700
+ await addCookie(this, COOKIE_NAME.SELECTED_ELEMENT, new SelectedElementCookie(FILTER_TYPE.SELECTOR, `role=table[name="${expectedListName}"]`));
673
701
  await getPageOrElement(this).then(async (element) => {
674
702
  await expectTableToHaveContent(element, expectedElementsOfList, "cell");
675
703
  });
704
+ await deleteCookieByName(this, COOKIE_NAME.SELECTED_ELEMENT);
676
705
  }
677
706
  );
678
707
 
@@ -699,8 +728,8 @@ async function expectTableToHaveContent(element: Locator, expectedElementsOfList
699
728
  let cellNumber = 0;
700
729
  return await Promise.all(cellsElement.map((cell: Locator) => {
701
730
  const expectedValue = expectedElementsOfList[rowNumber][cellNumber];
702
- expect(cell, { message: `${cellAccessibleRole} at index [${rowNumber}, ${cellNumber}] should be ${expectedValue}` }).toHaveAccessibleName(expectedValue);
703
731
  cellNumber++;
732
+ return expect(cell, { message: `${cellAccessibleRole} at index [${rowNumber + 1}, ${cellNumber}] should be ${expectedValue}` }).toHaveAccessibleName(expectedValue);
704
733
  }));
705
734
  }));
706
735
  }