@o3r/testing 10.0.0-prerelease.85 → 10.0.0-prerelease.87

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.
@@ -29,7 +29,7 @@ export declare class O3rComponentFixture<V extends O3rElement = O3rElement> impl
29
29
  * @param element ElementProfile to test
30
30
  * @param timeout specific timeout that will throw when reach
31
31
  */
32
- protected throwOnUndefined<T extends O3rElement>(element: Promise<T | undefined>, timeout?: number): Promise<T>;
32
+ protected throwOnUndefined<T extends O3rElement>(element: Promise<T>, timeout?: number): Promise<T>;
33
33
  /**
34
34
  * Get the element associated to the selector if present
35
35
  * @param selector Selector to access the element
@@ -43,7 +43,7 @@ export declare class O3rComponentFixture<V extends O3rElement = O3rElement> impl
43
43
  index?: number;
44
44
  shouldThrowIfNotPresent?: boolean;
45
45
  timeout?: number;
46
- }): Promise<O3rElement | undefined>;
46
+ }): Promise<O3rElement>;
47
47
  /**
48
48
  * Get text from the element associated to the given selector, or undefined if the element is not found or not visible
49
49
  * @param selector Selector to access the element
@@ -90,11 +90,11 @@ export declare class O3rComponentFixture<V extends O3rElement = O3rElement> impl
90
90
  timeout?: number;
91
91
  }): Promise<void>;
92
92
  /** @inheritdoc */
93
- query(selector: string, returnType?: undefined): Promise<O3rElement | undefined>;
94
- query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>): Promise<T | undefined>;
93
+ query(selector: string, returnType?: undefined): Promise<O3rElement>;
94
+ query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>): Promise<T>;
95
95
  /** @inheritdoc */
96
- queryNth(selector: string, index: number, returnType?: undefined): Promise<O3rElement | undefined>;
97
- queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T>): Promise<T | undefined>;
96
+ queryNth(selector: string, index: number, returnType?: undefined): Promise<O3rElement>;
97
+ queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T>): Promise<T>;
98
98
  /** @inheritdoc */
99
99
  queryAll(_selector: string, _returnType?: undefined, groupType?: undefined, timeout?: number): Promise<O3rElement[]>;
100
100
  queryAll<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>, groupType?: undefined, timeout?: number): Promise<T[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"component-fixture.d.ts","sourceRoot":"","sources":["../../../src/core/playwright/component-fixture.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAA2B,MAAM,WAAW,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAExD,YAAY,EAAE,uBAAuB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEtG;;GAEG;AACH,qBAAa,mBAAmB,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,CAAE,YAAW,uBAAuB,CAAC,CAAC,CAAC;IAEvG;;OAEG;IACH,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;IAEzB;;;;OAIG;gBACS,WAAW,EAAE,CAAC;IAI1B;;;;;OAKG;cACa,uBAAuB,CAAC,CAAC,SAAS,UAAU,EAAE,OAAO,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAWxG;;;;;OAKG;cACa,gBAAgB,CAAC,CAAC,SAAS,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAYrH;;;;;;;;OAQG;cACa,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,kBAAkB,CAAC,EAAE,qBAAqB,CAAC,UAAU,CAAC,EACtD,OAAO,GAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,uBAAuB,CAAC,EAAE,OAAO,CA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AU,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC;IACtF,QAAQ,CAAC,CAAC,SAAS,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAQ9H,kBAAkB;IACL,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IACpH,QAAQ,CAAC,CAAC,SAAS,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,qBAAqB,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAC7I,QAAQ,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,qBAAqB,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAmC9L,kBAAkB;IACX,UAAU;IAIjB,kBAAkB;IACX,gBAAgB,IAAI,OAAO,CAAC;QAAC,CAAC,aAAa,EAAE,MAAM,GAAG,uBAAuB,EAAE,CAAA;KAAC,CAAC;IAIxF,kBAAkB;IACL,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAIjE"}
@@ -26,19 +26,15 @@ var O3rComponentFixture = /** @class */ (function () {
26
26
  */
27
27
  O3rComponentFixture.prototype.throwOnUndefinedElement = function (element, timeout) {
28
28
  return tslib_1.__awaiter(this, void 0, void 0, function () {
29
- var count;
30
29
  return tslib_1.__generator(this, function (_a) {
31
30
  switch (_a.label) {
32
31
  case 0:
33
32
  if (!element) {
34
33
  throw new Error('Element not found in ' + this.constructor.name);
35
34
  }
36
- return [4 /*yield*/, (0, helpers_1.withTimeout)(element.sourceElement.element.count(), timeout)];
35
+ return [4 /*yield*/, element.sourceElement.element.first().waitFor({ state: 'attached', timeout: timeout })];
37
36
  case 1:
38
- count = _a.sent();
39
- if (!count) {
40
- throw new Error('Element not found in ' + this.constructor.name);
41
- }
37
+ _a.sent();
42
38
  return [2 /*return*/, element];
43
39
  }
44
40
  });
@@ -54,15 +50,16 @@ var O3rComponentFixture = /** @class */ (function () {
54
50
  return tslib_1.__awaiter(this, void 0, void 0, function () {
55
51
  var _this = this;
56
52
  return tslib_1.__generator(this, function (_a) {
57
- return [2 /*return*/, (0, helpers_1.withTimeout)(element, timeout)
58
- .then(function (el) { return el === null || el === void 0 ? void 0 : el.sourceElement.element.count(); })
59
- .then(function (count) { return (count || 0) > 0; })
60
- .then(function (isPresent) {
61
- if (!isPresent) {
62
- throw new Error('Element not found in ' + _this.constructor.name);
63
- }
64
- })
65
- .then(function () { return element; })];
53
+ return [2 /*return*/, (0, helpers_1.withTimeout)(element.then(function (el) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
54
+ return tslib_1.__generator(this, function (_a) {
55
+ switch (_a.label) {
56
+ case 0: return [4 /*yield*/, el.sourceElement.element.first().waitFor({ state: 'attached' })];
57
+ case 1:
58
+ _a.sent();
59
+ return [2 /*return*/, el];
60
+ }
61
+ });
62
+ }); }), timeout)];
66
63
  });
67
64
  });
68
65
  };
@@ -112,24 +109,19 @@ var O3rComponentFixture = /** @class */ (function () {
112
109
  O3rComponentFixture.prototype.getText = function (selector, options) {
113
110
  if (options === void 0) { options = {}; }
114
111
  return tslib_1.__awaiter(this, void 0, void 0, function () {
115
- var element, _a;
116
- return tslib_1.__generator(this, function (_b) {
117
- switch (_b.label) {
112
+ var element;
113
+ return tslib_1.__generator(this, function (_a) {
114
+ switch (_a.label) {
118
115
  case 0: return [4 /*yield*/, this.queryWithOptions(selector, options.elementConstructor, options)];
119
116
  case 1:
120
- element = _b.sent();
121
- _a = !element;
122
- if (_a) return [3 /*break*/, 3];
117
+ element = _a.sent();
123
118
  return [4 /*yield*/, element.isVisible()];
124
119
  case 2:
125
- _a = !(_b.sent());
126
- _b.label = 3;
127
- case 3:
128
- if (_a) {
120
+ if (!(_a.sent())) {
129
121
  return [2 /*return*/];
130
122
  }
131
123
  return [4 /*yield*/, element.getText()];
132
- case 4: return [2 /*return*/, _b.sent()];
124
+ case 3: return [2 /*return*/, _a.sent()];
133
125
  }
134
126
  });
135
127
  });
@@ -146,19 +138,14 @@ var O3rComponentFixture = /** @class */ (function () {
146
138
  O3rComponentFixture.prototype.isVisible = function (selector, options) {
147
139
  if (options === void 0) { options = {}; }
148
140
  return tslib_1.__awaiter(this, void 0, void 0, function () {
149
- var element, _a;
150
- return tslib_1.__generator(this, function (_b) {
151
- switch (_b.label) {
141
+ var element;
142
+ return tslib_1.__generator(this, function (_a) {
143
+ switch (_a.label) {
152
144
  case 0: return [4 /*yield*/, this.queryWithOptions(selector, options.elementConstructor, options)];
153
145
  case 1:
154
- element = _b.sent();
155
- _a = !!element;
156
- if (!_a) return [3 /*break*/, 3];
146
+ element = _a.sent();
157
147
  return [4 /*yield*/, element.isVisible()];
158
- case 2:
159
- _a = (_b.sent());
160
- _b.label = 3;
161
- case 3: return [2 /*return*/, _a];
148
+ case 2: return [2 /*return*/, _a.sent()];
162
149
  }
163
150
  });
164
151
  });
@@ -175,25 +162,20 @@ var O3rComponentFixture = /** @class */ (function () {
175
162
  O3rComponentFixture.prototype.click = function (selector, options) {
176
163
  if (options === void 0) { options = {}; }
177
164
  return tslib_1.__awaiter(this, void 0, void 0, function () {
178
- var element, _a;
179
- return tslib_1.__generator(this, function (_b) {
180
- switch (_b.label) {
165
+ var element;
166
+ return tslib_1.__generator(this, function (_a) {
167
+ switch (_a.label) {
181
168
  case 0: return [4 /*yield*/, this.queryWithOptions(selector, options.elementConstructor, options)];
182
169
  case 1:
183
- element = _b.sent();
184
- _a = !!element;
185
- if (!_a) return [3 /*break*/, 3];
170
+ element = _a.sent();
186
171
  return [4 /*yield*/, element.isVisible()];
187
172
  case 2:
188
- _a = (_b.sent());
189
- _b.label = 3;
190
- case 3:
191
- if (!_a) return [3 /*break*/, 5];
173
+ if (!_a.sent()) return [3 /*break*/, 4];
192
174
  return [4 /*yield*/, element.click()];
193
- case 4:
194
- _b.sent();
195
- _b.label = 5;
196
- case 5: return [2 /*return*/];
175
+ case 3:
176
+ _a.sent();
177
+ _a.label = 4;
178
+ case 4: return [2 /*return*/];
197
179
  }
198
180
  });
199
181
  });
@@ -202,17 +184,10 @@ var O3rComponentFixture = /** @class */ (function () {
202
184
  return tslib_1.__awaiter(this, void 0, void 0, function () {
203
185
  var elements, element, selectedElement;
204
186
  return tslib_1.__generator(this, function (_a) {
205
- try {
206
- elements = this.rootElement.sourceElement.element.locator(selector);
207
- element = elements.first();
208
- selectedElement = { element: element, page: this.rootElement.sourceElement.page };
209
- return [2 /*return*/, Promise.resolve(new (returnType || element_1.O3rElement)(selectedElement))];
210
- }
211
- catch (err) {
212
- console.warn("Failed to query ".concat(selector), err);
213
- return [2 /*return*/, Promise.resolve(undefined)];
214
- }
215
- return [2 /*return*/];
187
+ elements = this.rootElement.sourceElement.element.locator(selector);
188
+ element = elements.first();
189
+ selectedElement = { element: element, page: this.rootElement.sourceElement.page };
190
+ return [2 /*return*/, Promise.resolve(new (returnType || element_1.O3rElement)(selectedElement))];
216
191
  });
217
192
  });
218
193
  };
@@ -220,16 +195,10 @@ var O3rComponentFixture = /** @class */ (function () {
220
195
  return tslib_1.__awaiter(this, void 0, void 0, function () {
221
196
  var elements, element, selectedElement;
222
197
  return tslib_1.__generator(this, function (_a) {
223
- try {
224
- elements = this.rootElement.sourceElement.element.locator(selector);
225
- element = elements.nth(index);
226
- selectedElement = { element: element, page: this.rootElement.sourceElement.page };
227
- return [2 /*return*/, Promise.resolve(new (returnType || element_1.O3rElement)(selectedElement))];
228
- }
229
- catch (_b) {
230
- return [2 /*return*/, Promise.resolve(undefined)];
231
- }
232
- return [2 /*return*/];
198
+ elements = this.rootElement.sourceElement.element.locator(selector);
199
+ element = elements.nth(index);
200
+ selectedElement = { element: element, page: this.rootElement.sourceElement.page };
201
+ return [2 /*return*/, Promise.resolve(new (returnType || element_1.O3rElement)(selectedElement))];
233
202
  });
234
203
  });
235
204
  };
@@ -1 +1 @@
1
- {"version":3,"file":"component-fixture.js","sourceRoot":"","sources":["../../../src/core/playwright/component-fixture.ts"],"names":[],"mappings":";;;;AAAA,4BAA4B;AAC5B,4CAAuD;AAEvD,sCAAyC;AACzC,qCAAuF;AAKvF;;GAEG;AACH;IAOE;;;;OAIG;IACH,6BAAY,WAAc;QACxB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACa,qDAAuB,GAAvC,UAA8D,OAAW,EAAE,OAAgB;;;;;;wBACzF,IAAI,CAAC,OAAO,EAAE;4BACZ,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;yBAClE;wBACa,qBAAM,IAAA,qBAAW,EAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,OAAO,CAAC,EAAA;;wBAAzE,KAAK,GAAG,SAAiE;wBAC/E,IAAI,CAAC,KAAK,EAAE;4BACV,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;yBAClE;wBACD,sBAAO,OAAO,EAAC;;;;KAChB;IAED;;;;;OAKG;IACa,8CAAgB,GAAhC,UAAuD,OAA+B,EAAE,OAAgB;;;;gBACtG,sBAAO,IAAA,qBAAW,EAAC,OAAO,EAAE,OAAO,CAAC;yBACjC,IAAI,CAAC,UAAC,E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AED,kBAAkB;IACX,8CAAgB,GAAvB;QACE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,CAAC,IAAI,CAAC,EAAC,CAAC,CAAC;IAC1C,CAAC;IAED,kBAAkB;IACL,6CAAe,GAA5B,UAA6B,QAAgB;;;;gBACrC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,CAAC;gBACjF,sBAAO,OAAO,CAAC,QAAQ,EAAE,EAAC;;;KAC3B;IACH,0BAAC;AAAD,CAAC,AAjOD,IAiOC;AAjOY,kDAAmB","sourcesContent":["/* eslint-disable new-cap */\nimport { FixtureUsageError } from '../../errors/index';\nimport type { ComponentFixtureProfile } from '../component-fixture';\nimport { withTimeout } from '../helpers';\nimport { O3rElement, O3rElementConstructor, PlaywrightSourceElement } from './element';\nimport { O3rGroup, O3rGroupConstructor } from './group';\n\nexport type { ComponentFixtureProfile, Constructable, FixtureWithCustom } from '../component-fixture';\n\n/**\n * Implementation of the fixture dedicated to Playwright, hence using the webdriver to interact with the dom.\n */\nexport class O3rComponentFixture<V extends O3rElement = O3rElement> implements ComponentFixtureProfile<V> {\n\n /**\n * DOM element linked to the fixture.\n */\n protected rootElement: V;\n\n /**\n * Root element of this fixture.\n * All further queries will be applied to the element tree if any, otherwise they will be applied to the whole DOM.\n * @param rootElement\n */\n constructor(rootElement: V) {\n this.rootElement = rootElement;\n }\n\n /**\n * Throws an exception if the element is undefined.\n * Otherwise returns the element.\n * @param element ElementProfile to test\n * @param timeout specific timeout that will throw when reach\n */\n protected async throwOnUndefinedElement<T extends O3rElement>(element?: T, timeout?: number): Promise<T> {\n if (!element) {\n throw new Error('Element not found in ' + this.constructor.name);\n }\n const count = await withTimeout(element.sourceElement.element.count(), timeout);\n if (!count) {\n throw new Error('Element not found in ' + this.constructor.name);\n }\n return element;\n }\n\n /**\n * Throws an exception if the element is undefined.\n * Otherwise returns the element.\n * @param element ElementProfile to test\n * @param timeout specific timeout that will throw when reach\n */\n protected async throwOnUndefined<T extends O3rElement>(element: Promise<T | undefined>, timeout?: number): Promise<T> {\n return withTimeout(element, timeout)\n .then((el) => el?.sourceElement.element.count())\n .then((count) => (count || 0) > 0)\n .then((isPresent) => {\n if (!isPresent) {\n throw new Error('Element not found in ' + this.constructor.name);\n }\n })\n .then(() => element as Promise<T>);\n }\n\n /**\n * Get the element associated to the selector if present\n * @param selector Selector to access the element\n * @param elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options Options supported\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async queryWithOptions(\n selector: string,\n elementConstructor?: O3rElementConstructor<O3rElement>,\n options: {\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}\n ): Promise<O3rElement | undefined> {\n let element: O3rElement | undefined;\n if (options.index !== undefined) {\n element = await this.queryNth(selector, options.index, elementConstructor as any);\n } else {\n element = await this.query(selector, elementConstructor as any);\n }\n if (options.shouldThrowIfNotPresent) {\n return this.throwOnUndefinedElement<O3rElement>(element, options.timeout);\n }\n return element;\n }\n\n /**\n * Get text from the element associated to the given selector, or undefined if the element is not found or not visible\n * @param selector Selector to access the element\n * @param options Options supported\n * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async getText<T extends O3rElement>(selector: string, options: {\n elementConstructor?: O3rElementConstructor<T>;\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}): Promise<string | undefined> {\n const element = await this.queryWithOptions(selector, options.elementConstructor, options);\n if (!element || !await element.isVisible()) {\n return;\n }\n return await element.getText();\n }\n\n /**\n * Check if the element associated to the given selector is visible\n * @param selector Selector to access the element\n * @param options Options supported\n * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async isVisible<T extends O3rElement>(selector: string, options: {\n elementConstructor?: O3rElementConstructor<T> | undefined;\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}): Promise<boolean> {\n const element = await this.queryWithOptions(selector, options.elementConstructor, options);\n return !!element && await element.isVisible();\n }\n\n /**\n * Click on the element associated to the given selector if it exists and is visible\n * @param selector Selector to access the element\n * @param options Options supported\n * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async click<T extends O3rElement>(selector: string, options: {\n elementConstructor?: O3rElementConstructor<T> | undefined;\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}): Promise<void> {\n const element = await this.queryWithOptions(selector, options.elementConstructor, options);\n if (!!element && await element.isVisible()) {\n await element.click();\n }\n }\n\n /** @inheritdoc */\n public async query(selector: string, returnType?: undefined): Promise<O3rElement | undefined>;\n public async query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>): Promise<T | undefined>;\n public async query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T> | undefined): Promise<T | O3rElement | undefined> {\n try {\n const elements = this.rootElement.sourceElement.element.locator(selector);\n const element = elements.first();\n const selectedElement: PlaywrightSourceElement = {element: element, page: this.rootElement.sourceElement.page};\n return Promise.resolve(new (returnType || O3rElement)(selectedElement));\n } catch (err) {\n console.warn(`Failed to query ${selector}`, err);\n return Promise.resolve(undefined);\n }\n }\n\n /** @inheritdoc */\n public async queryNth(selector: string, index: number, returnType?: undefined): Promise<O3rElement | undefined>;\n public async queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T>): Promise<T | undefined>;\n public async queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T> | undefined): Promise<T | O3rElement | undefined> {\n try {\n const elements = this.rootElement.sourceElement.element.locator(selector);\n const element = elements.nth(index);\n const selectedElement: PlaywrightSourceElement = {element: element, page: this.rootElement.sourceElement.page};\n return Promise.resolve(new (returnType || O3rElement)(selectedElement));\n } catch {\n return Promise.resolve(undefined);\n }\n }\n\n /** @inheritdoc */\n public async queryAll(_selector: string, _returnType?: undefined, groupType?: undefined, timeout?: number): Promise<O3rElement[]>;\n public async queryAll<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>, groupType?: undefined, timeout?: number): Promise<T[]>;\n public async queryAll<T extends O3rElement, K extends O3rGroup<T>>(selector: string, returnType: O3rElementConstructor<T>, groupType: O3rGroupConstructor<K, T>, timeout?: number): Promise<K>;\n public async queryAll<T extends O3rElement, K extends O3rGroup<T>>(\n selector: string,\n returnType: O3rElementConstructor<T> | undefined,\n groupType: O3rGroupConstructor<K, T> | undefined,\n timeout = 5000\n ): Promise<(T | O3rElement)[] | K> {\n try {\n const sourceElement = this.rootElement.sourceElement.element;\n const pElements = sourceElement.locator(selector);\n // Mandatory because count is not reliable if we don't wait for the list to be attached\n await pElements.first().waitFor({state: 'attached', timeout});\n const pElementsCount = await pElements.count();\n const elements = [];\n for (let i = 0; i < pElementsCount; i++) {\n const selectedElement: PlaywrightSourceElement = {element: pElements.nth(i), page: this.rootElement.sourceElement.page};\n elements.push(returnType ? new returnType(selectedElement) : new O3rElement(selectedElement));\n }\n if (groupType) {\n const group = new groupType(elements as T[]);\n const isValid = await group.isValidGroup();\n\n if (!isValid) {\n throw new FixtureUsageError('invalid group of items');\n }\n return group;\n }\n\n return elements;\n } catch (err) {\n console.warn(`Failed to query all ${selector}`, err);\n return Promise.resolve([]);\n }\n }\n\n /** @inheritdoc */\n public getElement() {\n return this.rootElement;\n }\n\n /** @inheritdoc */\n public getSubComponents(): Promise<{[componentName: string]: ComponentFixtureProfile[]}> {\n return Promise.resolve({block: [this]});\n }\n\n /** @inheritDoc */\n public async queryNotPresent(selector: string): Promise<boolean> {\n const element = this.rootElement.sourceElement.element.locator(selector).first();\n return element.isHidden();\n }\n}\n"]}
1
+ {"version":3,"file":"component-fixture.js","sourceRoot":"","sources":["../../../src/core/playwright/component-fixture.ts"],"names":[],"mappings":";;;;AAAA,4BAA4B;AAC5B,4CAAuD;AAEvD,sCAAyC;AACzC,qCAAuF;AAKvF;;GAEG;AACH;IAOE;;;;OAIG;IACH,6BAAY,WAAc;QACxB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACa,qDAAuB,GAAvC,UAA8D,OAAW,EAAE,OAAgB;;;;;wBACzF,IAAI,CAAC,OAAO,EAAE;4BACZ,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;yBAClE;wBACD,qBAAM,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,UAAU,EAAE,OAAO,SAAA,EAAC,CAAC,EAAA;;wBAAjF,SAAiF,CAAC;wBAClF,sBAAO,OAAO,EAAC;;;;KAChB;IAED;;;;;OAKG;IACa,8CAAgB,GAAhC,UAAuD,OAAmB,EAAE,OAAgB;;;;gBAC1F,sBAAO,IAAA,qBAAW,EAChB,OAAO,CAAC,IAAI,CAAC,UAAO,EAAE;;;wCACpB,qBAAM,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,UAAU,EAAC,CAAC,EAAA;;oCAAnE,SAAmE,CAAC;oCACpE,sBAAO,EAAE,EAAC;;;yBACX,CAAC,EACF,OAAO,CAAC,EAAC;;;KACZ;IAED;;;;;;;;OAQG;IACa,8CAAgB,GAAhC,UACE,QAAgB,E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BAGf,sBAAO,QAAQ,EAAC;;;wBAEhB,OAAO,CAAC,IAAI,CAAC,8BAAuB,QAAQ,CAAE,EAAE,KAAG,CAAC,CAAC;wBACrD,sBAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,EAAC;;;;;KAE9B;IAED,kBAAkB;IACX,wCAAU,GAAjB;QACE,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,kBAAkB;IACX,8CAAgB,GAAvB;QACE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,CAAC,IAAI,CAAC,EAAC,CAAC,CAAC;IAC1C,CAAC;IAED,kBAAkB;IACL,6CAAe,GAA5B,UAA6B,QAAgB;;;;gBACrC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,CAAC;gBACjF,sBAAO,OAAO,CAAC,QAAQ,EAAE,EAAC;;;KAC3B;IACH,0BAAC;AAAD,CAAC,AAlND,IAkNC;AAlNY,kDAAmB","sourcesContent":["/* eslint-disable new-cap */\nimport { FixtureUsageError } from '../../errors/index';\nimport type { ComponentFixtureProfile } from '../component-fixture';\nimport { withTimeout } from '../helpers';\nimport { O3rElement, O3rElementConstructor, PlaywrightSourceElement } from './element';\nimport { O3rGroup, O3rGroupConstructor } from './group';\n\nexport type { ComponentFixtureProfile, Constructable, FixtureWithCustom } from '../component-fixture';\n\n/**\n * Implementation of the fixture dedicated to Playwright, hence using the webdriver to interact with the dom.\n */\nexport class O3rComponentFixture<V extends O3rElement = O3rElement> implements ComponentFixtureProfile<V> {\n\n /**\n * DOM element linked to the fixture.\n */\n protected rootElement: V;\n\n /**\n * Root element of this fixture.\n * All further queries will be applied to the element tree if any, otherwise they will be applied to the whole DOM.\n * @param rootElement\n */\n constructor(rootElement: V) {\n this.rootElement = rootElement;\n }\n\n /**\n * Throws an exception if the element is undefined.\n * Otherwise returns the element.\n * @param element ElementProfile to test\n * @param timeout specific timeout that will throw when reach\n */\n protected async throwOnUndefinedElement<T extends O3rElement>(element?: T, timeout?: number): Promise<T> {\n if (!element) {\n throw new Error('Element not found in ' + this.constructor.name);\n }\n await element.sourceElement.element.first().waitFor({state: 'attached', timeout});\n return element;\n }\n\n /**\n * Throws an exception if the element is undefined.\n * Otherwise returns the element.\n * @param element ElementProfile to test\n * @param timeout specific timeout that will throw when reach\n */\n protected async throwOnUndefined<T extends O3rElement>(element: Promise<T>, timeout?: number): Promise<T> {\n return withTimeout(\n element.then(async (el) => {\n await el.sourceElement.element.first().waitFor({state: 'attached'});\n return el;\n }),\n timeout);\n }\n\n /**\n * Get the element associated to the selector if present\n * @param selector Selector to access the element\n * @param elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options Options supported\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async queryWithOptions(\n selector: string,\n elementConstructor?: O3rElementConstructor<O3rElement>,\n options: {\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}\n ): Promise<O3rElement> {\n let element: O3rElement;\n if (options.index !== undefined) {\n element = await this.queryNth(selector, options.index, elementConstructor as any);\n } else {\n element = await this.query(selector, elementConstructor as any);\n }\n if (options.shouldThrowIfNotPresent) {\n return this.throwOnUndefinedElement<O3rElement>(element, options.timeout);\n }\n return element;\n }\n\n /**\n * Get text from the element associated to the given selector, or undefined if the element is not found or not visible\n * @param selector Selector to access the element\n * @param options Options supported\n * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async getText<T extends O3rElement>(selector: string, options: {\n elementConstructor?: O3rElementConstructor<T>;\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}): Promise<string | undefined> {\n const element = await this.queryWithOptions(selector, options.elementConstructor, options);\n if (!await element.isVisible()) {\n return;\n }\n return await element.getText();\n }\n\n /**\n * Check if the element associated to the given selector is visible\n * @param selector Selector to access the element\n * @param options Options supported\n * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async isVisible<T extends O3rElement>(selector: string, options: {\n elementConstructor?: O3rElementConstructor<T> | undefined;\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}): Promise<boolean> {\n const element = await this.queryWithOptions(selector, options.elementConstructor, options);\n return await element.isVisible();\n }\n\n /**\n * Click on the element associated to the given selector if it exists and is visible\n * @param selector Selector to access the element\n * @param options Options supported\n * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async click<T extends O3rElement>(selector: string, options: {\n elementConstructor?: O3rElementConstructor<T> | undefined;\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}): Promise<void> {\n const element = await this.queryWithOptions(selector, options.elementConstructor, options);\n if (await element.isVisible()) {\n await element.click();\n }\n }\n\n /** @inheritdoc */\n public async query(selector: string, returnType?: undefined): Promise<O3rElement>;\n public async query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>): Promise<T>;\n public async query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T> | undefined): Promise<T | O3rElement> {\n const elements = this.rootElement.sourceElement.element.locator(selector);\n const element = elements.first();\n const selectedElement: PlaywrightSourceElement = {element: element, page: this.rootElement.sourceElement.page};\n return Promise.resolve(new (returnType || O3rElement)(selectedElement));\n }\n\n /** @inheritdoc */\n public async queryNth(selector: string, index: number, returnType?: undefined): Promise<O3rElement>;\n public async queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T>): Promise<T>;\n public async queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T> | undefined): Promise<T | O3rElement> {\n const elements = this.rootElement.sourceElement.element.locator(selector);\n const element = elements.nth(index);\n const selectedElement: PlaywrightSourceElement = {element: element, page: this.rootElement.sourceElement.page};\n return Promise.resolve(new (returnType || O3rElement)(selectedElement));\n }\n\n /** @inheritdoc */\n public async queryAll(_selector: string, _returnType?: undefined, groupType?: undefined, timeout?: number): Promise<O3rElement[]>;\n public async queryAll<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>, groupType?: undefined, timeout?: number): Promise<T[]>;\n public async queryAll<T extends O3rElement, K extends O3rGroup<T>>(selector: string, returnType: O3rElementConstructor<T>, groupType: O3rGroupConstructor<K, T>, timeout?: number): Promise<K>;\n public async queryAll<T extends O3rElement, K extends O3rGroup<T>>(\n selector: string,\n returnType: O3rElementConstructor<T> | undefined,\n groupType: O3rGroupConstructor<K, T> | undefined,\n timeout = 5000\n ): Promise<(T | O3rElement)[] | K> {\n try {\n const sourceElement = this.rootElement.sourceElement.element;\n const pElements = sourceElement.locator(selector);\n // Mandatory because count is not reliable if we don't wait for the list to be attached\n await pElements.first().waitFor({state: 'attached', timeout});\n const pElementsCount = await pElements.count();\n const elements = [];\n for (let i = 0; i < pElementsCount; i++) {\n const selectedElement: PlaywrightSourceElement = {element: pElements.nth(i), page: this.rootElement.sourceElement.page};\n elements.push(returnType ? new returnType(selectedElement) : new O3rElement(selectedElement));\n }\n if (groupType) {\n const group = new groupType(elements as T[]);\n const isValid = await group.isValidGroup();\n\n if (!isValid) {\n throw new FixtureUsageError('invalid group of items');\n }\n return group;\n }\n\n return elements;\n } catch (err) {\n console.warn(`Failed to query all ${selector}`, err);\n return Promise.resolve([]);\n }\n }\n\n /** @inheritdoc */\n public getElement() {\n return this.rootElement;\n }\n\n /** @inheritdoc */\n public getSubComponents(): Promise<{[componentName: string]: ComponentFixtureProfile[]}> {\n return Promise.resolve({block: [this]});\n }\n\n /** @inheritDoc */\n public async queryNotPresent(selector: string): Promise<boolean> {\n const element = this.rootElement.sourceElement.element.locator(selector).first();\n return element.isHidden();\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../../src/core/playwright/element.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,IAAI,EAAC,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAE1C;;;;GAIG;AAEH,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC;CACZ,CAAC;AAEF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,sBAE7C;AAED;;GAEG;AACH,qBAAa,UAAW,YAAW,cAAc;IAC/C,+BAA+B;IACxB,aAAa,EAAE,uBAAuB,CAAC;gBAElC,aAAa,EAAE,uBAAuB,GAAG,UAAU;IAM/D,kBAAkB;IACX,OAAO;IAId,kBAAkB;IACL,YAAY;IAIzB,kBAAkB;IACX,YAAY,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIlD,kBAAkB;IACX,SAAS;IAIhB,kBAAkB;IACL,QAAQ;IAUrB,kBAAkB;IACL,QAAQ,CAAC,KAAK,EAAE,MAAM;IASnC,kBAAkB;IACL,UAAU;IAavB,kBAAkB;IACX,KAAK;IAIZ,kBAAkB;IACX,SAAS;IAIhB,kBAAkB;IACL,YAAY,CAAC,aAAa,EAAE,MAAM;CAIhD;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,cAAc,IAAI,KAAK,aAAa,EAAE,uBAAuB,GAAG,UAAU,KAAK,CAAC,CAAC"}
1
+ {"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../../src/core/playwright/element.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,IAAI,EAAC,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAE1C;;;;GAIG;AAEH,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC;CACZ,CAAC;AAEF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,sBAE7C;AAED;;GAEG;AACH,qBAAa,UAAW,YAAW,cAAc;IAC/C,+BAA+B;IACxB,aAAa,EAAE,uBAAuB,CAAC;gBAElC,aAAa,EAAE,uBAAuB,GAAG,UAAU;IAM/D,kBAAkB;IACX,OAAO;IAId,kBAAkB;IACL,YAAY;IAIzB,kBAAkB;IACX,YAAY,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIlD,kBAAkB;IACX,SAAS;IAIhB,kBAAkB;IACL,QAAQ;IAUrB,kBAAkB;IACL,QAAQ,CAAC,KAAK,EAAE,MAAM;IAMnC,kBAAkB;IACL,UAAU;IAIvB,kBAAkB;IACX,KAAK;IAIZ,kBAAkB;IACX,SAAS;IAIhB,kBAAkB;IACL,YAAY,CAAC,aAAa,EAAE,MAAM;CAIhD;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,cAAc,IAAI,KAAK,aAAa,EAAE,uBAAuB,GAAG,UAAU,KAAK,CAAC,CAAC"}
@@ -72,17 +72,11 @@ var O3rElement = /** @class */ (function () {
72
72
  return tslib_1.__awaiter(this, void 0, void 0, function () {
73
73
  return tslib_1.__generator(this, function (_a) {
74
74
  switch (_a.label) {
75
- case 0:
76
- // Clears the value in the field
77
- return [4 /*yield*/, this.clearValue()];
75
+ case 0: return [4 /*yield*/, this.sourceElement.element.fill(input)];
78
76
  case 1:
79
- // Clears the value in the field
80
- _a.sent();
81
- return [4 /*yield*/, this.sourceElement.element.fill(input)];
82
- case 2:
83
77
  _a.sent();
84
78
  return [4 /*yield*/, this.sourceElement.element.press('Tab')];
85
- case 3:
79
+ case 2:
86
80
  _a.sent();
87
81
  return [2 /*return*/];
88
82
  }
@@ -92,30 +86,12 @@ var O3rElement = /** @class */ (function () {
92
86
  /** @inheritdoc */
93
87
  O3rElement.prototype.clearValue = function () {
94
88
  return tslib_1.__awaiter(this, void 0, void 0, function () {
95
- var currentValue, i;
96
89
  return tslib_1.__generator(this, function (_a) {
97
90
  switch (_a.label) {
98
- case 0: return [4 /*yield*/, this.getValue()];
91
+ case 0: return [4 /*yield*/, this.sourceElement.element.fill('')];
99
92
  case 1:
100
- currentValue = _a.sent();
101
- if (!(currentValue !== undefined)) return [3 /*break*/, 6];
102
- i = 0;
103
- _a.label = 2;
104
- case 2:
105
- if (!(i < currentValue.length)) return [3 /*break*/, 6];
106
- // ensure backspace deletes the value
107
- return [4 /*yield*/, this.sourceElement.element.press('ArrowRight')];
108
- case 3:
109
- // ensure backspace deletes the value
110
93
  _a.sent();
111
- return [4 /*yield*/, this.sourceElement.element.press('Backspace')];
112
- case 4:
113
- _a.sent();
114
- _a.label = 5;
115
- case 5:
116
- i++;
117
- return [3 /*break*/, 2];
118
- case 6: return [2 /*return*/];
94
+ return [2 /*return*/];
119
95
  }
120
96
  });
121
97
  });
@@ -1 +1 @@
1
- {"version":3,"file":"element.js","sourceRoot":"","sources":["../../../src/core/playwright/element.ts"],"names":[],"mappings":";;;;AAgBA;;;GAGG;AACH,SAAgB,YAAY,CAAC,SAAiB;IAC5C,OAAO,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS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SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EAAC;;;;KACnD;IACH,iBAAC;AAAD,CAAC,AAhFD,IAgFC;AAhFY,gCAAU","sourcesContent":["import type {Locator, Page} from '@playwright/test';\nimport {ElementProfile} from '../element';\n\nexport {ElementProfile} from '../element';\n\n/**\n * Playwright type for source element\n * @param element is the DOM element\n * @param page is the tab in the browser where the test is run\n */\n\nexport type PlaywrightSourceElement = {\n element: Locator;\n page: Page;\n};\n\n/**\n * Remove text formatting (endline etc.) and return the content.\n * @param innerText\n */\nexport function getPlainText(innerText: string) {\n return innerText ? innerText.replace(/(?:\\r\\n|\\r|\\n)/g, ' ').replace(/\\s\\s+/g, ' ').trim() : undefined;\n}\n\n/**\n * Implementation dedicated to Playwright.\n */\nexport class O3rElement implements ElementProfile {\n /** Playwright sourceElement */\n public sourceElement: PlaywrightSourceElement;\n\n constructor(sourceElement: PlaywrightSourceElement | O3rElement) {\n this.sourceElement = sourceElement instanceof O3rElement\n ? {element: sourceElement.sourceElement.element, page: sourceElement.sourceElement.page}\n : sourceElement;\n }\n\n /** @inheritdoc */\n public getText() {\n return this.sourceElement.element.innerText();\n }\n\n /** @inheritdoc */\n public async getPlainText() {\n return getPlainText(await this.getText());\n }\n\n /** @inheritdoc */\n public getInnerHTML(): Promise<string | undefined> {\n return this.sourceElement.element.innerHTML();\n }\n\n /** @inheritdoc */\n public mouseOver() {\n return this.sourceElement.element.hover();\n }\n\n /** @inheritdoc */\n public async getValue() {\n try {\n return await this.sourceElement.element.inputValue();\n } catch (error) {\n console.warn('Failed to retrieve input value');\n const valueByAttribute = await this.sourceElement.element.getAttribute('value');\n return valueByAttribute !== null ? valueByAttribute : undefined;\n }\n }\n\n /** @inheritdoc */\n public async setValue(input: string) {\n // Clears the value in the field\n await this.clearValue();\n\n await this.sourceElement.element.fill(input);\n\n await this.sourceElement.element.press('Tab');\n }\n\n /** @inheritdoc */\n public async clearValue() {\n const currentValue = await this.getValue();\n\n if (currentValue !== undefined) {\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let i = 0; i < currentValue.length; i++) {\n // ensure backspace deletes the value\n await this.sourceElement.element.press('ArrowRight');\n await this.sourceElement.element.press('Backspace');\n }\n }\n }\n\n /** @inheritdoc */\n public click() {\n return this.sourceElement.element.click();\n }\n\n /** @inheritdoc */\n public isVisible() {\n return this.sourceElement.element.isVisible();\n }\n\n /** @inheritdoc */\n public async getAttribute(attributeName: string) {\n const attribute = await this.sourceElement.element.getAttribute(attributeName);\n return attribute !== null ? attribute : undefined;\n }\n}\n\n/**\n * Constructor of a O3rElement\n */\nexport type O3rElementConstructor<T extends ElementProfile> = new (sourceElement: PlaywrightSourceElement | O3rElement) => T;\n"]}
1
+ {"version":3,"file":"element.js","sourceRoot":"","sources":["../../../src/core/playwright/element.ts"],"names":[],"mappings":";;;;AAgBA;;;GAGG;AACH,SAAgB,YAAY,CAAC,SAAiB;IAC5C,OAAO,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACzG,CAAC;AAFD,oCAEC;AAED;;GAEG;AACH;IAIE,oBAAY,aAAmD;QAC7D,IAAI,CAAC,aAAa,GAAG,aAAa,YAAY,UAAU;YACtD,CAAC,CAAC,EAAC,OAAO,EAAE,aAAa,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,EAAE,aAAa,CAAC,aAAa,CAAC,IAAI,EAAC;YACxF,CAAC,CAAC,aAAa,CAAC;IACpB,CAAC;IAED,kBAAkB;IACX,4BAAO,GAAd;QACE,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;IAChD,CAAC;IAED,kBAAkB;IACL,iCAAY,GAAzB;;;;;;wBACS,KAAA,YAAY,CAAA;wBAAC,qBAAM,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C,CAAC;IAED,kBAAkB;IACX,8BAAS,GAAhB;QACE,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;IAChD,CAAC;IAED,kBAAkB;IACL,iCAAY,GAAzB,UAA0B,aAAqB;;;;;4BAC3B,qBAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,EAAA;;wBAAxE,SAAS,GAAG,SAA4D;wBAC9E,sBAAO,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EAAC;;;;KACnD;IACH,iBAAC;AAAD,CAAC,AApED,IAoEC;AApEY,gCAAU","sourcesContent":["import type {Locator, Page} from '@playwright/test';\nimport {ElementProfile} from '../element';\n\nexport {ElementProfile} from '../element';\n\n/**\n * Playwright type for source element\n * @param element is the DOM element\n * @param page is the tab in the browser where the test is run\n */\n\nexport type PlaywrightSourceElement = {\n element: Locator;\n page: Page;\n};\n\n/**\n * Remove text formatting (endline etc.) and return the content.\n * @param innerText\n */\nexport function getPlainText(innerText: string) {\n return innerText ? innerText.replace(/(?:\\r\\n|\\r|\\n)/g, ' ').replace(/\\s\\s+/g, ' ').trim() : undefined;\n}\n\n/**\n * Implementation dedicated to Playwright.\n */\nexport class O3rElement implements ElementProfile {\n /** Playwright sourceElement */\n public sourceElement: PlaywrightSourceElement;\n\n constructor(sourceElement: PlaywrightSourceElement | O3rElement) {\n this.sourceElement = sourceElement instanceof O3rElement\n ? {element: sourceElement.sourceElement.element, page: sourceElement.sourceElement.page}\n : sourceElement;\n }\n\n /** @inheritdoc */\n public getText() {\n return this.sourceElement.element.innerText();\n }\n\n /** @inheritdoc */\n public async getPlainText() {\n return getPlainText(await this.getText());\n }\n\n /** @inheritdoc */\n public getInnerHTML(): Promise<string | undefined> {\n return this.sourceElement.element.innerHTML();\n }\n\n /** @inheritdoc */\n public mouseOver() {\n return this.sourceElement.element.hover();\n }\n\n /** @inheritdoc */\n public async getValue() {\n try {\n return await this.sourceElement.element.inputValue();\n } catch (error) {\n console.warn('Failed to retrieve input value');\n const valueByAttribute = await this.sourceElement.element.getAttribute('value');\n return valueByAttribute !== null ? valueByAttribute : undefined;\n }\n }\n\n /** @inheritdoc */\n public async setValue(input: string) {\n await this.sourceElement.element.fill(input);\n\n await this.sourceElement.element.press('Tab');\n }\n\n /** @inheritdoc */\n public async clearValue() {\n await this.sourceElement.element.fill('');\n }\n\n /** @inheritdoc */\n public click() {\n return this.sourceElement.element.click();\n }\n\n /** @inheritdoc */\n public isVisible() {\n return this.sourceElement.element.isVisible();\n }\n\n /** @inheritdoc */\n public async getAttribute(attributeName: string) {\n const attribute = await this.sourceElement.element.getAttribute(attributeName);\n return attribute !== null ? attribute : undefined;\n }\n}\n\n/**\n * Constructor of a O3rElement\n */\nexport type O3rElementConstructor<T extends ElementProfile> = new (sourceElement: PlaywrightSourceElement | O3rElement) => T;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o3r/testing",
3
- "version": "10.0.0-prerelease.85",
3
+ "version": "10.0.0-prerelease.87",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -106,9 +106,9 @@
106
106
  "@angular/platform-browser": "~17.0.2",
107
107
  "@ngrx/store": "~17.1.0",
108
108
  "@ngx-translate/core": "~15.0.0",
109
- "@o3r/core": "^10.0.0-prerelease.85",
110
- "@o3r/localization": "^10.0.0-prerelease.85",
111
- "@o3r/schematics": "^10.0.0-prerelease.85",
109
+ "@o3r/core": "^10.0.0-prerelease.87",
110
+ "@o3r/localization": "^10.0.0-prerelease.87",
111
+ "@o3r/schematics": "^10.0.0-prerelease.87",
112
112
  "@playwright/test": "~1.41.0",
113
113
  "@schematics/angular": "~17.0.0",
114
114
  "pixelmatch": "^5.2.1",
@@ -182,12 +182,12 @@
182
182
  "@ngx-translate/core": "~15.0.0",
183
183
  "@nx/eslint-plugin": "~18.0.2",
184
184
  "@nx/jest": "~18.0.2",
185
- "@o3r/build-helpers": "^10.0.0-prerelease.85",
186
- "@o3r/core": "^10.0.0-prerelease.85",
187
- "@o3r/eslint-plugin": "^10.0.0-prerelease.85",
188
- "@o3r/localization": "^10.0.0-prerelease.85",
189
- "@o3r/schematics": "^10.0.0-prerelease.85",
190
- "@o3r/test-helpers": "^10.0.0-prerelease.85",
185
+ "@o3r/build-helpers": "^10.0.0-prerelease.87",
186
+ "@o3r/core": "^10.0.0-prerelease.87",
187
+ "@o3r/eslint-plugin": "^10.0.0-prerelease.87",
188
+ "@o3r/localization": "^10.0.0-prerelease.87",
189
+ "@o3r/schematics": "^10.0.0-prerelease.87",
190
+ "@o3r/test-helpers": "^10.0.0-prerelease.87",
191
191
  "@playwright/test": "~1.41.0",
192
192
  "@schematics/angular": "~17.0.3",
193
193
  "@stylistic/eslint-plugin-ts": "^1.5.4",