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
@@ -13,47 +13,9 @@ var _isDisplayedInViewport = _interopRequireDefault(require("../../scripts/isDis
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
- /**
17
- *
18
- * Return true if the selected DOM-element found by given selector is visible and within the viewport.
19
- *
20
- * <example>
21
- :index.html
22
- <div id="notDisplayed" style="display: none"></div>
23
- <div id="notVisible" style="visibility: hidden"></div>
24
- <div id="notInViewport" style="position:absolute; left: 9999999"></div>
25
- <div id="zeroOpacity" style="opacity: 0"></div>
26
- :isDisplayedInViewport.js
27
- :isDisplayed.js
28
- it('should detect if an element is visible', () => {
29
- let isDisplayedInViewport = $('#notDisplayed').isDisplayedInViewport();
30
- console.log(isDisplayedInViewport); // outputs: false
31
-
32
- isDisplayedInViewport = $('#notVisible').isDisplayedInViewport();
33
- console.log(isDisplayedInViewport); // outputs: false
34
-
35
- isDisplayedInViewport = $('#notExisting').isDisplayedInViewport();
36
- console.log(isDisplayedInViewport); // outputs: false
37
-
38
- isDisplayedInViewport = $('#notInViewport').isDisplayedInViewport();
39
- console.log(isDisplayedInViewport); // outputs: false
40
-
41
- isDisplayedInViewport = $('#zeroOpacity').isDisplayedInViewport();
42
- console.log(isDisplayedInViewport); // outputs: false
43
- });
44
- * </example>
45
- *
46
- * @alias element.isDisplayedInViewport
47
- * @return {Boolean} true if element(s)* [is|are] displayed
48
- * @uses protocol/selectorExecute, protocol/timeoutsAsyncScript
49
- * @type state
50
- *
51
- */
52
16
  function isDisplayedInViewport() {
53
17
  return (0, _utils.getBrowserObject)(this).execute(_isDisplayedInViewport.default, {
54
18
  [_constants.ELEMENT_KEY]: this.elementId,
55
- // w3c compatible
56
- ELEMENT: this.elementId // jsonwp compatible
57
-
19
+ ELEMENT: this.elementId
58
20
  });
59
21
  }
@@ -5,38 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = isEnabled;
7
7
 
8
- /**
9
- *
10
- * Return true or false if the selected DOM-element is enabled.
11
- *
12
- * <example>
13
- :index.html
14
- <input type="text" name="inputField" class="input1">
15
- <input type="text" name="inputField" class="input2" disabled>
16
- <input type="text" name="inputField" class="input3" disabled="disabled">
17
-
18
- :isEnabled.js
19
- it('should detect if an element is enabled', () => {
20
- let elem = $('.input1')
21
- let isEnabled = elem.isEnabled();
22
- console.log(isEnabled); // outputs: true
23
-
24
- elem = $('.input2')
25
- isEnabled = elem.isEnabled();
26
- console.log(isEnabled2); // outputs: false
27
-
28
- elem = $('.input3')
29
- isEnabled = elem.isEnabled();
30
- console.log(isEnabled3); // outputs: false
31
- });
32
- * </example>
33
- *
34
- * @alias element.isEnabled
35
- * @return {Boolean} true if element(s)* (is|are) enabled
36
- * @uses protocol/elements, protocol/elementIdEnabled
37
- * @type state
38
- *
39
- */
40
8
  function isEnabled() {
41
9
  return this.isElementEnabled(this.elementId);
42
10
  }
@@ -5,46 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = isExisting;
7
7
 
8
- /**
9
- *
10
- * Returns true if element exists in the DOM
11
- *
12
- * <example>
13
- :index.html
14
- <div id="notDisplayed" style="display: none"></div>
15
- <div id="notVisible" style="visibility: hidden"></div>
16
- <div id="notInViewport" style="position:absolute; left: 9999999"></div>
17
- <div id="zeroOpacity" style="opacity: 0"></div>
18
- :isExisting.js
19
- it('should detect if elements are existing', () => {
20
- let elem = $('#someRandomNonExistingElement')
21
- let isExisting = elem.isExisting()
22
- console.log(isExisting); // outputs: false
23
-
24
- elem = $('#notDisplayed')
25
- isExisting = elem.isExisting()
26
- console.log(isExisting); // outputs: true
27
-
28
- elem = $('#notVisible')
29
- isExisting = elem.isExisting()
30
- console.log(isExisting); // outputs: true
31
-
32
- elem = $('#notInViewport')
33
- isExisting = elem.isExisting()
34
- console.log(isExisting); // outputs: true
35
-
36
- elem = $('#zeroOpacity')
37
- isExisting = elem.isExisting()
38
- console.log(isExisting); // outputs: true
39
- });
40
- * </example>
41
- *
42
- * @alias element.isExisting
43
- * @return {Boolean} true if element(s)* [is|are] existing
44
- * @uses protocol/elements
45
- * @type state
46
- *
47
- */
48
8
  function isExisting() {
49
9
  return this.parent.$$(this.selector).then(res => res.length > 0);
50
10
  }
@@ -13,37 +13,9 @@ var _isFocused = _interopRequireDefault(require("../../scripts/isFocused"));
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
- /**
17
- *
18
- * Return true or false if the selected DOM-element currently has focus. If the selector matches
19
- * multiple elements, it will return true if one of the elements has focus.
20
- *
21
- * <example>
22
- :index.html
23
- <input name="login" autofocus="" />
24
- :hasFocus.js
25
- it('should detect the focus of an element', () => {
26
- browser.url('/');
27
- const loginInput = $('[name="login"]');
28
- console.log(loginInput.isFocused()); // outputs: false
29
-
30
- loginInput.click();
31
- console.log(loginInput.isFocused()); // outputs: true
32
- })
33
- * </example>
34
- *
35
- * @alias element.isFocused
36
- * @return {Boolean} true if one of the matching elements has focus
37
- *
38
- * @uses protocol/execute
39
- * @type state
40
- *
41
- */
42
16
  function isFocused() {
43
17
  return (0, _utils.getBrowserObject)(this).execute(_isFocused.default, {
44
18
  [_constants.ELEMENT_KEY]: this.elementId,
45
- // w3c compatible
46
- ELEMENT: this.elementId // jsonwp compatible
47
-
19
+ ELEMENT: this.elementId
48
20
  });
49
21
  }
@@ -5,35 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = isSelected;
7
7
 
8
- /**
9
- *
10
- * Will return true or false whether or not an `<option>` or `<input>` element of type
11
- * checkbox or radio is currently selected.
12
- *
13
- * <example>
14
- :index.html
15
- <select name="selectbox" id="selectbox">
16
- <option value="John Doe">John Doe</option>
17
- <option value="Layla Terry" selected="selected">Layla Terry</option>
18
- <option value="Bill Gilbert">Bill Gilbert"</option>
19
- </select>
20
-
21
- :isSelected.js
22
- it('should detect if an element is selected', () => {
23
- let element = $('[value="Layla Terry"]');
24
- console.log(element.isSelected()); // outputs: true
25
-
26
- element = $('[value="Bill Gilbert"]')
27
- console.log(element.isSelected()); // outputs: false
28
- });
29
- * </example>
30
- *
31
- * @alias element.isSelected
32
- * @return {Boolean} true if element is selected
33
- * @uses protocol/elements, protocol/elementIdSelected
34
- * @type state
35
- *
36
- */
37
8
  function isSelected() {
38
9
  return this.isElementSelected(this.elementId);
39
10
  }
@@ -7,27 +7,10 @@ exports.default = moveTo;
7
7
 
8
8
  var _utils = require("../../utils");
9
9
 
10
- /**
11
- *
12
- * Move the mouse by an offset of the specified element. If no element is specified,
13
- * the move is relative to the current mouse cursor. If an element is provided but
14
- * no offset, the mouse will be moved to the center of the element. If the element
15
- * is not visible, it will be scrolled into view.
16
- *
17
- * @param {Number=} xoffset X offset to move to, relative to the top-left corner of the element. If not specified, the mouse will move to the middle of the element.
18
- * @param {Number=} yoffset Y offset to move to, relative to the top-left corner of the element. If not specified, the mouse will move to the middle of the element.
19
- *
20
- * @see https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#sessionsessionidmoveto
21
- * @type protocol
22
- */
23
10
  async function moveTo(xoffset, yoffset) {
24
11
  if (!this.isW3C) {
25
12
  return this.moveToElement(this.elementId, xoffset, yoffset);
26
13
  }
27
- /**
28
- * get rect of element
29
- */
30
-
31
14
 
32
15
  const {
33
16
  x,
@@ -37,10 +20,6 @@ async function moveTo(xoffset, yoffset) {
37
20
  } = await (0, _utils.getElementRect)(this);
38
21
  const newXoffset = parseInt(x + (typeof xoffset === 'number' ? xoffset : width / 2), 10);
39
22
  const newYoffset = parseInt(y + (typeof yoffset === 'number' ? yoffset : height / 2), 10);
40
- /**
41
- * W3C way of handle the mouse move actions
42
- */
43
-
44
23
  return this.performActions([{
45
24
  type: 'pointer',
46
25
  id: 'finger1',
@@ -13,31 +13,6 @@ var _resq = require("../../scripts/resq");
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
- /**
17
- *
18
- * The `react$$` command is a useful command to query multiple React Components
19
- * by their actual name and filter them by props and state.
20
- *
21
- * **NOTE:** the command only works with applications using React v16.x
22
- *
23
- * <example>
24
- :pause.js
25
- it('should calculate 7 * 6', () => {
26
- browser.url('https://ahfarmer.github.io/calculator/');
27
- const appWrapper = browser.$('div#root')
28
-
29
- const orangeButtons = appWrapper.react$$('t', { orange: true })
30
- console.log(orangeButtons.map((btn) => btn.getText())); // prints "[ '÷', 'x', '-', '+', '=' ]"
31
- });
32
- * </example>
33
- *
34
- * @alias react$$
35
- * @param {String} selector of React component
36
- * @param {Object=} props React props the element should contain
37
- * @param {Array<any>|number|string|object|boolean=} state React state the element should be in
38
- * @return {Element[]}
39
- *
40
- */
41
16
  const resqScript = _fs.default.readFileSync(require.resolve('resq'));
42
17
 
43
18
  async function react$$(selector, props = {}, state = {}) {
@@ -13,35 +13,6 @@ var _resq = require("../../scripts/resq");
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
- /**
17
- *
18
- * The `react$` command is a useful command to query React Components by their
19
- * actual name and filter them by props and state.
20
- *
21
- * **NOTE:** the command only works with applications using React v16.x
22
- *
23
- * <example>
24
- :pause.js
25
- it('should calculate 7 * 6', () => {
26
- browser.url('https://ahfarmer.github.io/calculator/');
27
- const appWrapper = browser.$('div#root')
28
-
29
- appWrapper.react$('t', { name: '7' }).click()
30
- appWrapper.react$('t', { name: 'x' }).click()
31
- appWrapper.react$('t', { name: '6' }).click()
32
- appWrapper.react$('t', { name: '=' }).click()
33
-
34
- console.log($('.component-display').getText()); // prints "42"
35
- });
36
- * </example>
37
- *
38
- * @alias react$
39
- * @param {String} selector of React component
40
- * @param {Object=} props React props the element should contain
41
- * @param {Array<any>|number|string|object|boolean=} state React state the element should be in
42
- * @return {Element}
43
- *
44
- */
45
16
  const resqScript = _fs.default.readFileSync(require.resolve('resq'));
46
17
 
47
18
  async function react$(selector, props = {}, state = {}) {
@@ -11,28 +11,7 @@ var _utils = require("../../utils");
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
14
- /**
15
- *
16
- * Save a screenshot of an element to a PNG file on your OS.
17
- *
18
- * <example>
19
- :saveScreenshot.js
20
- it('should save a screenshot of the browser view', function () {
21
- const elem = $('#someElem');
22
- elem.saveScreenshot('./some/path/elemScreenshot.png');
23
- });
24
- * </example>
25
- *
26
- * @alias element.saveScreenshot
27
- * @param {String} filename path to the generated image (`.png` suffix is required) relative to the execution directory
28
- * @return {Buffer} screenshot buffer
29
- * @type utility
30
- *
31
- */
32
14
  async function saveScreenshot(filepath) {
33
- /**
34
- * type check
35
- */
36
15
  if (typeof filepath !== 'string' || !filepath.endsWith('.png')) {
37
16
  throw new Error('saveScreenshot expects a filepath of type string and ".png" file ending');
38
17
  }
@@ -7,35 +7,11 @@ exports.default = scrollIntoView;
7
7
 
8
8
  var _constants = require("../../constants");
9
9
 
10
- /**
11
- *
12
- * Scroll element into viewport.
13
- * https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
14
- *
15
- * <example>
16
- :scrollIntoView.js
17
- it('should demonstrate the scrollIntoView command', () => {
18
- const elem = $('#myElement');
19
- // scroll to specific element
20
- elem.scrollIntoView();
21
- });
22
- * </example>
23
- *
24
- * @alias element.scrollIntoView
25
- * @param {object|boolean=} scrollIntoViewOptions boolean alignToTop or scrollIntoViewOptions object
26
- * @uses protocol/execute
27
- * @type utility
28
- *
29
- */
30
10
  function scrollIntoView(scrollIntoViewOptions = true) {
31
- return this.parent.execute(
32
- /* istanbul ignore next */
33
- function (elem, options) {
11
+ return this.parent.execute(function (elem, options) {
34
12
  elem.scrollIntoView(options);
35
13
  }, {
36
14
  [_constants.ELEMENT_KEY]: this.elementId,
37
- // w3c compatible
38
- ELEMENT: this.elementId // jsonwp compatible
39
-
15
+ ELEMENT: this.elementId
40
16
  }, scrollIntoViewOptions);
41
17
  }
@@ -7,55 +7,9 @@ exports.default = selectByAttribute;
7
7
 
8
8
  var _utils = require("../../utils");
9
9
 
10
- /**
11
- *
12
- * Select option with a specific value.
13
- *
14
- * <example>
15
- :example.html
16
- <select id="selectbox">
17
- <option value="someValue0">uno</option>
18
- <option value="someValue1">dos</option>
19
- <option value="someValue2">tres</option>
20
- <option value="someValue3">cuatro</option>
21
- <option value="someValue4">cinco</option>
22
- <option name="someName5" value="someValue5">seis</option>
23
- </select>
24
- :selectByAttribute.js
25
- it('Should demonstrate the selectByAttribute command', () => {
26
- const selectBox = $('#selectbox');
27
- const value = selectBox.getValue();
28
- console.log(value); // returns "someValue0"
29
-
30
- selectBox.selectByAttribute('value', 'someValue3');
31
- console.log(selectBox.getValue()); // returns "someValue3"
32
-
33
- selectBox.selectByAttribute('name', 'someName5');
34
- console.log(selectBox.getValue()); // returns "someValue5"
35
- });
36
- * </example>
37
- *
38
- * @alias element.selectByAttribute
39
- * @param {String} attribute attribute of option element to get selected
40
- * @param {String} value value of option element to get selected
41
- * @uses protocol/findElementFromElement, protocol/elementClick
42
- * @type action
43
- *
44
- */
45
10
  async function selectByAttribute(attribute, value) {
46
- /**
47
- * convert value into string
48
- */
49
11
  value = typeof value === 'number' ? value.toString() : value;
50
- /**
51
- * find option elememnt using xpath
52
- */
53
-
54
12
  const normalized = `[normalize-space(@${attribute.trim()}) = "${value.trim()}"]`;
55
13
  const optionElement = await this.findElementFromElement(this.elementId, 'xpath', `./option${normalized}|./optgroup/option${normalized}`);
56
- /**
57
- * select option
58
- */
59
-
60
14
  return this.elementClick((0, _utils.getElementFromResponse)(optionElement));
61
15
  }
@@ -7,46 +7,10 @@ exports.default = selectByIndex;
7
7
 
8
8
  var _utils = require("../../utils");
9
9
 
10
- /**
11
- *
12
- * Select option with a specific index.
13
- *
14
- * <example>
15
- :example.html
16
- <select id="selectbox">
17
- <option value="someValue0">uno</option>
18
- <option value="someValue1">dos</option>
19
- <option value="someValue2">tres</option>
20
- <option value="someValue3">cuatro</option>
21
- <option value="someValue4">cinco</option>
22
- <option value="someValue5">seis</option>
23
- </select>
24
- :selectByIndex.js
25
- it('Should demonstrate the selectByIndex command', () => {
26
- const selectBox = $('#selectbox');
27
- console.log(selectBox.getValue()); // returns "someValue0"
28
- selectBox.selectByIndex(4);
29
- console.log(selectBox.getValue()); // returns "someValue4"
30
- });
31
- * </example>
32
- *
33
- * @alias element.selectByIndexs
34
- * @param {Number} index option index
35
- * @uses protocol/findElementsFromElement, protocol/elementClick
36
- * @type action
37
- *
38
- */
39
10
  async function selectByIndex(index) {
40
- /**
41
- * negative index check
42
- */
43
11
  if (index < 0) {
44
12
  throw new Error('Index needs to be 0 or any other positive number');
45
13
  }
46
- /**
47
- * get option elememnts using css
48
- */
49
-
50
14
 
51
15
  const optionElements = await this.findElementsFromElement(this.elementId, 'css selector', 'option');
52
16
 
@@ -57,10 +21,6 @@ async function selectByIndex(index) {
57
21
  if (optionElements.length - 1 < index) {
58
22
  throw new Error(`Option with index "${index}" not found. Select element only contains ${optionElements.length} option elements`);
59
23
  }
60
- /**
61
- * select option
62
- */
63
-
64
24
 
65
25
  return this.elementClick((0, _utils.getElementFromResponse)(optionElements[index]));
66
26
  }
@@ -7,55 +7,13 @@ exports.default = selectByVisibleText;
7
7
 
8
8
  var _utils = require("../../utils");
9
9
 
10
- /**
11
- *
12
- * Select option with displayed text matching the argument.
13
- *
14
- * <example>
15
- :example.html
16
- <select id="selectbox">
17
- <option value="someValue0">uno</option>
18
- <option value="someValue1">dos</option>
19
- <option value="someValue2">tres</option>
20
- <option value="someValue3">cuatro</option>
21
- <option value="someValue4">cinco</option>
22
- <option value="someValue5">seis</option>
23
- </select>
24
- :selectByVisibleText.js
25
- it('demonstrate the selectByVisibleText command', () => {
26
- const selectBox = $('#selectbox');
27
- console.log(selectBox.getText('option:checked')); // returns "uno"
28
- selectBox.selectByVisibleText('cuatro');
29
- console.log(selectBox.getText('option:checked')); // returns "cuatro"
30
- })
31
- * </example>
32
- *
33
- * @alias element.selectByVisibleText
34
- * @param {String} text text of option element to get selected
35
- * @uses protocol/findElementsFromElement, protocol/elementClick
36
- * @type action
37
- *
38
- */
39
10
  async function selectByVisibleText(text) {
40
- /**
41
- * convert value into string
42
- */
43
11
  text = typeof text === 'number' ? text.toString() : text;
44
- const normalized = text.trim() // strip leading and trailing white-space characters
45
- .replace(/\s+/, ' '); // replace sequences of whitespace characters by a single space
46
-
47
- /**
48
- * find option element using xpath
49
- */
50
-
12
+ const normalized = text.trim().replace(/\s+/, ' ');
51
13
  const formatted = /"/.test(normalized) ? 'concat("' + normalized.split('"').join('", \'"\', "') + '")' : `"${normalized}"`;
52
14
  const dotFormat = `[. = ${formatted}]`;
53
15
  const spaceFormat = `[normalize-space(text()) = ${formatted}]`;
54
16
  const selections = [`./option${dotFormat}`, `./option${spaceFormat}`, `./optgroup/option${dotFormat}`, `./optgroup/option${spaceFormat}`];
55
17
  const optionElement = await this.findElementFromElement(this.elementId, 'xpath', selections.join('|'));
56
- /**
57
- * select option
58
- */
59
-
60
18
  return this.elementClick((0, _utils.getElementFromResponse)(optionElement));
61
19
  }
@@ -5,31 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = setValue;
7
7
 
8
- /**
9
- *
10
- * Send a sequence of key strokes to an element (clears value before). If the element
11
- * doesn't need to be cleared first then use addValue. You can also use
12
- * unicode characters like Left arrow or Back space. WebdriverIO will take care of
13
- * translating them into unicode characters. You’ll find all supported characters
14
- * [here](https://w3c.github.io/webdriver/webdriver-spec.html#keyboard-actions).
15
- * To do that, the value has to correspond to a key from the table.
16
- *
17
- * <example>
18
- :setValue.js
19
- it('should set value for a certain element', () => {
20
- const input = $('.input');
21
- input.setValue('test123');
22
-
23
- console.log(input.getValue()); // outputs: 'test123'
24
- });
25
- * </example>
26
- *
27
- * @alias element.setValue
28
- * @param {string | number | boolean | object | Array<any>} value Value to be added
29
- * @uses protocol/elements, protocol/elementIdClear, protocol/elementIdValue
30
- * @type action
31
- *
32
- */
33
8
  async function setValue(value) {
34
9
  await this.clearValue();
35
10
  return this.addValue(value);
@@ -7,24 +7,6 @@ exports.default = shadowRoot;
7
7
 
8
8
  var _shadowFnFactory = require("../../scripts/shadowFnFactory");
9
9
 
10
- /**
11
- *
12
- * Access elements inside a given element's shadowRoot
13
- *
14
- * <example>
15
- :shadow$$.js
16
- it('should return elements inside a shadowRoot', () => {
17
- const innerEl = $('.input').shadow$$('#innerEl');
18
- console.log(innerEl.getValue()); // outputs: 'test123'
19
- });
20
- * </example>
21
- *
22
- * @alias element.shadow$$
23
- * @param {String|Function} selector selector or JS Function to fetch a certain element
24
- * @return {Element[]}
25
- * @type utility
26
- *
27
- */
28
10
  async function shadowRoot(selector) {
29
11
  return await this.$$((0, _shadowFnFactory.shadowFnFactory)(selector, true));
30
12
  }
@@ -7,24 +7,6 @@ exports.default = shadowRoot;
7
7
 
8
8
  var _shadowFnFactory = require("../../scripts/shadowFnFactory");
9
9
 
10
- /**
11
- *
12
- * Access an element inside a given element's shadowRoot
13
- *
14
- * <example>
15
- :shadow$$.js
16
- it('should return an element inside a shadowRoot', () => {
17
- const innerEl = $('.input').shadow$('#innerEl');
18
- console.log(innerEl.getValue()); // outputs: 'test123'
19
- });
20
- * </example>
21
- *
22
- * @alias element.shadow$
23
- * @param {String|Function} selector selector or JS Function to fetch a certain element
24
- * @return {Element}
25
- * @type utility
26
- *
27
- */
28
10
  async function shadowRoot(selector) {
29
11
  return await this.$((0, _shadowFnFactory.shadowFnFactory)(selector));
30
12
  }