@amanat-qa/ui-core 2.0.3 → 2.1.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.
- package/dist/elements/baseElement.js +87 -66
- package/package.json +2 -2
|
@@ -6,19 +6,19 @@ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o =
|
|
|
6
6
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
7
7
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
8
8
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
|
-
function
|
|
9
|
+
function _classPrivateFieldLooseBase2(e, t) { if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance"); return e; }
|
|
10
10
|
var id = 0;
|
|
11
11
|
function _classPrivateFieldLooseKey(e) { return "__private_" + id++ + "_" + e; }
|
|
12
12
|
require('cypress-xpath');
|
|
13
13
|
var _require = require('@amanat-qa/utils-frontend'),
|
|
14
14
|
Randomizer = _require.Randomizer;
|
|
15
15
|
var XPATH = require('../locators/baseLocatorChildren/XPATH');
|
|
16
|
-
var
|
|
16
|
+
var _elementName2 = /*#__PURE__*/_classPrivateFieldLooseKey("elementName");
|
|
17
17
|
var _elementLocator = /*#__PURE__*/_classPrivateFieldLooseKey("elementLocator");
|
|
18
18
|
var BaseElement = /*#__PURE__*/function () {
|
|
19
19
|
function BaseElement(elementLocator, elementName) {
|
|
20
20
|
_classCallCheck(this, BaseElement);
|
|
21
|
-
Object.defineProperty(this,
|
|
21
|
+
Object.defineProperty(this, _elementName2, {
|
|
22
22
|
writable: true,
|
|
23
23
|
value: void 0
|
|
24
24
|
});
|
|
@@ -26,37 +26,37 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
26
26
|
writable: true,
|
|
27
27
|
value: void 0
|
|
28
28
|
});
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
_classPrivateFieldLooseBase2(this, _elementLocator)[_elementLocator] = elementLocator;
|
|
30
|
+
_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2] = elementName;
|
|
31
31
|
}
|
|
32
32
|
return _createClass(BaseElement, [{
|
|
33
33
|
key: "getElement",
|
|
34
34
|
value: function getElement(locator) {
|
|
35
35
|
var elementLocator = locator;
|
|
36
|
-
if (!elementLocator) elementLocator =
|
|
36
|
+
if (!elementLocator) elementLocator = _classPrivateFieldLooseBase2(this, _elementLocator)[_elementLocator];
|
|
37
37
|
return elementLocator instanceof XPATH ? cy.xpath(elementLocator.value).first() : cy.get(elementLocator.value).first();
|
|
38
38
|
}
|
|
39
39
|
}, {
|
|
40
40
|
key: "getElements",
|
|
41
41
|
value: function getElements() {
|
|
42
|
-
return
|
|
42
|
+
return _classPrivateFieldLooseBase2(this, _elementLocator)[_elementLocator] instanceof XPATH ? cy.xpath(_classPrivateFieldLooseBase2(this, _elementLocator)[_elementLocator].value) : cy.get(_classPrivateFieldLooseBase2(this, _elementLocator)[_elementLocator].value);
|
|
43
43
|
}
|
|
44
44
|
}, {
|
|
45
45
|
key: "clickElement",
|
|
46
46
|
value: function clickElement() {
|
|
47
|
-
cy.logger("[inf] \u25B6 click ".concat(
|
|
47
|
+
cy.logger("[inf] \u25B6 click ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2]));
|
|
48
48
|
return this.getElement().click();
|
|
49
49
|
}
|
|
50
50
|
}, {
|
|
51
51
|
key: "focusOnElement",
|
|
52
52
|
value: function focusOnElement() {
|
|
53
|
-
cy.logger("[inf] \u25B6 focus on ".concat(
|
|
53
|
+
cy.logger("[inf] \u25B6 focus on ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2]));
|
|
54
54
|
return this.getElement().focus();
|
|
55
55
|
}
|
|
56
56
|
}, {
|
|
57
57
|
key: "forceClickElement",
|
|
58
58
|
value: function forceClickElement() {
|
|
59
|
-
cy.logger("[inf] \u25B6 force click ".concat(
|
|
59
|
+
cy.logger("[inf] \u25B6 force click ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2]));
|
|
60
60
|
return this.getElement().click({
|
|
61
61
|
force: true
|
|
62
62
|
});
|
|
@@ -64,25 +64,25 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
64
64
|
}, {
|
|
65
65
|
key: "doubleClickElement",
|
|
66
66
|
value: function doubleClickElement() {
|
|
67
|
-
cy.logger("[inf] \u25B6 double click ".concat(
|
|
67
|
+
cy.logger("[inf] \u25B6 double click ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2]));
|
|
68
68
|
this.getElement().dblclick();
|
|
69
69
|
}
|
|
70
70
|
}, {
|
|
71
71
|
key: "multipleClickElement",
|
|
72
72
|
value: function multipleClickElement(count) {
|
|
73
|
-
cy.logger("[inf] \u25B6 click ".concat(
|
|
73
|
+
cy.logger("[inf] \u25B6 click ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2], " ").concat(count, " times"));
|
|
74
74
|
this.getElement().clicks(count);
|
|
75
75
|
}
|
|
76
76
|
}, {
|
|
77
77
|
key: "clickElementFromList",
|
|
78
78
|
value: function clickElementFromList(index) {
|
|
79
|
-
cy.logger("[inf] \u25B6 click element from ".concat(
|
|
79
|
+
cy.logger("[inf] \u25B6 click element from ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2]));
|
|
80
80
|
this.getElements()[index].click();
|
|
81
81
|
}
|
|
82
82
|
}, {
|
|
83
83
|
key: "getText",
|
|
84
84
|
value: function getText() {
|
|
85
|
-
cy.logger("[inf] \u25B6 get ".concat(
|
|
85
|
+
cy.logger("[inf] \u25B6 get ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2], " text:"));
|
|
86
86
|
this.getElement().then(function ($el) {
|
|
87
87
|
return cy.logger("[inf] text contains: \"".concat($el.text(), "\""));
|
|
88
88
|
});
|
|
@@ -93,7 +93,7 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
93
93
|
}, {
|
|
94
94
|
key: "getValue",
|
|
95
95
|
value: function getValue() {
|
|
96
|
-
cy.logger("[inf] \u25B6 get ".concat(
|
|
96
|
+
cy.logger("[inf] \u25B6 get ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2], " value:"));
|
|
97
97
|
this.getElement().then(function ($el) {
|
|
98
98
|
return cy.logger("[inf] value is: \"".concat($el.val(), "\""));
|
|
99
99
|
});
|
|
@@ -113,7 +113,7 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
113
113
|
key: "getAttributeValue",
|
|
114
114
|
value: function getAttributeValue(_ref2) {
|
|
115
115
|
var attrName = _ref2.attrName;
|
|
116
|
-
cy.logger("[inf] \u25B6 get ".concat(
|
|
116
|
+
cy.logger("[inf] \u25B6 get ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2], " attribute \"").concat(attrName, "\" value:"));
|
|
117
117
|
return this.getElement().invoke('attr', attrName).then(function (value) {
|
|
118
118
|
cy.logger("[inf] attribute value contains: \"".concat(value, "\""));
|
|
119
119
|
return cy.wrap(value);
|
|
@@ -122,7 +122,7 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
122
122
|
}, {
|
|
123
123
|
key: "scrollElementToView",
|
|
124
124
|
value: function scrollElementToView() {
|
|
125
|
-
cy.logger("[inf] \u25B6 scroll to ".concat(
|
|
125
|
+
cy.logger("[inf] \u25B6 scroll to ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2]));
|
|
126
126
|
this.getElement().scrollIntoView({
|
|
127
127
|
offset: {
|
|
128
128
|
top: -150,
|
|
@@ -133,7 +133,7 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
133
133
|
}, {
|
|
134
134
|
key: "clearData",
|
|
135
135
|
value: function clearData() {
|
|
136
|
-
cy.logger("[inf] \u25B6 clear ".concat(
|
|
136
|
+
cy.logger("[inf] \u25B6 clear ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2]));
|
|
137
137
|
this.getElement().clear();
|
|
138
138
|
}
|
|
139
139
|
}, {
|
|
@@ -142,7 +142,7 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
142
142
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
143
143
|
useCypressRealEvents: false
|
|
144
144
|
};
|
|
145
|
-
cy.logger("[inf] \u25B6 input ".concat(
|
|
145
|
+
cy.logger("[inf] \u25B6 input ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2]));
|
|
146
146
|
if (options.useCypressRealEvents) {
|
|
147
147
|
this.getElement().click();
|
|
148
148
|
cy.realType(data);
|
|
@@ -153,7 +153,7 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
153
153
|
}, {
|
|
154
154
|
key: "forceInputData",
|
|
155
155
|
value: function forceInputData(data) {
|
|
156
|
-
cy.logger("[inf] \u25B6 force input ".concat(
|
|
156
|
+
cy.logger("[inf] \u25B6 force input ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2]));
|
|
157
157
|
this.getElement().type(data, {
|
|
158
158
|
force: true
|
|
159
159
|
});
|
|
@@ -161,7 +161,7 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
161
161
|
}, {
|
|
162
162
|
key: "fillInputField",
|
|
163
163
|
value: function fillInputField(data) {
|
|
164
|
-
cy.logger("[inf] \u25B6 fill input data into ".concat(
|
|
164
|
+
cy.logger("[inf] \u25B6 fill input data into ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2]));
|
|
165
165
|
this.getElement().fill(data, {
|
|
166
166
|
overwrite: false,
|
|
167
167
|
prepend: true
|
|
@@ -170,13 +170,13 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
170
170
|
}, {
|
|
171
171
|
key: "enterData",
|
|
172
172
|
value: function enterData(data) {
|
|
173
|
-
cy.logger("[inf] \u25B6 input ".concat(
|
|
173
|
+
cy.logger("[inf] \u25B6 input ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2], " and submit"));
|
|
174
174
|
this.getElement().type("".concat(data, "{enter}"));
|
|
175
175
|
}
|
|
176
176
|
}, {
|
|
177
177
|
key: "uploadFile",
|
|
178
178
|
value: function uploadFile(path) {
|
|
179
|
-
cy.logger("[inf] \u25B6 upload file with ".concat(
|
|
179
|
+
cy.logger("[inf] \u25B6 upload file with ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2]));
|
|
180
180
|
this.getElement().selectFile(path, {
|
|
181
181
|
force: true
|
|
182
182
|
});
|
|
@@ -189,28 +189,28 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
189
189
|
}, {
|
|
190
190
|
key: "elementIsExisting",
|
|
191
191
|
value: function elementIsExisting() {
|
|
192
|
-
return cy.isExisting(
|
|
192
|
+
return cy.isExisting(_classPrivateFieldLooseBase2(this, _elementLocator)[_elementLocator].value);
|
|
193
193
|
}
|
|
194
194
|
}, {
|
|
195
195
|
key: "waitElementIsExisting",
|
|
196
196
|
value: function waitElementIsExisting() {
|
|
197
|
-
return cy.waitIsExisting(
|
|
197
|
+
return cy.waitIsExisting(_classPrivateFieldLooseBase2(this, _elementLocator)[_elementLocator].value);
|
|
198
198
|
}
|
|
199
199
|
}, {
|
|
200
200
|
key: "waitElementIsNotExisting",
|
|
201
201
|
value: function waitElementIsNotExisting() {
|
|
202
|
-
return cy.waitIsNotExisting(
|
|
202
|
+
return cy.waitIsNotExisting(_classPrivateFieldLooseBase2(this, _elementLocator)[_elementLocator].value);
|
|
203
203
|
}
|
|
204
204
|
}, {
|
|
205
205
|
key: "elementIsDisplayed",
|
|
206
206
|
value: function elementIsDisplayed() {
|
|
207
|
-
var
|
|
208
|
-
cy.logger("[inf] \u25B6 check ".concat(
|
|
207
|
+
var _this2 = this;
|
|
208
|
+
cy.logger("[inf] \u25B6 check ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2], " is displayed:"));
|
|
209
209
|
return this.elementIsExisting().then(function (isExisting) {
|
|
210
|
-
var notDisplayedLog = "[inf] ".concat(
|
|
210
|
+
var notDisplayedLog = "[inf] ".concat(_classPrivateFieldLooseBase2(_this2, _elementName2)[_elementName2], " is not displayed");
|
|
211
211
|
if (isExisting) {
|
|
212
|
-
return
|
|
213
|
-
cy.logger(isVisible ? "[inf] ".concat(
|
|
212
|
+
return _this2.elementIsVisible().then(function (isVisible) {
|
|
213
|
+
cy.logger(isVisible ? "[inf] ".concat(_classPrivateFieldLooseBase2(_this2, _elementName2)[_elementName2], " is displayed") : notDisplayedLog);
|
|
214
214
|
return cy.wrap(isVisible);
|
|
215
215
|
});
|
|
216
216
|
}
|
|
@@ -221,13 +221,13 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
221
221
|
}, {
|
|
222
222
|
key: "waitElementIsDisplayed",
|
|
223
223
|
value: function waitElementIsDisplayed() {
|
|
224
|
-
var
|
|
225
|
-
cy.logger("[inf] \u25B6 wait ".concat(
|
|
224
|
+
var _this3 = this;
|
|
225
|
+
cy.logger("[inf] \u25B6 wait ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2], " is displayed:"));
|
|
226
226
|
return this.waitElementIsExisting().then(function (isExisting) {
|
|
227
|
-
var notDisplayedLog = "[inf] ".concat(
|
|
227
|
+
var notDisplayedLog = "[inf] ".concat(_classPrivateFieldLooseBase2(_this3, _elementName2)[_elementName2], " is not displayed");
|
|
228
228
|
if (isExisting) {
|
|
229
|
-
return
|
|
230
|
-
cy.logger(isVisible ? "[inf] ".concat(
|
|
229
|
+
return _this3.elementIsVisible().then(function (isVisible) {
|
|
230
|
+
cy.logger(isVisible ? "[inf] ".concat(_classPrivateFieldLooseBase2(_this3, _elementName2)[_elementName2], " is displayed") : notDisplayedLog);
|
|
231
231
|
return cy.wrap(isVisible);
|
|
232
232
|
});
|
|
233
233
|
}
|
|
@@ -238,13 +238,13 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
238
238
|
}, {
|
|
239
239
|
key: "waitElementIsNotDisplayed",
|
|
240
240
|
value: function waitElementIsNotDisplayed() {
|
|
241
|
-
var
|
|
242
|
-
cy.logger("[inf] \u25B6 wait ".concat(
|
|
241
|
+
var _this4 = this;
|
|
242
|
+
cy.logger("[inf] \u25B6 wait ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2], " is not displayed:"));
|
|
243
243
|
return this.waitElementIsNotExisting().then(function (isExisting) {
|
|
244
|
-
var displayedLog = "[inf] ".concat(
|
|
244
|
+
var displayedLog = "[inf] ".concat(_classPrivateFieldLooseBase2(_this4, _elementName2)[_elementName2], " is displayed");
|
|
245
245
|
if (!isExisting) {
|
|
246
|
-
return
|
|
247
|
-
cy.logger(!isVisible ? "[inf] ".concat(
|
|
246
|
+
return _this4.elementIsVisible().then(function (isVisible) {
|
|
247
|
+
cy.logger(!isVisible ? "[inf] ".concat(_classPrivateFieldLooseBase2(_this4, _elementName2)[_elementName2], " is not displayed") : displayedLog);
|
|
248
248
|
return cy.wrap(isVisible);
|
|
249
249
|
});
|
|
250
250
|
}
|
|
@@ -255,30 +255,30 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
255
255
|
}, {
|
|
256
256
|
key: "elementIsEnabled",
|
|
257
257
|
value: function elementIsEnabled() {
|
|
258
|
-
var
|
|
259
|
-
cy.logger("[inf] \u25B6 check ".concat(
|
|
258
|
+
var _this5 = this;
|
|
259
|
+
cy.logger("[inf] \u25B6 check ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2], " is enabled:"));
|
|
260
260
|
return this.getElement().isEnabled().then(function (isEnabled) {
|
|
261
|
-
cy.logger(isEnabled ? "[inf] ".concat(
|
|
261
|
+
cy.logger(isEnabled ? "[inf] ".concat(_classPrivateFieldLooseBase2(_this5, _elementName2)[_elementName2], " is enabled") : "[inf] ".concat(_classPrivateFieldLooseBase2(_this5, _elementName2)[_elementName2], " is not enabled"));
|
|
262
262
|
return cy.wrap(isEnabled);
|
|
263
263
|
});
|
|
264
264
|
}
|
|
265
265
|
}, {
|
|
266
266
|
key: "waitElementIsEnabled",
|
|
267
267
|
value: function waitElementIsEnabled() {
|
|
268
|
-
var
|
|
269
|
-
cy.logger("[inf] \u25B6 wait ".concat(
|
|
268
|
+
var _this6 = this;
|
|
269
|
+
cy.logger("[inf] \u25B6 wait ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2], " is enabled:"));
|
|
270
270
|
return this.getElement().waitIsEnabled().then(function (isEnabled) {
|
|
271
|
-
cy.logger(isEnabled ? "[inf] ".concat(
|
|
271
|
+
cy.logger(isEnabled ? "[inf] ".concat(_classPrivateFieldLooseBase2(_this6, _elementName2)[_elementName2], " is enabled") : "[inf] ".concat(_classPrivateFieldLooseBase2(_this6, _elementName2)[_elementName2], " is not enabled"));
|
|
272
272
|
return cy.wrap(isEnabled);
|
|
273
273
|
});
|
|
274
274
|
}
|
|
275
275
|
}, {
|
|
276
276
|
key: "waitElementIsNotEnabled",
|
|
277
277
|
value: function waitElementIsNotEnabled() {
|
|
278
|
-
var
|
|
279
|
-
cy.logger("[inf] \u25B6 wait ".concat(
|
|
278
|
+
var _this7 = this;
|
|
279
|
+
cy.logger("[inf] \u25B6 wait ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2], " is not enabled:"));
|
|
280
280
|
return this.getElement().waitIsNotEnabled().then(function (isEnabled) {
|
|
281
|
-
cy.logger(!isEnabled ? "[inf] ".concat(
|
|
281
|
+
cy.logger(!isEnabled ? "[inf] ".concat(_classPrivateFieldLooseBase2(_this7, _elementName2)[_elementName2], " is not enabled") : "[inf] ".concat(_classPrivateFieldLooseBase2(_this7, _elementName2)[_elementName2], " is enabled"));
|
|
282
282
|
return cy.wrap(isEnabled);
|
|
283
283
|
});
|
|
284
284
|
}
|
|
@@ -304,17 +304,17 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
304
304
|
_options$count,
|
|
305
305
|
_options$typeAndEnter,
|
|
306
306
|
_options$exceptionEle,
|
|
307
|
-
|
|
307
|
+
_this8 = this;
|
|
308
308
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
309
309
|
var valuesListPromise = (_options$valuesListPr = options.valuesListPromise) !== null && _options$valuesListPr !== void 0 ? _options$valuesListPr : null;
|
|
310
310
|
var count = (_options$count = options.count) !== null && _options$count !== void 0 ? _options$count : 1;
|
|
311
311
|
var typeAndEnter = (_options$typeAndEnter = options.typeAndEnter) !== null && _options$typeAndEnter !== void 0 ? _options$typeAndEnter : false;
|
|
312
312
|
var exceptionElementsList = (_options$exceptionEle = options.exceptionElementsList) !== null && _options$exceptionEle !== void 0 ? _options$exceptionEle : [];
|
|
313
|
-
this.getElement(
|
|
313
|
+
this.getElement(_classPrivateFieldLooseBase2(this, _elementLocator)[_elementLocator]).click();
|
|
314
314
|
var exceptionsTextList = [];
|
|
315
315
|
if (exceptionElementsList.length !== 0) {
|
|
316
316
|
exceptionElementsList.forEach(function (element) {
|
|
317
|
-
return
|
|
317
|
+
return _this8.getElement(_classPrivateFieldLooseBase2(element, _elementLocator)[_elementLocator]).then(function ($el) {
|
|
318
318
|
return exceptionsTextList.push($el.text());
|
|
319
319
|
});
|
|
320
320
|
});
|
|
@@ -326,8 +326,8 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
326
326
|
}
|
|
327
327
|
valuesListPromise.then(function (elementsTextList) {
|
|
328
328
|
for (var counter = 0; counter < count; counter += 1) {
|
|
329
|
-
cy.logger("[inf] \u25B6 click ".concat(
|
|
330
|
-
cy.logger("[inf] \u25B6 get random element from ".concat(
|
|
329
|
+
cy.logger("[inf] \u25B6 click ".concat(_classPrivateFieldLooseBase2(dropdownElement, _elementName2)[_elementName2]));
|
|
330
|
+
cy.logger("[inf] \u25B6 get random element from ".concat(_classPrivateFieldLooseBase2(_this8, _elementName2)[_elementName2]));
|
|
331
331
|
var randomElementText = Randomizer.getRandomElementByText(elementsTextList, exceptionsTextList);
|
|
332
332
|
exceptionsTextList.push(randomElementText);
|
|
333
333
|
dropdownElement.chooseElementFromDropdown(randomElementText, typeAndEnter);
|
|
@@ -341,7 +341,7 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
341
341
|
}, {
|
|
342
342
|
key: "clickRandomRadiobuttonsOrCheckboxesByText",
|
|
343
343
|
value: function clickRandomRadiobuttonsOrCheckboxesByText(_ref3) {
|
|
344
|
-
var
|
|
344
|
+
var _this9 = this;
|
|
345
345
|
var inputElementType = _ref3.inputElementType,
|
|
346
346
|
parentOfLabelTag = _ref3.parentOfLabelTag,
|
|
347
347
|
_ref3$randomCount = _ref3.randomCount,
|
|
@@ -357,13 +357,13 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
357
357
|
var exceptionsTextList = [];
|
|
358
358
|
if (exceptionsElements.length !== 0) {
|
|
359
359
|
exceptionsElements.forEach(function (element) {
|
|
360
|
-
return
|
|
360
|
+
return _this9.getElement(_classPrivateFieldLooseBase2(element, _elementLocator)[_elementLocator]).then(function ($el) {
|
|
361
361
|
return exceptionsTextList.push($el.text());
|
|
362
362
|
});
|
|
363
363
|
});
|
|
364
364
|
}
|
|
365
365
|
for (var counter = 0; counter < count; counter += 1) {
|
|
366
|
-
cy.logger("[inf] \u25B6 get random element from ".concat(
|
|
366
|
+
cy.logger("[inf] \u25B6 get random element from ".concat(_classPrivateFieldLooseBase2(_this9, _elementName2)[_elementName2]));
|
|
367
367
|
var randomElementText = Randomizer.getRandomElementByText(elementsTextList, exceptionsTextList);
|
|
368
368
|
exceptionsTextList.push(randomElementText);
|
|
369
369
|
cy.logger("[inf] \u25B6 click ".concat(randomElementText));
|
|
@@ -376,11 +376,11 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
376
376
|
}, {
|
|
377
377
|
key: "openCalendarAndFlipMonths",
|
|
378
378
|
value: function openCalendarAndFlipMonths(rightArrowElement, monthIncrement) {
|
|
379
|
-
cy.logger("[inf] \u25B6 click ".concat(
|
|
379
|
+
cy.logger("[inf] \u25B6 click ".concat(_classPrivateFieldLooseBase2(this, _elementName2)[_elementName2]));
|
|
380
380
|
this.getElement().clicks(4);
|
|
381
381
|
for (var i = 0; i < monthIncrement; i += 1) {
|
|
382
|
-
cy.logger("[inf] \u25B6 click ".concat(
|
|
383
|
-
this.getElement(
|
|
382
|
+
cy.logger("[inf] \u25B6 click ".concat(_classPrivateFieldLooseBase2(rightArrowElement, _elementName2)[_elementName2]));
|
|
383
|
+
this.getElement(_classPrivateFieldLooseBase2(rightArrowElement, _elementLocator)[_elementLocator]).click({
|
|
384
384
|
force: true
|
|
385
385
|
});
|
|
386
386
|
}
|
|
@@ -402,18 +402,18 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
402
402
|
}, {
|
|
403
403
|
key: "createListOfElements",
|
|
404
404
|
value: function createListOfElements(dropdownElement) {
|
|
405
|
-
var
|
|
405
|
+
var _this0 = this;
|
|
406
406
|
var elements = [];
|
|
407
|
-
this.getElement(
|
|
407
|
+
this.getElement(_classPrivateFieldLooseBase2(dropdownElement, _elementLocator)[_elementLocator]).click();
|
|
408
408
|
return this.getElement().then(function (element) {
|
|
409
409
|
elements.push(element.text());
|
|
410
|
-
return
|
|
410
|
+
return _this0.iterateOverList(elements);
|
|
411
411
|
});
|
|
412
412
|
}
|
|
413
413
|
}, {
|
|
414
414
|
key: "iterateOverList",
|
|
415
415
|
value: function iterateOverList(elements) {
|
|
416
|
-
var
|
|
416
|
+
var _this1 = this;
|
|
417
417
|
this.getElement();
|
|
418
418
|
cy.realPress('{downarrow}');
|
|
419
419
|
return this.getElement().then(function (element) {
|
|
@@ -422,7 +422,7 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
422
422
|
return cy.wrap(elements);
|
|
423
423
|
}
|
|
424
424
|
elements.push(element.text());
|
|
425
|
-
return
|
|
425
|
+
return _this1.iterateOverList(elements);
|
|
426
426
|
});
|
|
427
427
|
}
|
|
428
428
|
}, {
|
|
@@ -439,6 +439,27 @@ var BaseElement = /*#__PURE__*/function () {
|
|
|
439
439
|
});
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
|
+
}, {
|
|
443
|
+
key: "findElementTextByTitle",
|
|
444
|
+
value: function findElementTextByTitle(title) {
|
|
445
|
+
var _this = this;
|
|
446
|
+
var cellXpathTemplate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '//td[contains(@class, "ant-table-cell")][{{index}}]';
|
|
447
|
+
cy.logger("[inf] ▶ find element text by title \"".concat(title, "\""));
|
|
448
|
+
return this.getElementsListText({
|
|
449
|
+
propertyName: 'innerText'
|
|
450
|
+
}).then(function (innerTextArray) {
|
|
451
|
+
var targetIndex = innerTextArray.findIndex(function (innerText) {
|
|
452
|
+
return innerText === title;
|
|
453
|
+
}) + 1;
|
|
454
|
+
if (!targetIndex) {
|
|
455
|
+
throw new Error("Title \"".concat(title, "\" was not found in ").concat(_classPrivateFieldLooseBase(_this, _elementName)[_elementName]));
|
|
456
|
+
}
|
|
457
|
+
return cy.wrap(targetIndex);
|
|
458
|
+
}).then(function (index) {
|
|
459
|
+
var targetElement = new BaseElement(new XPATH(cellXpathTemplate.replace('{{index}}', index)), "".concat(title, " target element"));
|
|
460
|
+
return targetElement.getText();
|
|
461
|
+
});
|
|
462
|
+
}
|
|
442
463
|
}]);
|
|
443
464
|
}();
|
|
444
465
|
module.exports = BaseElement;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amanat-qa/ui-core",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"prepare": "npm run build"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@amanat-qa/utils-frontend": "5.1
|
|
41
|
+
"@amanat-qa/utils-frontend": "5.4.1",
|
|
42
42
|
"cypress-xpath": "*"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|