@amanat-qa/ui-core 1.0.5 → 1.0.7

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.
Files changed (32) hide show
  1. package/dist/baseForm.js +74 -0
  2. package/dist/elements/baseElement.js +443 -0
  3. package/dist/elements/baseElementChildren/button.js +25 -0
  4. package/dist/elements/baseElementChildren/checkbox.js +34 -0
  5. package/dist/elements/baseElementChildren/label.js +25 -0
  6. package/dist/elements/baseElementChildren/radioButton.js +25 -0
  7. package/dist/elements/baseElementChildren/switch.js +34 -0
  8. package/dist/elements/baseElementChildren/textbox.js +25 -0
  9. package/{src → dist}/index.js +3 -1
  10. package/dist/locators/baseLocator.js +29 -0
  11. package/dist/locators/baseLocatorChildren/ATTR.js +25 -0
  12. package/dist/locators/baseLocatorChildren/CSS.js +25 -0
  13. package/dist/locators/baseLocatorChildren/ID.js +25 -0
  14. package/dist/locators/baseLocatorChildren/TAG.js +25 -0
  15. package/dist/locators/baseLocatorChildren/TEXT.js +25 -0
  16. package/dist/locators/baseLocatorChildren/XPATH.js +25 -0
  17. package/package.json +29 -20
  18. package/src/baseForm.js +0 -57
  19. package/src/elements/baseElement.js +0 -361
  20. package/src/elements/baseElementChildren/button.js +0 -5
  21. package/src/elements/baseElementChildren/checkbox.js +0 -9
  22. package/src/elements/baseElementChildren/label.js +0 -5
  23. package/src/elements/baseElementChildren/radioButton.js +0 -5
  24. package/src/elements/baseElementChildren/switch.js +0 -9
  25. package/src/elements/baseElementChildren/textbox.js +0 -5
  26. package/src/locators/baseLocator.js +0 -13
  27. package/src/locators/baseLocatorChildren/ATTR.js +0 -5
  28. package/src/locators/baseLocatorChildren/CSS.js +0 -5
  29. package/src/locators/baseLocatorChildren/ID.js +0 -5
  30. package/src/locators/baseLocatorChildren/TAG.js +0 -5
  31. package/src/locators/baseLocatorChildren/TEXT.js +0 -5
  32. package/src/locators/baseLocatorChildren/XPATH.js +0 -5
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
5
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
6
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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 _classPrivateFieldLooseBase(e, t) { if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance"); return e; }
10
+ var id = 0;
11
+ function _classPrivateFieldLooseKey(e) { return "__private_" + id++ + "_" + e; }
12
+ require('cypress-xpath');
13
+ var XPATH = require('./locators/baseLocatorChildren/XPATH');
14
+ var _pageName = /*#__PURE__*/_classPrivateFieldLooseKey("pageName");
15
+ var _pageLocator = /*#__PURE__*/_classPrivateFieldLooseKey("pageLocator");
16
+ var BaseForm = /*#__PURE__*/function () {
17
+ function BaseForm(pageLocator, pageName) {
18
+ _classCallCheck(this, BaseForm);
19
+ Object.defineProperty(this, _pageName, {
20
+ writable: true,
21
+ value: void 0
22
+ });
23
+ Object.defineProperty(this, _pageLocator, {
24
+ writable: true,
25
+ value: void 0
26
+ });
27
+ _classPrivateFieldLooseBase(this, _pageLocator)[_pageLocator] = pageLocator;
28
+ _classPrivateFieldLooseBase(this, _pageName)[_pageName] = pageName;
29
+ }
30
+ return _createClass(BaseForm, [{
31
+ key: "getUniqueElement",
32
+ value: function getUniqueElement() {
33
+ return _classPrivateFieldLooseBase(this, _pageLocator)[_pageLocator] instanceof XPATH ? cy.xpath(_classPrivateFieldLooseBase(this, _pageLocator)[_pageLocator].value).first() : cy.get(_classPrivateFieldLooseBase(this, _pageLocator)[_pageLocator].value).first();
34
+ }
35
+ }, {
36
+ key: "pageIsVisible",
37
+ value: function pageIsVisible() {
38
+ return this.getUniqueElement().isVisible();
39
+ }
40
+ }, {
41
+ key: "waitPageIsExisting",
42
+ value: function waitPageIsExisting() {
43
+ return cy.waitIsExisting(_classPrivateFieldLooseBase(this, _pageLocator)[_pageLocator].value);
44
+ }
45
+ }, {
46
+ key: "pageIsDisplayed",
47
+ value: function pageIsDisplayed() {
48
+ var _this = this;
49
+ cy.logger("[inf] \u25B6 check ".concat(_classPrivateFieldLooseBase(this, _pageName)[_pageName], " is displayed:"));
50
+ return this.waitPageIsExisting().then(function (isExisting) {
51
+ var notDisplayedLog = "[inf] ".concat(_classPrivateFieldLooseBase(_this, _pageName)[_pageName], " is not displayed");
52
+ if (isExisting) {
53
+ return _this.pageIsVisible().then(function (isVisible) {
54
+ cy.logger(isVisible ? "[inf] ".concat(_classPrivateFieldLooseBase(_this, _pageName)[_pageName], " is displayed") : notDisplayedLog);
55
+ return cy.wrap(isVisible);
56
+ });
57
+ }
58
+ cy.logger(notDisplayedLog);
59
+ return cy.wrap(isExisting);
60
+ });
61
+ }
62
+ }, {
63
+ key: "pageIsEnabled",
64
+ value: function pageIsEnabled() {
65
+ var _this2 = this;
66
+ cy.logger("[inf] \u25B6 check ".concat(_classPrivateFieldLooseBase(this, _pageName)[_pageName], " is enabled:"));
67
+ return this.getUniqueElement().waitIsEnabled().then(function (isEnabled) {
68
+ cy.logger(isEnabled ? "[inf] ".concat(_classPrivateFieldLooseBase(_this2, _pageName)[_pageName], " is enabled") : "[inf] ".concat(_classPrivateFieldLooseBase(_this2, _pageName)[_pageName], " is not enabled"));
69
+ return cy.wrap(isEnabled);
70
+ });
71
+ }
72
+ }]);
73
+ }();
74
+ module.exports = BaseForm;
@@ -0,0 +1,443 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
5
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
6
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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 _classPrivateFieldLooseBase(e, t) { if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance"); return e; }
10
+ var id = 0;
11
+ function _classPrivateFieldLooseKey(e) { return "__private_" + id++ + "_" + e; }
12
+ require('cypress-xpath');
13
+ var Randomizer = require('@amanat-qa/utils-frontend/randomizer');
14
+ var XPATH = require('../locators/baseLocatorChildren/XPATH');
15
+ var _elementName = /*#__PURE__*/_classPrivateFieldLooseKey("elementName");
16
+ var _elementLocator = /*#__PURE__*/_classPrivateFieldLooseKey("elementLocator");
17
+ var BaseElement = /*#__PURE__*/function () {
18
+ function BaseElement(elementLocator, elementName) {
19
+ _classCallCheck(this, BaseElement);
20
+ Object.defineProperty(this, _elementName, {
21
+ writable: true,
22
+ value: void 0
23
+ });
24
+ Object.defineProperty(this, _elementLocator, {
25
+ writable: true,
26
+ value: void 0
27
+ });
28
+ _classPrivateFieldLooseBase(this, _elementLocator)[_elementLocator] = elementLocator;
29
+ _classPrivateFieldLooseBase(this, _elementName)[_elementName] = elementName;
30
+ }
31
+ return _createClass(BaseElement, [{
32
+ key: "getElement",
33
+ value: function getElement(locator) {
34
+ var elementLocator = locator;
35
+ if (!elementLocator) elementLocator = _classPrivateFieldLooseBase(this, _elementLocator)[_elementLocator];
36
+ return elementLocator instanceof XPATH ? cy.xpath(elementLocator.value).first() : cy.get(elementLocator.value).first();
37
+ }
38
+ }, {
39
+ key: "getElements",
40
+ value: function getElements() {
41
+ return _classPrivateFieldLooseBase(this, _elementLocator)[_elementLocator] instanceof XPATH ? cy.xpath(_classPrivateFieldLooseBase(this, _elementLocator)[_elementLocator].value) : cy.get(_classPrivateFieldLooseBase(this, _elementLocator)[_elementLocator].value);
42
+ }
43
+ }, {
44
+ key: "clickElement",
45
+ value: function clickElement() {
46
+ cy.logger("[inf] \u25B6 click ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName]));
47
+ return this.getElement().click();
48
+ }
49
+ }, {
50
+ key: "focusOnElement",
51
+ value: function focusOnElement() {
52
+ cy.logger("[inf] \u25B6 focus on ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName]));
53
+ return this.getElement().focus();
54
+ }
55
+ }, {
56
+ key: "forceClickElement",
57
+ value: function forceClickElement() {
58
+ cy.logger("[inf] \u25B6 force click ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName]));
59
+ return this.getElement().click({
60
+ force: true
61
+ });
62
+ }
63
+ }, {
64
+ key: "doubleClickElement",
65
+ value: function doubleClickElement() {
66
+ cy.logger("[inf] \u25B6 double click ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName]));
67
+ this.getElement().dblclick();
68
+ }
69
+ }, {
70
+ key: "multipleClickElement",
71
+ value: function multipleClickElement(count) {
72
+ cy.logger("[inf] \u25B6 click ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName], " ").concat(count, " times"));
73
+ this.getElement().clicks(count);
74
+ }
75
+ }, {
76
+ key: "clickElementFromList",
77
+ value: function clickElementFromList(index) {
78
+ cy.logger("[inf] \u25B6 click element from ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName]));
79
+ this.getElements()[index].click();
80
+ }
81
+ }, {
82
+ key: "getText",
83
+ value: function getText() {
84
+ cy.logger("[inf] \u25B6 get ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName], " text:"));
85
+ this.getElement().then(function ($el) {
86
+ return cy.logger("[inf] text contains: \"".concat($el.text(), "\""));
87
+ });
88
+ return this.getElement().then(function ($el) {
89
+ return $el.text();
90
+ });
91
+ }
92
+ }, {
93
+ key: "getValue",
94
+ value: function getValue() {
95
+ cy.logger("[inf] \u25B6 get ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName], " value:"));
96
+ this.getElement().then(function ($el) {
97
+ return cy.logger("[inf] value is: \"".concat($el.val(), "\""));
98
+ });
99
+ return this.getElement().then(function ($el) {
100
+ return $el.val();
101
+ });
102
+ }
103
+ }, {
104
+ key: "getElementsListText",
105
+ value: function getElementsListText(_ref) {
106
+ var propertyName = _ref.propertyName;
107
+ return this.getElements().then(function ($el) {
108
+ return Cypress._.map($el, propertyName);
109
+ });
110
+ }
111
+ }, {
112
+ key: "getAttributeValue",
113
+ value: function getAttributeValue(_ref2) {
114
+ var attrName = _ref2.attrName;
115
+ cy.logger("[inf] \u25B6 get ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName], " attribute \"").concat(attrName, "\" value:"));
116
+ return this.getElement().invoke('attr', attrName).then(function (value) {
117
+ cy.logger("[inf] attribute value contains: \"".concat(value, "\""));
118
+ return cy.wrap(value);
119
+ });
120
+ }
121
+ }, {
122
+ key: "scrollElementToView",
123
+ value: function scrollElementToView() {
124
+ cy.logger("[inf] \u25B6 scroll to ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName]));
125
+ this.getElement().scrollIntoView({
126
+ offset: {
127
+ top: -150,
128
+ left: 0
129
+ }
130
+ });
131
+ }
132
+ }, {
133
+ key: "clearData",
134
+ value: function clearData() {
135
+ cy.logger("[inf] \u25B6 clear ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName]));
136
+ this.getElement().clear();
137
+ }
138
+ }, {
139
+ key: "inputData",
140
+ value: function inputData(data) {
141
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
142
+ useCypressRealEvents: false
143
+ };
144
+ cy.logger("[inf] \u25B6 input ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName]));
145
+ if (options.useCypressRealEvents) {
146
+ this.getElement().click();
147
+ cy.realType(data);
148
+ } else {
149
+ this.getElement().type(data);
150
+ }
151
+ }
152
+ }, {
153
+ key: "forceInputData",
154
+ value: function forceInputData(data) {
155
+ cy.logger("[inf] \u25B6 force input ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName]));
156
+ this.getElement().type(data, {
157
+ force: true
158
+ });
159
+ }
160
+ }, {
161
+ key: "fillInputField",
162
+ value: function fillInputField(data) {
163
+ cy.logger("[inf] \u25B6 fill input data into ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName]));
164
+ this.getElement().fill(data, {
165
+ overwrite: false,
166
+ prepend: true
167
+ });
168
+ }
169
+ }, {
170
+ key: "enterData",
171
+ value: function enterData(data) {
172
+ cy.logger("[inf] \u25B6 input ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName], " and submit"));
173
+ this.getElement().type("".concat(data, "{enter}"));
174
+ }
175
+ }, {
176
+ key: "uploadFile",
177
+ value: function uploadFile(path) {
178
+ cy.logger("[inf] \u25B6 upload file with ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName]));
179
+ this.getElement().selectFile(path, {
180
+ force: true
181
+ });
182
+ }
183
+ }, {
184
+ key: "elementIsVisible",
185
+ value: function elementIsVisible() {
186
+ return this.getElement().isVisible();
187
+ }
188
+ }, {
189
+ key: "elementIsExisting",
190
+ value: function elementIsExisting() {
191
+ return cy.isExisting(_classPrivateFieldLooseBase(this, _elementLocator)[_elementLocator].value);
192
+ }
193
+ }, {
194
+ key: "waitElementIsExisting",
195
+ value: function waitElementIsExisting() {
196
+ return cy.waitIsExisting(_classPrivateFieldLooseBase(this, _elementLocator)[_elementLocator].value);
197
+ }
198
+ }, {
199
+ key: "waitElementIsNotExisting",
200
+ value: function waitElementIsNotExisting() {
201
+ return cy.waitIsNotExisting(_classPrivateFieldLooseBase(this, _elementLocator)[_elementLocator].value);
202
+ }
203
+ }, {
204
+ key: "elementIsDisplayed",
205
+ value: function elementIsDisplayed() {
206
+ var _this = this;
207
+ cy.logger("[inf] \u25B6 check ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName], " is displayed:"));
208
+ return this.elementIsExisting().then(function (isExisting) {
209
+ var notDisplayedLog = "[inf] ".concat(_classPrivateFieldLooseBase(_this, _elementName)[_elementName], " is not displayed");
210
+ if (isExisting) {
211
+ return _this.elementIsVisible().then(function (isVisible) {
212
+ cy.logger(isVisible ? "[inf] ".concat(_classPrivateFieldLooseBase(_this, _elementName)[_elementName], " is displayed") : notDisplayedLog);
213
+ return cy.wrap(isVisible);
214
+ });
215
+ }
216
+ cy.logger(notDisplayedLog);
217
+ return cy.wrap(isExisting);
218
+ });
219
+ }
220
+ }, {
221
+ key: "waitElementIsDisplayed",
222
+ value: function waitElementIsDisplayed() {
223
+ var _this2 = this;
224
+ cy.logger("[inf] \u25B6 wait ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName], " is displayed:"));
225
+ return this.waitElementIsExisting().then(function (isExisting) {
226
+ var notDisplayedLog = "[inf] ".concat(_classPrivateFieldLooseBase(_this2, _elementName)[_elementName], " is not displayed");
227
+ if (isExisting) {
228
+ return _this2.elementIsVisible().then(function (isVisible) {
229
+ cy.logger(isVisible ? "[inf] ".concat(_classPrivateFieldLooseBase(_this2, _elementName)[_elementName], " is displayed") : notDisplayedLog);
230
+ return cy.wrap(isVisible);
231
+ });
232
+ }
233
+ cy.logger(notDisplayedLog);
234
+ return cy.wrap(isExisting);
235
+ });
236
+ }
237
+ }, {
238
+ key: "waitElementIsNotDisplayed",
239
+ value: function waitElementIsNotDisplayed() {
240
+ var _this3 = this;
241
+ cy.logger("[inf] \u25B6 wait ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName], " is not displayed:"));
242
+ return this.waitElementIsNotExisting().then(function (isExisting) {
243
+ var displayedLog = "[inf] ".concat(_classPrivateFieldLooseBase(_this3, _elementName)[_elementName], " is displayed");
244
+ if (!isExisting) {
245
+ return _this3.elementIsVisible().then(function (isVisible) {
246
+ cy.logger(!isVisible ? "[inf] ".concat(_classPrivateFieldLooseBase(_this3, _elementName)[_elementName], " is not displayed") : displayedLog);
247
+ return cy.wrap(isVisible);
248
+ });
249
+ }
250
+ cy.logger(displayedLog);
251
+ return cy.wrap(isExisting);
252
+ });
253
+ }
254
+ }, {
255
+ key: "elementIsEnabled",
256
+ value: function elementIsEnabled() {
257
+ var _this4 = this;
258
+ cy.logger("[inf] \u25B6 check ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName], " is enabled:"));
259
+ return this.getElement().isEnabled().then(function (isEnabled) {
260
+ cy.logger(isEnabled ? "[inf] ".concat(_classPrivateFieldLooseBase(_this4, _elementName)[_elementName], " is enabled") : "[inf] ".concat(_classPrivateFieldLooseBase(_this4, _elementName)[_elementName], " is not enabled"));
261
+ return cy.wrap(isEnabled);
262
+ });
263
+ }
264
+ }, {
265
+ key: "waitElementIsEnabled",
266
+ value: function waitElementIsEnabled() {
267
+ var _this5 = this;
268
+ cy.logger("[inf] \u25B6 wait ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName], " is enabled:"));
269
+ return this.getElement().waitIsEnabled().then(function (isEnabled) {
270
+ cy.logger(isEnabled ? "[inf] ".concat(_classPrivateFieldLooseBase(_this5, _elementName)[_elementName], " is enabled") : "[inf] ".concat(_classPrivateFieldLooseBase(_this5, _elementName)[_elementName], " is not enabled"));
271
+ return cy.wrap(isEnabled);
272
+ });
273
+ }
274
+ }, {
275
+ key: "waitElementIsNotEnabled",
276
+ value: function waitElementIsNotEnabled() {
277
+ var _this6 = this;
278
+ cy.logger("[inf] \u25B6 wait ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName], " is not enabled:"));
279
+ return this.getElement().waitIsNotEnabled().then(function (isEnabled) {
280
+ cy.logger(!isEnabled ? "[inf] ".concat(_classPrivateFieldLooseBase(_this6, _elementName)[_elementName], " is not enabled") : "[inf] ".concat(_classPrivateFieldLooseBase(_this6, _elementName)[_elementName], " is enabled"));
281
+ return cy.wrap(isEnabled);
282
+ });
283
+ }
284
+
285
+ /**
286
+ * requires one mandatory argument: dropdownElement.
287
+ * options contain optional parameters:
288
+ * list of values to choose from,
289
+ * count of elements to choose,
290
+ * boolean toggler for typing and pressing Enter key
291
+ * and exceptions elements sequence:
292
+ * @param {BaseElement} dropdownElement
293
+ * @param {Object} options
294
+ * @param {Promise} options.valuesListPromise
295
+ * @param {int} options.count
296
+ * @param {boolean} options.typeAndEnter
297
+ * @param {BaseElement[]} options.exceptionElementsList
298
+ */
299
+ }, {
300
+ key: "chooseRandomElementsFromDropdownByText",
301
+ value: function chooseRandomElementsFromDropdownByText(dropdownElement) {
302
+ var _options$valuesListPr,
303
+ _options$count,
304
+ _options$typeAndEnter,
305
+ _options$exceptionEle,
306
+ _this7 = this;
307
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
308
+ var valuesListPromise = (_options$valuesListPr = options.valuesListPromise) !== null && _options$valuesListPr !== void 0 ? _options$valuesListPr : null;
309
+ var count = (_options$count = options.count) !== null && _options$count !== void 0 ? _options$count : 1;
310
+ var typeAndEnter = (_options$typeAndEnter = options.typeAndEnter) !== null && _options$typeAndEnter !== void 0 ? _options$typeAndEnter : false;
311
+ var exceptionElementsList = (_options$exceptionEle = options.exceptionElementsList) !== null && _options$exceptionEle !== void 0 ? _options$exceptionEle : [];
312
+ this.getElement(_classPrivateFieldLooseBase(this, _elementLocator)[_elementLocator]).click();
313
+ var exceptionsTextList = [];
314
+ if (exceptionElementsList.length !== 0) {
315
+ exceptionElementsList.forEach(function (element) {
316
+ return _this7.getElement(_classPrivateFieldLooseBase(element, _elementLocator)[_elementLocator]).then(function ($el) {
317
+ return exceptionsTextList.push($el.text());
318
+ });
319
+ });
320
+ }
321
+ if (!valuesListPromise) {
322
+ valuesListPromise = dropdownElement.getElementsListText({
323
+ propertyName: 'innerText'
324
+ });
325
+ }
326
+ valuesListPromise.then(function (elementsTextList) {
327
+ for (var counter = 0; counter < count; counter += 1) {
328
+ cy.logger("[inf] \u25B6 click ".concat(_classPrivateFieldLooseBase(dropdownElement, _elementName)[_elementName]));
329
+ cy.logger("[inf] \u25B6 get random element from ".concat(_classPrivateFieldLooseBase(_this7, _elementName)[_elementName]));
330
+ var randomElementText = Randomizer.getRandomElementByText(elementsTextList, exceptionsTextList);
331
+ exceptionsTextList.push(randomElementText);
332
+ dropdownElement.chooseElementFromDropdown(randomElementText, typeAndEnter);
333
+ }
334
+ });
335
+ }
336
+
337
+ // requires two mandatory arguments:
338
+ // inputElementType - is type of clickable element (checkbox/radio),
339
+ // parentOfLabelTag - is a tagname of an element on the upper node that nesting input`s label text
340
+ }, {
341
+ key: "clickRandomRadiobuttonsOrCheckboxesByText",
342
+ value: function clickRandomRadiobuttonsOrCheckboxesByText(_ref3) {
343
+ var _this8 = this;
344
+ var inputElementType = _ref3.inputElementType,
345
+ parentOfLabelTag = _ref3.parentOfLabelTag,
346
+ _ref3$randomCount = _ref3.randomCount,
347
+ randomCount = _ref3$randomCount === void 0 ? true : _ref3$randomCount;
348
+ for (var _len = arguments.length, exceptionsElements = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
349
+ exceptionsElements[_key - 1] = arguments[_key];
350
+ }
351
+ this.getElementsListText({
352
+ propertyName: 'innerText'
353
+ }).then(function (elementsTextList) {
354
+ var count = elementsTextList.length;
355
+ if (randomCount) count = Randomizer.getRandomInteger(elementsTextList.length, 1);
356
+ var exceptionsTextList = [];
357
+ if (exceptionsElements.length !== 0) {
358
+ exceptionsElements.forEach(function (element) {
359
+ return _this8.getElement(_classPrivateFieldLooseBase(element, _elementLocator)[_elementLocator]).then(function ($el) {
360
+ return exceptionsTextList.push($el.text());
361
+ });
362
+ });
363
+ }
364
+ for (var counter = 0; counter < count; counter += 1) {
365
+ cy.logger("[inf] \u25B6 get random element from ".concat(_classPrivateFieldLooseBase(_this8, _elementName)[_elementName]));
366
+ var randomElementText = Randomizer.getRandomElementByText(elementsTextList, exceptionsTextList);
367
+ exceptionsTextList.push(randomElementText);
368
+ cy.logger("[inf] \u25B6 click ".concat(randomElementText));
369
+ cy.contains(parentOfLabelTag, randomElementText).find("input[type=".concat(inputElementType, "]")).click({
370
+ force: true
371
+ });
372
+ }
373
+ });
374
+ }
375
+ }, {
376
+ key: "openCalendarAndFlipMonths",
377
+ value: function openCalendarAndFlipMonths(rightArrowElement, monthIncrement) {
378
+ cy.logger("[inf] \u25B6 click ".concat(_classPrivateFieldLooseBase(this, _elementName)[_elementName]));
379
+ this.getElement().clicks(4);
380
+ for (var i = 0; i < monthIncrement; i += 1) {
381
+ cy.logger("[inf] \u25B6 click ".concat(_classPrivateFieldLooseBase(rightArrowElement, _elementName)[_elementName]));
382
+ this.getElement(_classPrivateFieldLooseBase(rightArrowElement, _elementLocator)[_elementLocator]).click({
383
+ force: true
384
+ });
385
+ }
386
+ }
387
+ }, {
388
+ key: "clickArrowButtonRandomNumberOfTimes",
389
+ value: function clickArrowButtonRandomNumberOfTimes(direction, numberOfElements) {
390
+ this.elementIsVisible();
391
+ var directionLowerCase = direction.toLowerCase();
392
+ var numberOfClicksOnArrowButton = Randomizer.getRandomInteger(numberOfElements - 1);
393
+ cy.logger("[inf] \u25B6 direction: ".concat(directionLowerCase, ", numberOfClicks: ").concat(numberOfClicksOnArrowButton));
394
+ for (var i = numberOfClicksOnArrowButton; i > 0; i -= 1) {
395
+ cy.logger("[inf] \u25B6 press ".concat(directionLowerCase, " arrow button"));
396
+ cy.realPress("{".concat(directionLowerCase, "arrow}"));
397
+ }
398
+ cy.logger('[inf] ▶ press Enter button');
399
+ cy.realPress('Enter');
400
+ }
401
+ }, {
402
+ key: "createListOfElements",
403
+ value: function createListOfElements(dropdownElement) {
404
+ var _this9 = this;
405
+ var elements = [];
406
+ this.getElement(_classPrivateFieldLooseBase(dropdownElement, _elementLocator)[_elementLocator]).click();
407
+ return this.getElement().then(function (element) {
408
+ elements.push(element.text());
409
+ return _this9.iterateOverList(elements);
410
+ });
411
+ }
412
+ }, {
413
+ key: "iterateOverList",
414
+ value: function iterateOverList(elements) {
415
+ var _this0 = this;
416
+ this.getElement();
417
+ cy.realPress('{downarrow}');
418
+ return this.getElement().then(function (element) {
419
+ if (element.text() === elements[0]) {
420
+ cy.logger("Number of countries is ".concat(elements.length));
421
+ return cy.wrap(elements);
422
+ }
423
+ elements.push(element.text());
424
+ return _this0.iterateOverList(elements);
425
+ });
426
+ }
427
+ }, {
428
+ key: "chooseElementFromDropdown",
429
+ value: function chooseElementFromDropdown(text, typeAndEnter) {
430
+ if (typeAndEnter) {
431
+ cy.logger("[inf] \u25B6 type and enter ".concat(text));
432
+ this.enterData(text);
433
+ cy.realPress('{esc}');
434
+ } else {
435
+ cy.logger("[inf] \u25B6 click ".concat(text));
436
+ this.getElements().contains(new RegExp("".concat(text))).click({
437
+ force: true
438
+ });
439
+ }
440
+ }
441
+ }]);
442
+ }();
443
+ module.exports = BaseElement;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
5
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
7
+ 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); }
8
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
9
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
10
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
11
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
12
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
14
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
15
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
16
+ var BaseElement = require('../baseElement');
17
+ var Button = /*#__PURE__*/function (_BaseElement) {
18
+ function Button() {
19
+ _classCallCheck(this, Button);
20
+ return _callSuper(this, Button, arguments);
21
+ }
22
+ _inherits(Button, _BaseElement);
23
+ return _createClass(Button);
24
+ }(BaseElement);
25
+ module.exports = Button;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
5
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
6
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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 _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
10
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
11
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
12
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
14
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
15
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
16
+ var BaseElement = require('../baseElement');
17
+ var Checkbox = /*#__PURE__*/function (_BaseElement) {
18
+ function Checkbox() {
19
+ _classCallCheck(this, Checkbox);
20
+ return _callSuper(this, Checkbox, arguments);
21
+ }
22
+ _inherits(Checkbox, _BaseElement);
23
+ return _createClass(Checkbox, [{
24
+ key: "isChecked",
25
+ value: function isChecked() {
26
+ return this.getAttributeValue({
27
+ attrName: 'checked'
28
+ }).then(function (value) {
29
+ return JSON.parse(value);
30
+ });
31
+ }
32
+ }]);
33
+ }(BaseElement);
34
+ module.exports = Checkbox;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
5
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
7
+ 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); }
8
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
9
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
10
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
11
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
12
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
14
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
15
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
16
+ var BaseElement = require('../baseElement');
17
+ var Label = /*#__PURE__*/function (_BaseElement) {
18
+ function Label() {
19
+ _classCallCheck(this, Label);
20
+ return _callSuper(this, Label, arguments);
21
+ }
22
+ _inherits(Label, _BaseElement);
23
+ return _createClass(Label);
24
+ }(BaseElement);
25
+ module.exports = Label;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
5
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
7
+ 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); }
8
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
9
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
10
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
11
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
12
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
14
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
15
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
16
+ var BaseElement = require('../baseElement');
17
+ var RadioButton = /*#__PURE__*/function (_BaseElement) {
18
+ function RadioButton() {
19
+ _classCallCheck(this, RadioButton);
20
+ return _callSuper(this, RadioButton, arguments);
21
+ }
22
+ _inherits(RadioButton, _BaseElement);
23
+ return _createClass(RadioButton);
24
+ }(BaseElement);
25
+ module.exports = RadioButton;