webdriverio 5.11.11 → 5.11.12

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 (84) hide show
  1. package/build/commands/browser/$$.js +0 -42
  2. package/build/commands/browser/$.js +0 -42
  3. package/build/commands/browser/call.js +0 -38
  4. package/build/commands/browser/debug.js +1 -21
  5. package/build/commands/browser/deleteCookies.js +0 -43
  6. package/build/commands/browser/execute.js +0 -43
  7. package/build/commands/browser/executeAsync.js +0 -51
  8. package/build/commands/browser/getCookies.js +0 -32
  9. package/build/commands/browser/getWindowSize.js +0 -20
  10. package/build/commands/browser/keys.js +0 -36
  11. package/build/commands/browser/newWindow.js +0 -37
  12. package/build/commands/browser/pause.js +0 -21
  13. package/build/commands/browser/react$$.js +0 -24
  14. package/build/commands/browser/react$.js +0 -28
  15. package/build/commands/browser/reloadSession.js +1 -28
  16. package/build/commands/browser/saveRecordingScreen.js +0 -23
  17. package/build/commands/browser/saveScreenshot.js +0 -22
  18. package/build/commands/browser/setCookies.js +0 -46
  19. package/build/commands/browser/setTimeout.js +1 -38
  20. package/build/commands/browser/setWindowSize.js +0 -25
  21. package/build/commands/browser/switchWindow.js +0 -38
  22. package/build/commands/browser/touchAction.js +0 -60
  23. package/build/commands/browser/uploadFile.js +0 -32
  24. package/build/commands/browser/url.js +0 -33
  25. package/build/commands/browser/waitUntil.js +0 -40
  26. package/build/commands/constant.js +0 -18
  27. package/build/commands/element/$$.js +0 -39
  28. package/build/commands/element/$.js +0 -43
  29. package/build/commands/element/addValue.js +1 -28
  30. package/build/commands/element/clearValue.js +0 -26
  31. package/build/commands/element/click.js +0 -43
  32. package/build/commands/element/doubleClick.js +0 -30
  33. package/build/commands/element/dragAndDrop.js +1 -21
  34. package/build/commands/element/getAttribute.js +0 -26
  35. package/build/commands/element/getCSSProperty.js +0 -66
  36. package/build/commands/element/getHTML.js +1 -33
  37. package/build/commands/element/getLocation.js +0 -27
  38. package/build/commands/element/getProperty.js +0 -16
  39. package/build/commands/element/getSize.js +0 -27
  40. package/build/commands/element/getTagName.js +0 -23
  41. package/build/commands/element/getText.js +0 -40
  42. package/build/commands/element/getValue.js +0 -24
  43. package/build/commands/element/isDisplayed.js +1 -62
  44. package/build/commands/element/isDisplayedInViewport.js +1 -39
  45. package/build/commands/element/isEnabled.js +0 -32
  46. package/build/commands/element/isExisting.js +0 -40
  47. package/build/commands/element/isFocused.js +1 -29
  48. package/build/commands/element/isSelected.js +0 -29
  49. package/build/commands/element/moveTo.js +0 -21
  50. package/build/commands/element/react$$.js +0 -25
  51. package/build/commands/element/react$.js +0 -29
  52. package/build/commands/element/saveScreenshot.js +0 -21
  53. package/build/commands/element/scrollIntoView.js +2 -26
  54. package/build/commands/element/selectByAttribute.js +0 -46
  55. package/build/commands/element/selectByIndex.js +0 -40
  56. package/build/commands/element/selectByVisibleText.js +1 -43
  57. package/build/commands/element/setValue.js +0 -25
  58. package/build/commands/element/shadow$$.js +0 -18
  59. package/build/commands/element/shadow$.js +0 -18
  60. package/build/commands/element/touchAction.js +0 -53
  61. package/build/commands/element/waitForDisplayed.js +0 -37
  62. package/build/commands/element/waitForEnabled.js +0 -35
  63. package/build/commands/element/waitForExist.js +0 -38
  64. package/build/commands/element/waitUntil.js +0 -6
  65. package/build/constants.js +0 -128
  66. package/build/index.js +0 -25
  67. package/build/middlewares.js +0 -14
  68. package/build/multiremote.js +0 -46
  69. package/build/scripts/getHTML.js +0 -7
  70. package/build/scripts/getProperty.js +0 -6
  71. package/build/scripts/isDisplayedInViewport.js +0 -5
  72. package/build/scripts/isElementDisplayed.js +10 -71
  73. package/build/scripts/isFocused.js +0 -5
  74. package/build/scripts/newWindow.js +0 -8
  75. package/build/scripts/resq.js +2 -7
  76. package/build/scripts/shadowFnFactory.js +0 -1
  77. package/build/utils/Timer.js +4 -23
  78. package/build/utils/findStrategy.js +16 -48
  79. package/build/utils/getElementObject.js +0 -25
  80. package/build/utils/implicitWait.js +0 -12
  81. package/build/utils/refetchElement.js +2 -15
  82. package/build/utils.js +3 -119
  83. package/package.json +3 -3
  84. package/webdriverio-core.d.ts +0 -8
package/build/utils.js CHANGED
@@ -56,48 +56,23 @@ const applyScopePrototype = (prototype, scope) => {
56
56
  };
57
57
  });
58
58
  };
59
- /**
60
- * enhances objects with element commands
61
- */
62
-
63
59
 
64
60
  const getPrototype = scope => {
65
61
  const prototype = {};
66
- /**
67
- * register action commands
68
- */
69
-
70
62
  applyScopePrototype(prototype, scope);
71
63
  return prototype;
72
64
  };
73
- /**
74
- * get element id from WebDriver response
75
- * @param {?Object|undefined} res body object from response or null
76
- * @return {?string} element id or null if element couldn't be found
77
- */
78
-
79
65
 
80
66
  exports.getPrototype = getPrototype;
81
67
 
82
68
  const getElementFromResponse = res => {
83
- /**
84
- * a function selector can return null
85
- */
86
69
  if (!res) {
87
70
  return null;
88
71
  }
89
- /**
90
- * deprecated JSONWireProtocol response
91
- */
92
-
93
72
 
94
73
  if (res.ELEMENT) {
95
74
  return res.ELEMENT;
96
75
  }
97
- /**
98
- * W3C WebDriver response
99
- */
100
-
101
76
 
102
77
  if (res[_constants.ELEMENT_KEY]) {
103
78
  return res[_constants.ELEMENT_KEY];
@@ -105,20 +80,12 @@ const getElementFromResponse = res => {
105
80
 
106
81
  return null;
107
82
  };
108
- /**
109
- * traverse up the scope chain until browser element was reached
110
- */
111
-
112
83
 
113
84
  exports.getElementFromResponse = getElementFromResponse;
114
85
 
115
86
  function getBrowserObject(elem) {
116
87
  return elem.parent ? getBrowserObject(elem.parent) : elem;
117
88
  }
118
- /**
119
- * transform whatever value is into an array of char strings
120
- */
121
-
122
89
 
123
90
  function transformToCharString(value) {
124
91
  const ret = [];
@@ -136,9 +103,7 @@ function transformToCharString(value) {
136
103
  } else if (val && typeof val === 'object') {
137
104
  try {
138
105
  ret.push(...JSON.stringify(val).split(''));
139
- } catch (e) {
140
- /* ignore */
141
- }
106
+ } catch (e) {}
142
107
  } else if (typeof val === 'boolean') {
143
108
  const entry = val ? 'true'.split('') : 'false'.split('');
144
109
  ret.push(...entry);
@@ -149,20 +114,12 @@ function transformToCharString(value) {
149
114
  }
150
115
 
151
116
  function sanitizeCSS(value) {
152
- /* istanbul ignore next */
153
117
  if (!value) {
154
118
  return value;
155
119
  }
156
120
 
157
121
  return value.trim().replace(/'/g, '').replace(/"/g, '').toLowerCase();
158
122
  }
159
- /**
160
- * parse css values to a better format
161
- * @param {Object} cssPropertyValue result of WebDriver call
162
- * @param {String} cssProperty name of css property to parse
163
- * @return {Object} parsed css property
164
- */
165
-
166
123
 
167
124
  function parseCSS(cssPropertyValue, cssProperty) {
168
125
  if (!cssPropertyValue) {
@@ -175,14 +132,7 @@ function parseCSS(cssPropertyValue, cssProperty) {
175
132
  };
176
133
 
177
134
  if (parsedValue.value.indexOf('rgb') === 0) {
178
- /**
179
- * remove whitespaces in rgb values
180
- */
181
135
  parsedValue.value = parsedValue.value.replace(/\s/g, '');
182
- /**
183
- * parse color values
184
- */
185
-
186
136
  let color = parsedValue.value;
187
137
  parsedValue.parsed = (0, _rgb2hex.default)(parsedValue.value);
188
138
  parsedValue.parsed.type = 'color';
@@ -198,9 +148,6 @@ function parseCSS(cssPropertyValue, cssProperty) {
198
148
  string
199
149
  };
200
150
  } else {
201
- /**
202
- * parse other css properties
203
- */
204
151
  try {
205
152
  parsedValue.parsed = (0, _cssValue.default)(cssPropertyValue);
206
153
 
@@ -211,19 +158,11 @@ function parseCSS(cssPropertyValue, cssProperty) {
211
158
  if (parsedValue.parsed.type && parsedValue.parsed.type === 'number' && parsedValue.parsed.unit === '') {
212
159
  parsedValue.value = parsedValue.parsed.value;
213
160
  }
214
- } catch (e) {// TODO improve css-parse lib to handle properties like
215
- // `-webkit-animation-timing-function : cubic-bezier(0.25, 0.1, 0.25, 1)
216
- }
161
+ } catch (e) {}
217
162
  }
218
163
 
219
164
  return parsedValue;
220
165
  }
221
- /**
222
- * check for unicode character or split string into literals
223
- * @param {String} value text
224
- * @return {Array} set of characters or unicode symbols
225
- */
226
-
227
166
 
228
167
  function checkUnicode(value) {
229
168
  return Object.prototype.hasOwnProperty.call(_constants.UNICODE_CHARACTERS, value) ? [_constants.UNICODE_CHARACTERS[value]] : new _graphemeSplitter.default().splitGraphemes(value);
@@ -233,10 +172,6 @@ function fetchElementByJSFunction(selector, scope) {
233
172
  if (!scope.elementId) {
234
173
  return scope.execute(selector);
235
174
  }
236
- /**
237
- * use a regular function because IE does not understand arrow functions
238
- */
239
-
240
175
 
241
176
  const script = function (elem) {
242
177
  return selector.call(elem);
@@ -244,15 +179,8 @@ function fetchElementByJSFunction(selector, scope) {
244
179
 
245
180
  return getBrowserObject(scope).execute(`return (${script}).apply(null, arguments)`, scope);
246
181
  }
247
- /**
248
- * logic to find an element
249
- */
250
-
251
182
 
252
183
  async function findElement(selector) {
253
- /**
254
- * fetch element using regular protocol command
255
- */
256
184
  if (typeof selector === 'string') {
257
185
  const {
258
186
  using,
@@ -260,10 +188,6 @@ async function findElement(selector) {
260
188
  } = (0, _findStrategy.findStrategy)(selector, this.isW3C, this.isMobile);
261
189
  return this.elementId ? this.findElementFromElement(this.elementId, using, value) : this.findElement(using, value);
262
190
  }
263
- /**
264
- * fetch element with JS function
265
- */
266
-
267
191
 
268
192
  if (typeof selector === 'function') {
269
193
  const notFoundError = new Error(`Function selector "${selector.toString()}" did not return an HTMLElement`);
@@ -274,15 +198,8 @@ async function findElement(selector) {
274
198
 
275
199
  throw new Error(INVALID_SELECTOR_ERROR);
276
200
  }
277
- /**
278
- * logic to find a elements
279
- */
280
-
281
201
 
282
202
  async function findElements(selector) {
283
- /**
284
- * fetch element using regular protocol command
285
- */
286
203
  if (typeof selector === 'string') {
287
204
  const {
288
205
  using,
@@ -290,10 +207,6 @@ async function findElements(selector) {
290
207
  } = (0, _findStrategy.findStrategy)(selector, this.isW3C, this.isMobile);
291
208
  return this.elementId ? this.findElementsFromElement(this.elementId, using, value) : this.findElements(using, value);
292
209
  }
293
- /**
294
- * fetch element with JS function
295
- */
296
-
297
210
 
298
211
  if (typeof selector === 'function') {
299
212
  let elems = await fetchElementByJSFunction(selector, this);
@@ -303,10 +216,6 @@ async function findElements(selector) {
303
216
 
304
217
  throw new Error(INVALID_SELECTOR_ERROR);
305
218
  }
306
- /**
307
- * Strip element object and return w3c and jsonwp compatible keys
308
- */
309
-
310
219
 
311
220
  function verifyArgsAndStripIfElement(args) {
312
221
  function verify(arg) {
@@ -326,10 +235,6 @@ function verifyArgsAndStripIfElement(args) {
326
235
 
327
236
  return !Array.isArray(args) ? verify(args) : args.map(verify);
328
237
  }
329
- /**
330
- * getElementRect
331
- */
332
-
333
238
 
334
239
  async function getElementRect(scope) {
335
240
  const rect = await scope.getElementRect(scope.elementId);
@@ -338,15 +243,9 @@ async function getElementRect(scope) {
338
243
  y: 0,
339
244
  width: 0,
340
245
  height: 0
341
- /**
342
- * getElementRect workaround for Safari 12.0.3
343
- * if one of [x, y, height, width] is undefined get rect with javascript
344
- */
345
-
346
246
  };
347
247
 
348
248
  if (Object.keys(defaults).some(key => rect[key] == null)) {
349
- /* istanbul ignore next */
350
249
  const rectJs = await getBrowserObject(scope).execute(function (el) {
351
250
  if (!el || !el.getBoundingClientRect) {
352
251
  return;
@@ -364,8 +263,7 @@ async function getElementRect(scope) {
364
263
  width,
365
264
  height
366
265
  };
367
- }, scope); // try set proper value
368
-
266
+ }, scope);
369
267
  Object.keys(defaults).forEach(key => {
370
268
  if (rect[key] != null) {
371
269
  return;
@@ -390,32 +288,18 @@ async function getElementRect(scope) {
390
288
  function getAbsoluteFilepath(filepath) {
391
289
  return filepath.startsWith('/') || filepath.startsWith('\\') || filepath.match(/^[a-zA-Z]:\\/) ? filepath : _path.default.join(process.cwd(), filepath);
392
290
  }
393
- /**
394
- * check if directory exists
395
- */
396
-
397
291
 
398
292
  function assertDirectoryExists(filepath) {
399
293
  if (!_fs.default.existsSync(_path.default.dirname(filepath))) {
400
294
  throw new Error(`directory (${_path.default.dirname(filepath)}) doesn't exist`);
401
295
  }
402
296
  }
403
- /**
404
- * check if urls are valid and fix them if necessary
405
- * @param {string} url url to navigate to
406
- * @param {Boolean} [retryCheck=false] true if an url was already check and still failed with fix applied
407
- * @return {string} fixed url
408
- */
409
-
410
297
 
411
298
  function validateUrl(url, origError) {
412
299
  try {
413
300
  const urlObject = new _url.URL(url);
414
301
  return urlObject.href;
415
302
  } catch (e) {
416
- /**
417
- * if even adding http:// doesn't help, fail with original error
418
- */
419
303
  if (origError) {
420
304
  throw origError;
421
305
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "webdriverio",
3
3
  "description": "Next-gen WebDriver test automation framework for Node.js",
4
- "version": "5.11.11",
4
+ "version": "5.11.12",
5
5
  "homepage": "https://webdriver.io",
6
6
  "author": "Christian Bromann <christian@saucelabs.com>",
7
7
  "license": "MIT",
@@ -68,7 +68,7 @@
68
68
  "resq": "^1.5.0",
69
69
  "rgb2hex": "^0.1.0",
70
70
  "serialize-error": "^4.1.0",
71
- "webdriver": "^5.11.10"
71
+ "webdriver": "^5.11.12"
72
72
  },
73
- "gitHead": "edf3ebf2f7ed4cbe2c041926c0c24ffbe19e320b"
73
+ "gitHead": "32d9805f8dee10f0665e31eed14f774aaa48c914"
74
74
  }
@@ -139,14 +139,6 @@ declare namespace WebdriverIO {
139
139
 
140
140
  afterSuite?(suite: Suite): void;
141
141
  afterTest?(test: Test): void;
142
-
143
- // cucumber specific hooks
144
- beforeFeature?(uri: any, feature: any): void;
145
- beforeScenario?(uri: any, feature: any, scenario: any): void;
146
- beforeStep?(uri: any, feature: any, scenario: any, step: any): void;
147
- afterFeature?(uri: any, feature: any, scenario: any, step: any, result: any): void;
148
- afterScenario?(uri: any, feature: any, scenario: any, result: {status: string, duration: number}): void;
149
- afterStep?(uri: any, feature: any): void;
150
142
  }
151
143
  type _HooksArray = {
152
144
  [K in keyof Pick<HookFunctions, "onPrepare" | "onComplete" | "before" | "after" | "beforeSession" | "afterSession">]: HookFunctions[K] | Array<HookFunctions[K]>;