@amanat-qa/ui-core 1.0.6 → 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.
- package/dist/baseForm.js +54 -34
- package/dist/elements/baseElement.js +406 -291
- package/dist/elements/baseElementChildren/button.js +22 -2
- package/dist/elements/baseElementChildren/checkbox.js +30 -7
- package/dist/elements/baseElementChildren/label.js +22 -2
- package/dist/elements/baseElementChildren/radioButton.js +22 -2
- package/dist/elements/baseElementChildren/switch.js +30 -7
- package/dist/elements/baseElementChildren/textbox.js +22 -2
- package/dist/locators/baseLocator.js +16 -6
- package/dist/locators/baseLocatorChildren/ATTR.js +22 -2
- package/dist/locators/baseLocatorChildren/CSS.js +22 -2
- package/dist/locators/baseLocatorChildren/ID.js +22 -2
- package/dist/locators/baseLocatorChildren/TAG.js +22 -2
- package/dist/locators/baseLocatorChildren/TEXT.js +22 -2
- package/dist/locators/baseLocatorChildren/XPATH.js +22 -2
- package/package.json +2 -2
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
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); }
|
|
3
9
|
function _classPrivateFieldLooseBase(e, t) { if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance"); return e; }
|
|
4
10
|
var id = 0;
|
|
5
11
|
function _classPrivateFieldLooseKey(e) { return "__private_" + id++ + "_" + e; }
|
|
6
12
|
require('cypress-xpath');
|
|
7
|
-
|
|
8
|
-
|
|
13
|
+
var Randomizer = require('@amanat-qa/utils-frontend/randomizer');
|
|
14
|
+
var XPATH = require('../locators/baseLocatorChildren/XPATH');
|
|
9
15
|
var _elementName = /*#__PURE__*/_classPrivateFieldLooseKey("elementName");
|
|
10
16
|
var _elementLocator = /*#__PURE__*/_classPrivateFieldLooseKey("elementLocator");
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
var BaseElement = /*#__PURE__*/function () {
|
|
18
|
+
function BaseElement(elementLocator, elementName) {
|
|
19
|
+
_classCallCheck(this, BaseElement);
|
|
13
20
|
Object.defineProperty(this, _elementName, {
|
|
14
21
|
writable: true,
|
|
15
22
|
value: void 0
|
|
@@ -21,308 +28,416 @@ class BaseElement {
|
|
|
21
28
|
_classPrivateFieldLooseBase(this, _elementLocator)[_elementLocator] = elementLocator;
|
|
22
29
|
_classPrivateFieldLooseBase(this, _elementName)[_elementName] = elementName;
|
|
23
30
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return _classPrivateFieldLooseBase(this, _elementLocator)[_elementLocator] instanceof XPATH ? cy.xpath(_classPrivateFieldLooseBase(this, _elementLocator)[_elementLocator].value) : cy.get(_classPrivateFieldLooseBase(this, _elementLocator)[_elementLocator].value);
|
|
31
|
-
}
|
|
32
|
-
clickElement() {
|
|
33
|
-
cy.logger(`[inf] ▶ click ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]}`);
|
|
34
|
-
return this.getElement().click();
|
|
35
|
-
}
|
|
36
|
-
focusOnElement() {
|
|
37
|
-
cy.logger(`[inf] ▶ focus on ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]}`);
|
|
38
|
-
return this.getElement().focus();
|
|
39
|
-
}
|
|
40
|
-
forceClickElement() {
|
|
41
|
-
cy.logger(`[inf] ▶ force click ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]}`);
|
|
42
|
-
return this.getElement().click({
|
|
43
|
-
force: true
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
doubleClickElement() {
|
|
47
|
-
cy.logger(`[inf] ▶ double click ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]}`);
|
|
48
|
-
this.getElement().dblclick();
|
|
49
|
-
}
|
|
50
|
-
multipleClickElement(count) {
|
|
51
|
-
cy.logger(`[inf] ▶ click ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]} ${count} times`);
|
|
52
|
-
this.getElement().clicks(count);
|
|
53
|
-
}
|
|
54
|
-
clickElementFromList(index) {
|
|
55
|
-
cy.logger(`[inf] ▶ click element from ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]}`);
|
|
56
|
-
this.getElements()[index].click();
|
|
57
|
-
}
|
|
58
|
-
getText() {
|
|
59
|
-
cy.logger(`[inf] ▶ get ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]} text:`);
|
|
60
|
-
this.getElement().then($el => cy.logger(`[inf] text contains: "${$el.text()}"`));
|
|
61
|
-
return this.getElement().then($el => $el.text());
|
|
62
|
-
}
|
|
63
|
-
getValue() {
|
|
64
|
-
cy.logger(`[inf] ▶ get ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]} value:`);
|
|
65
|
-
this.getElement().then($el => cy.logger(`[inf] value is: "${$el.val()}"`));
|
|
66
|
-
return this.getElement().then($el => $el.val());
|
|
67
|
-
}
|
|
68
|
-
getElementsListText({
|
|
69
|
-
propertyName
|
|
70
|
-
}) {
|
|
71
|
-
return this.getElements().then($el => Cypress._.map($el, propertyName));
|
|
72
|
-
}
|
|
73
|
-
getAttributeValue({
|
|
74
|
-
attrName
|
|
75
|
-
}) {
|
|
76
|
-
cy.logger(`[inf] ▶ get ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]} attribute "${attrName}" value:`);
|
|
77
|
-
return this.getElement().invoke('attr', attrName).then(value => {
|
|
78
|
-
cy.logger(`[inf] attribute value contains: "${value}"`);
|
|
79
|
-
return cy.wrap(value);
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
scrollElementToView() {
|
|
83
|
-
cy.logger(`[inf] ▶ scroll to ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]}`);
|
|
84
|
-
this.getElement().scrollIntoView({
|
|
85
|
-
offset: {
|
|
86
|
-
top: -150,
|
|
87
|
-
left: 0
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
clearData() {
|
|
92
|
-
cy.logger(`[inf] ▶ clear ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]}`);
|
|
93
|
-
this.getElement().clear();
|
|
94
|
-
}
|
|
95
|
-
inputData(data, options = {
|
|
96
|
-
useCypressRealEvents: false
|
|
97
|
-
}) {
|
|
98
|
-
cy.logger(`[inf] ▶ input ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]}`);
|
|
99
|
-
if (options.useCypressRealEvents) {
|
|
100
|
-
this.getElement().click();
|
|
101
|
-
cy.realType(data);
|
|
102
|
-
} else {
|
|
103
|
-
this.getElement().type(data);
|
|
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();
|
|
104
37
|
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
150
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
+
});
|
|
163
319
|
});
|
|
164
320
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
waitElementIsNotDisplayed() {
|
|
170
|
-
cy.logger(`[inf] ▶ wait ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]} is not displayed:`);
|
|
171
|
-
return this.waitElementIsNotExisting().then(isExisting => {
|
|
172
|
-
const displayedLog = `[inf] ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]} is displayed`;
|
|
173
|
-
if (!isExisting) {
|
|
174
|
-
return this.elementIsVisible().then(isVisible => {
|
|
175
|
-
cy.logger(!isVisible ? `[inf] ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]} is not displayed` : displayedLog);
|
|
176
|
-
return cy.wrap(isVisible);
|
|
321
|
+
if (!valuesListPromise) {
|
|
322
|
+
valuesListPromise = dropdownElement.getElementsListText({
|
|
323
|
+
propertyName: 'innerText'
|
|
177
324
|
});
|
|
178
325
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
return cy.wrap(isEnabled);
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
waitElementIsEnabled() {
|
|
191
|
-
cy.logger(`[inf] ▶ wait ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]} is enabled:`);
|
|
192
|
-
return this.getElement().waitIsEnabled().then(isEnabled => {
|
|
193
|
-
cy.logger(isEnabled ? `[inf] ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]} is enabled` : `[inf] ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]} is not enabled`);
|
|
194
|
-
return cy.wrap(isEnabled);
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
waitElementIsNotEnabled() {
|
|
198
|
-
cy.logger(`[inf] ▶ wait ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]} is not enabled:`);
|
|
199
|
-
return this.getElement().waitIsNotEnabled().then(isEnabled => {
|
|
200
|
-
cy.logger(!isEnabled ? `[inf] ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]} is not enabled` : `[inf] ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]} is enabled`);
|
|
201
|
-
return cy.wrap(isEnabled);
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* requires one mandatory argument: dropdownElement.
|
|
207
|
-
* options contain optional parameters:
|
|
208
|
-
* list of values to choose from,
|
|
209
|
-
* count of elements to choose,
|
|
210
|
-
* boolean toggler for typing and pressing Enter key
|
|
211
|
-
* and exceptions elements sequence:
|
|
212
|
-
* @param {BaseElement} dropdownElement
|
|
213
|
-
* @param {Object} options
|
|
214
|
-
* @param {Promise} options.valuesListPromise
|
|
215
|
-
* @param {int} options.count
|
|
216
|
-
* @param {boolean} options.typeAndEnter
|
|
217
|
-
* @param {BaseElement[]} options.exceptionElementsList
|
|
218
|
-
*/
|
|
219
|
-
chooseRandomElementsFromDropdownByText(dropdownElement, options = {}) {
|
|
220
|
-
let valuesListPromise = options.valuesListPromise ?? null;
|
|
221
|
-
const count = options.count ?? 1;
|
|
222
|
-
const typeAndEnter = options.typeAndEnter ?? false;
|
|
223
|
-
const exceptionElementsList = options.exceptionElementsList ?? [];
|
|
224
|
-
this.getElement(_classPrivateFieldLooseBase(this, _elementLocator)[_elementLocator]).click();
|
|
225
|
-
const exceptionsTextList = [];
|
|
226
|
-
if (exceptionElementsList.length !== 0) {
|
|
227
|
-
exceptionElementsList.forEach(element => this.getElement(_classPrivateFieldLooseBase(element, _elementLocator)[_elementLocator]).then($el => exceptionsTextList.push($el.text())));
|
|
228
|
-
}
|
|
229
|
-
if (!valuesListPromise) {
|
|
230
|
-
valuesListPromise = dropdownElement.getElementsListText({
|
|
231
|
-
propertyName: 'innerText'
|
|
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
|
+
}
|
|
232
334
|
});
|
|
233
335
|
}
|
|
234
|
-
valuesListPromise.then(elementsTextList => {
|
|
235
|
-
for (let counter = 0; counter < count; counter += 1) {
|
|
236
|
-
cy.logger(`[inf] ▶ click ${_classPrivateFieldLooseBase(dropdownElement, _elementName)[_elementName]}`);
|
|
237
|
-
cy.logger(`[inf] ▶ get random element from ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]}`);
|
|
238
|
-
const randomElementText = Randomizer.getRandomElementByText(elementsTextList, exceptionsTextList);
|
|
239
|
-
exceptionsTextList.push(randomElementText);
|
|
240
|
-
dropdownElement.chooseElementFromDropdown(randomElementText, typeAndEnter);
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
336
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const exceptionsTextList = [];
|
|
259
|
-
if (exceptionsElements.length !== 0) {
|
|
260
|
-
exceptionsElements.forEach(element => this.getElement(_classPrivateFieldLooseBase(element, _elementLocator)[_elementLocator]).then($el => exceptionsTextList.push($el.text())));
|
|
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];
|
|
261
350
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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({
|
|
268
383
|
force: true
|
|
269
384
|
});
|
|
270
385
|
}
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
openCalendarAndFlipMonths(rightArrowElement, monthIncrement) {
|
|
274
|
-
cy.logger(`[inf] ▶ click ${_classPrivateFieldLooseBase(this, _elementName)[_elementName]}`);
|
|
275
|
-
this.getElement().clicks(4);
|
|
276
|
-
for (let i = 0; i < monthIncrement; i += 1) {
|
|
277
|
-
cy.logger(`[inf] ▶ click ${_classPrivateFieldLooseBase(rightArrowElement, _elementName)[_elementName]}`);
|
|
278
|
-
this.getElement(_classPrivateFieldLooseBase(rightArrowElement, _elementLocator)[_elementLocator]).click({
|
|
279
|
-
force: true
|
|
280
|
-
});
|
|
281
386
|
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
cy.logger('[inf] ▶ press Enter button');
|
|
293
|
-
cy.realPress('Enter');
|
|
294
|
-
}
|
|
295
|
-
createListOfElements(dropdownElement) {
|
|
296
|
-
const elements = [];
|
|
297
|
-
this.getElement(_classPrivateFieldLooseBase(dropdownElement, _elementLocator)[_elementLocator]).click();
|
|
298
|
-
return this.getElement().then(element => {
|
|
299
|
-
elements.push(element.text());
|
|
300
|
-
return this.iterateOverList(elements);
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
iterateOverList(elements) {
|
|
304
|
-
this.getElement();
|
|
305
|
-
cy.realPress('{downarrow}');
|
|
306
|
-
return this.getElement().then(element => {
|
|
307
|
-
if (element.text() === elements[0]) {
|
|
308
|
-
cy.logger(`Number of countries is ${elements.length}`);
|
|
309
|
-
return cy.wrap(elements);
|
|
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}"));
|
|
310
397
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
force: true
|
|
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);
|
|
324
410
|
});
|
|
325
411
|
}
|
|
326
|
-
}
|
|
327
|
-
|
|
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
|
+
}();
|
|
328
443
|
module.exports = BaseElement;
|