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
@@ -9,33 +9,8 @@ var _request = _interopRequireDefault(require("webdriver/build/request"));
9
9
 
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
 
12
- /**
13
- *
14
- * Creates a new Selenium session with your current capabilities. This is useful if you
15
- * test highly stateful application where you need to clean the browser session between
16
- * the tests in your spec file to avoid creating hundreds of single test files with WDIO.
17
- * Be careful though, this command affects your test time tremendously since spawning
18
- * new Selenium sessions is very time consuming especially when using cloud services.
19
- *
20
- * <example>
21
- :reloadSync.js
22
- it('should reload my session with current capabilities', () => {
23
- console.log(browser.sessionId) // outputs: e042b3f3cd5a479da4e171825e96e655
24
- browser.reloadSession()
25
- console.log(browser.sessionId) // outputs: 9a0d9bf9d4864160aa982c50cf18a573
26
- })
27
- * </example>
28
- *
29
- * @alias browser.reloadSession
30
- * @type utility
31
- *
32
- */
33
12
  async function reloadSession() {
34
13
  const oldSessionId = this.sessionId;
35
- /**
36
- * end current running session
37
- */
38
-
39
14
  await this.deleteSession();
40
15
  const {
41
16
  w3cCaps,
@@ -43,9 +18,7 @@ async function reloadSession() {
43
18
  } = this.options.requestedCapabilities;
44
19
  const sessionRequest = new _request.default('POST', '/session', {
45
20
  capabilities: w3cCaps,
46
- // W3C compliant
47
- desiredCapabilities: jsonwpCaps // JSONWP compliant
48
-
21
+ desiredCapabilities: jsonwpCaps
49
22
  });
50
23
  const response = await sessionRequest.makeRequest(this.options);
51
24
  const newSessionId = response.sessionId || response.value && response.value.sessionId;
@@ -11,30 +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
- * Appium only. Save a video started by startRecordingScreen command to file.
17
- * See [Appium docs](http://appium.io/docs/en/commands/device/recording-screen/start-recording-screen/)
18
- *
19
- * <example>
20
- :saveRecordingScreen.js
21
- it('should save a video', () => {
22
- browser.startRecordingScreen();
23
- $('~BUTTON').click();
24
- browser.saveRecordingScreen('./some/path/video.mp4');
25
- });
26
- * </example>
27
- *
28
- * @alias browser.saveRecordingScreen
29
- * @param {String} filepath full or relative to the execution directory path to the generated video
30
- * @return {Buffer} video buffer
31
- * @type utility
32
- *
33
- */
34
14
  async function saveRecordingScreen(filepath) {
35
- /**
36
- * type check
37
- */
38
15
  if (typeof filepath !== 'string') {
39
16
  throw new Error('saveRecordingScreen expects a filepath');
40
17
  }
@@ -11,29 +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 the current browsing context to a PNG file on your OS. Be aware that
17
- * some browser drivers take screenshots of the whole document (e.g. Geckodriver with Firefox)
18
- * and others only of the current viewport (e.g. Chromedriver with Chrome).
19
- *
20
- * <example>
21
- :saveScreenshot.js
22
- it('should save a screenshot of the browser view', function () {
23
- browser.saveScreenshot('./some/path/screenshot.png');
24
- });
25
- * </example>
26
- *
27
- * @alias browser.saveScreenshot
28
- * @param {String} filepath path to the generated image (`.png` suffix is required) relative to the execution directory
29
- * @return {Buffer} screenshot buffer
30
- * @type utility
31
- *
32
- */
33
14
  async function saveScreenshot(filepath) {
34
- /**
35
- * type check
36
- */
37
15
  if (typeof filepath !== 'string' || !filepath.endsWith('.png')) {
38
16
  throw new Error('saveScreenshot expects a filepath of type string and ".png" file ending');
39
17
  }
@@ -5,52 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = setCookies;
7
7
 
8
- /**
9
- *
10
- * Sets one or more [cookies](https://w3c.github.io/webdriver/#cookies) for the current page. Make sure you are
11
- * on the page that should receive the cookie. You can't set a cookie for an arbitrary page without
12
- * being on that page.
13
- *
14
- * <example>
15
- :setCookies.js
16
- it('should set a cookie for the page', () => {
17
- browser.url('/')
18
-
19
- // set a single cookie
20
- browser.setCookies({
21
- name: 'test1',
22
- value: 'one'
23
- // The below options are optional
24
- // path: '/foo', // The cookie path. Defaults to "/"
25
- // domain: '.example.com', // The domain the cookie is visible to. Defaults to the current browsing context’s active document’s URL domain
26
- // secure: true, // Whether the cookie is a secure cookie. Defaults to false
27
- // httpOnly: true, // Whether the cookie is an HTTP only cookie. Defaults to false
28
- // expiry: 1551393875 // When the cookie expires, specified in seconds since Unix Epoch
29
- })
30
-
31
- // set multiple cookies
32
- browser.setCookies([
33
- {name: 'test2', value: 'two'},
34
- {name: 'test3', value: 'three'}
35
- ])
36
-
37
- const cookies = browser.getCookies()
38
- console.log(cookies);
39
- // outputs:
40
- // [
41
- // {name: 'test1', value: 'one', domain: 'www.example.com'},
42
- // {name: 'test2', value: 'two', domain: 'www.example.com'},
43
- // {name: 'test3', value: 'three', domain: 'www.example.com'}
44
- // ]
45
- });
46
- * </example>
47
- *
48
- * @alias browser.setCookies
49
- * @param {Object} cookie cookie object or object array
50
- * @uses protocol/addCookie
51
- * @type cookie
52
- *
53
- */
54
8
  async function setCookies(cookieObjs) {
55
9
  const cookieObjsList = !Array.isArray(cookieObjs) ? [cookieObjs] : cookieObjs;
56
10
 
@@ -5,43 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = setTimeout;
7
7
 
8
- /**
9
- *
10
- * Sets the timeouts associated with the current session, timeout durations control such
11
- * behaviour as timeouts on script injection, document navigation, and element retrieval.
12
- * For more information and examples, see [timeouts guide](https://webdriver.io/docs/timeouts.html#selenium-timeouts).
13
- *
14
- * <example>
15
- :setTimeout.js
16
- it('should change timeout duration for session with long code duration', () => {
17
- browser.setTimeout({
18
- 'pageLoad': 10000,
19
- 'script': 60000
20
- });
21
- // Execute code which takes a long time
22
- browser.executeAsync((done) => {
23
- console.log('Wake me up before you go!');
24
- setTimeout(done, 59000);
25
- });
26
- });
27
- * </example>
28
- *
29
- * @param {Object} timeouts Object containing session timeout values
30
- * @param {Number} timeouts.implicit (Optional) Time in milliseconds to retry the element location strategy when finding an element.
31
- * @param {Number} timeouts.pageLoad (Optional) Time in milliseconds to wait for the document to finish loading.
32
- * @param {Number} timeouts.script (Optional) Scripts injected with [`execute`](https://webdriver.io/docs/api/browser/execute.html) or [`executeAsync`](https://webdriver.io/docs/api/browser/executeAsync.html) will run until they hit the script timeout duration, which is also given in milliseconds.
33
- * @see https://w3c.github.io/webdriver/#set-timeouts
34
- *
35
- */
36
8
  async function setTimeout(timeouts) {
37
9
  if (typeof timeouts !== 'object') {
38
10
  throw new Error('Parameter for "setTimeout" command needs to be an object');
39
11
  }
40
- /**
41
- * If value is not an integer, or it is less than 0 or greater than the maximum safe
42
- * integer, return error with error code invalid argument.
43
- */
44
-
45
12
 
46
13
  const timeoutValues = Object.values(timeouts);
47
14
 
@@ -49,13 +16,9 @@ async function setTimeout(timeouts) {
49
16
  throw new Error('Specified timeout values are not valid integer (see https://webdriver.io/docs/api/browser/setTimeout.html for documentation).');
50
17
  }
51
18
 
52
- const implicit = timeouts.implicit; // Previously also known as `page load` with JsonWireProtocol
53
-
19
+ const implicit = timeouts.implicit;
54
20
  const pageLoad = timeouts['page load'] || timeouts.pageLoad;
55
21
  const script = timeouts.script;
56
- /**
57
- * JsonWireProtocol action
58
- */
59
22
 
60
23
  if (!this.isW3C) {
61
24
  return Promise.all([isFinite(implicit) && this.setTimeouts('implicit', implicit), isFinite(pageLoad) && this.setTimeouts('page load', pageLoad), isFinite(script) && this.setTimeouts('script', script)].filter(Boolean));
@@ -7,38 +7,13 @@ exports.default = setWindowSize;
7
7
 
8
8
  var _utils = require("../../utils");
9
9
 
10
- /**
11
- *
12
- * Resizes browser window outer size according to provided width and height.
13
- *
14
- * <example>
15
- * :setWindowSize.js
16
- it('should re-size browser outer window with 500 width and 600 height', function () {
17
- browser.setWindowSize(500, 600);
18
- });
19
- * </example>
20
- *
21
- * @alias browser.setWindowSize
22
- * @param {Number} width browser will be resized to provided width
23
- * @param {Number} height browser will be resized to provided height
24
- * @return {Null|Object} Null for *NO*W3C browser and Object{x, y, width, height} for W3C browser
25
- * @type window
26
- *
27
- */
28
10
  function setWindowSize(width, height) {
29
11
  const minWindowSize = 0;
30
12
  const maxWindowSize = 2147483647;
31
- /**
32
- * type check
33
- */
34
13
 
35
14
  if (typeof width !== 'number' || typeof height !== 'number') {
36
15
  throw new Error('setWindowSize expects width and height of type number');
37
16
  }
38
- /**
39
- * value check
40
- */
41
-
42
17
 
43
18
  if (width < minWindowSize || width > maxWindowSize || height < minWindowSize || height > maxWindowSize) {
44
19
  throw new Error('setWindowSize expects width and height to be a number in the 0 to 2^31 − 1 range');
@@ -5,37 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = switchWindow;
7
7
 
8
- /**
9
- *
10
- * Switch focus to a particular tab / window.
11
- *
12
- * <example>
13
- :switchWindow.js
14
- it('should switch to another window', () => {
15
- // open url
16
- browser.url('https://google.com')
17
- // create new window
18
- browser.newWindow('https://webdriver.io')
19
-
20
- // switch back via url match
21
- browser.switchWindow('google.com')
22
-
23
- // switch back via title match
24
- browser.switchWindow('Next-gen WebDriver test framework')
25
- });
26
- * </example>
27
- *
28
- * @param {String|RegExp} urlOrTitleToMatch String or regular expression that matches the title or url of the page
29
- *
30
- * @uses protocol/getWindowHandles, protocol/switchToWindow, protocol/getUrl, protocol/getTitle
31
- * @alias browser.switchTab
32
- * @type window
33
- *
34
- */
35
8
  async function switchWindow(urlOrTitleToMatch) {
36
- /*!
37
- * parameter check
38
- */
39
9
  if (typeof urlOrTitleToMatch !== 'string' && !(urlOrTitleToMatch instanceof RegExp)) {
40
10
  throw new Error('Unsupported parameter for switchWindow, required is "string" or an RegExp');
41
11
  }
@@ -44,19 +14,11 @@ async function switchWindow(urlOrTitleToMatch) {
44
14
 
45
15
  for (const tab of tabs) {
46
16
  await this.switchToWindow(tab);
47
- /**
48
- * check if url matches
49
- */
50
-
51
17
  const url = await this.getUrl();
52
18
 
53
19
  if (url.match(urlOrTitleToMatch)) {
54
20
  return tab;
55
21
  }
56
- /**
57
- * check title
58
- */
59
-
60
22
 
61
23
  const title = await this.getTitle();
62
24
 
@@ -7,66 +7,6 @@ exports.default = touchAction;
7
7
 
8
8
  var _constant = require("../constant");
9
9
 
10
- /**
11
- *
12
- * The Touch Action API provides the basis of all gestures that can be automated in Appium.
13
- * It is currently only available to native apps and can not be used to interact with webapps.
14
- * At its core is the ability to chain together _ad hoc_ individual actions, which will then be
15
- * applied to an element in the application on the device. The basic actions that can be used are:
16
- *
17
- * - press (pass element or (x,y) or both)
18
- * - longPress (pass element or (x,y) or both)
19
- * - tap (pass element or (x,y) or both)
20
- * - moveTo (pass absolute x,y coordinates)
21
- * - wait (pass ms (as milliseconds))
22
- * - release (no arguments)
23
- *
24
- * <example>
25
- :touchAction.js
26
- it('should do a touch gesture', function () {
27
- const screen = $('//UITextbox');
28
-
29
- // simple touch action on element
30
- browser.touchAction({
31
- action: 'tap',
32
- element: screen
33
- });
34
-
35
- // simple touch action x y variables
36
- // tap location is 30px right and 20px down relative from the viewport
37
- browser.touchAction({
38
- action: 'tap',
39
- x: 30,
40
- y:20
41
- })
42
-
43
- // simple touch action x y variables
44
- // tap location is 30px right and 20px down relative from the center of the element
45
- browser.touchAction({
46
- action: 'tap',
47
- x: 30,
48
- y:20,
49
- element: screen
50
- })
51
-
52
- // multi action on an element
53
- // drag&drop from position 200x200 down 100px on the screen
54
- browser.touchAction([
55
- { action: 'press', x: 200, y: 200 },
56
- { action: 'moveTo', x: 200, y: 300 },
57
- 'release'
58
- ])
59
- });
60
- * </example>
61
- *
62
- * @param {String|Object[]} action action to execute
63
- *
64
- * @see https://saucelabs.com/blog/appium-sauce-labs-bootcamp-chapter-2-touch-actions
65
- * @type mobile
66
- * @for android, ios
67
- * @uses mobile/performTouchAction, mobile/performMultiAction
68
- *
69
- */
70
10
  function touchAction(...args) {
71
11
  return _constant.touchAction.apply(this, args);
72
12
  }
@@ -13,41 +13,10 @@ var _archiver = _interopRequireDefault(require("archiver"));
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
- /**
17
- * Uploads a file to the Selenium Standalone server or other browser driver
18
- * (e.g. Chromedriver) by using the [`file`](/api/protocol/file.html) command.
19
- * _Note:_ that this command is only supported if you use a Selenium Hub or
20
- * Chromedriver directly.
21
- *
22
- * <example>
23
- :touchAction.js
24
- const path = require('path');
25
-
26
- it('should upload a file', function () {
27
- const filePath = path.join(__dirname, '/local/path/to/your/file');
28
-
29
- const remoteFilePath = browser.uploadFile(filePath);
30
- $('.upload-data-file-input').setValue(remoteFilePath);
31
- });
32
- * </example>
33
- *
34
- * @alias browser.uploadFile
35
- * @param {String} localPath local path to file
36
- * @type utility
37
- * @uses protocol/file
38
- * @returns {String} remote URL
39
- */
40
16
  async function uploadFile(localPath) {
41
- /**
42
- * parameter check
43
- */
44
17
  if (typeof localPath !== 'string') {
45
18
  throw new Error('number or type of arguments don\'t agree with uploadFile command');
46
19
  }
47
- /**
48
- * check if command is available
49
- */
50
-
51
20
 
52
21
  if (typeof this.file !== 'function') {
53
22
  throw new Error(`The uploadFile command is not available in ${this.capabilities.browserName}`);
@@ -61,7 +30,6 @@ async function uploadFile(localPath) {
61
30
  (0, _archiver.default)('zip').on('error', err => reject(err)).on('data', data => zipData.push(data)).on('end', () => this.file(Buffer.concat(zipData).toString('base64')).then(resolve, reject)).append(source, {
62
31
  name: _path.default.basename(localPath)
63
32
  }).finalize(err => {
64
- /* istanbul ignore next */
65
33
  if (err) {
66
34
  reject(err);
67
35
  }
@@ -11,39 +11,6 @@ var _utils = require("../../utils");
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
14
- /**
15
- *
16
- * Protocol binding to load or get the URL of the browser. If a baseUrl is
17
- * specified in the config, it will be prepended to the url parameter using
18
- * node's url.resolve() method.
19
- *
20
- * <example>
21
- :url.js
22
- // navigate to a new URL
23
- browser.url('https://webdriver.io');
24
- // receive url
25
- console.log(browser.getUrl()); // outputs: "https://webdriver.io"
26
-
27
- :baseUrlResolutions.js
28
- // With a base URL of http://example.com/site, the following url parameters resolve as such:
29
- // When providing a scheme:
30
- // https://webdriver.io
31
- browser.url('https://webdriver.io');
32
- // When not starting with a slash, the URL resolves relative to the baseUrl
33
- // http://example.com/site/relative
34
- browser.url('relative');
35
- // When starting with a slash, the URL resolves relative to the root path of the baseUrl
36
- // http://example.com/rootRelative
37
- browser.url('/rootRelative');
38
- * </example>
39
- *
40
- * @param {String=} url the URL to navigate to
41
- *
42
- * @see https://w3c.github.io/webdriver/webdriver-spec.html#dfn-get
43
- * @see https://nodejs.org/api/url.html#url_url_resolve_from_to
44
- * @type protocol
45
- *
46
- */
47
14
  function url(path) {
48
15
  if (typeof path !== 'string') {
49
16
  throw new Error('Parameter for "url" command needs to be type of string');
@@ -9,50 +9,10 @@ var _Timer = _interopRequireDefault(require("../../utils/Timer"));
9
9
 
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
 
12
- /**
13
- *
14
- * This wait command is your universal weapon if you want to wait on something. It expects a condition
15
- * and waits until that condition is fulfilled with a truthy value. If you use the WDIO testrunner the
16
- * commands within the condition are getting executed synchronously like in your test.
17
- *
18
- * A common example is to wait until a certain element contains a certain text (see example).
19
- *
20
- * <example>
21
- :example.html
22
- <div id="someText">I am some text</div>
23
- <script>
24
- setTimeout(() => {
25
- $('#someText').html('I am now different');
26
- }, 1000);
27
- </script>
28
-
29
- :waitUntil.js
30
- it('should wait until text has changed', () => {
31
- browser.waitUntil(() => {
32
- return $('#someText').getText() === 'I am now different'
33
- }, 5000, 'expected text to be different after 5s');
34
- });
35
- * </example>
36
- *
37
- *
38
- * @alias browser.waitUntil
39
- * @param {Function} condition condition to wait on
40
- * @param {Number=} timeout timeout in ms (default: 5000)
41
- * @param {String=} timeoutMsg error message to throw when waitUntil times out
42
- * @param {Number=} interval interval between condition checks (default: 500)
43
- * @return {Boolean} true if condition is fulfilled
44
- * @uses utility/pause
45
- * @type utility
46
- *
47
- */
48
12
  function _default(condition, timeout, timeoutMsg, interval) {
49
13
  if (typeof condition !== 'function') {
50
14
  throw new Error('Condition is not a function');
51
15
  }
52
- /*!
53
- * ensure that timeout and interval are set properly
54
- */
55
-
56
16
 
57
17
  if (typeof timeout !== 'number') {
58
18
  timeout = this.options.waitforTimeout;
@@ -4,10 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.touchAction = exports.validateParameters = exports.formatArgs = void 0;
7
-
8
- /**
9
- * Constants around commands
10
- */
11
7
  const TOUCH_ACTIONS = ['press', 'longPress', 'tap', 'moveTo', 'wait', 'release'];
12
8
  const POS_ACTIONS = TOUCH_ACTIONS.slice(0, 4);
13
9
  const ACCEPTED_OPTIONS = ['x', 'y', 'element'];
@@ -27,10 +23,6 @@ const formatArgs = function (scope, actions) {
27
23
  const formattedAction = {
28
24
  action: action.action,
29
25
  options: {}
30
- /**
31
- * don't propagate for actions that don't require element options
32
- */
33
-
34
26
  };
35
27
  const actionElement = action.element && typeof action.element.elementId === 'string' ? action.element.elementId : scope.elementId;
36
28
 
@@ -41,9 +33,6 @@ const formatArgs = function (scope, actions) {
41
33
  if (isFinite(action.x)) formattedAction.options.x = action.x;
42
34
  if (isFinite(action.y)) formattedAction.options.y = action.y;
43
35
  if (action.ms) formattedAction.options.ms = action.ms;
44
- /**
45
- * remove options property if empty
46
- */
47
36
 
48
37
  if (Object.keys(formattedAction.options).length === 0) {
49
38
  delete formattedAction.options;
@@ -52,13 +41,6 @@ const formatArgs = function (scope, actions) {
52
41
  return formattedAction;
53
42
  });
54
43
  };
55
- /**
56
- * Make sure action has proper options before sending command to Appium.
57
- *
58
- * @param {Object} params touchAction parameters
59
- * @return null
60
- */
61
-
62
44
 
63
45
  exports.formatArgs = formatArgs;
64
46
 
@@ -9,45 +9,6 @@ var _utils = require("../../utils");
9
9
 
10
10
  var _getElementObject = require("../../utils/getElementObject");
11
11
 
12
- /**
13
- * The `$$` command is a short way to call the [`findElements`](/docs/api/webdriver.html#findelements) command in order
14
- * to fetch multiple elements on the page similar to the `$$` command from the browser scope. The difference when calling
15
- * it from an element scope is that the driver will look within the children of that element.
16
- *
17
- * For more information on how to select specific elements, see [`Selectors`](/docs/selectors.html).
18
- *
19
- * <example>
20
- :index.html
21
- <ul id="menu">
22
- <li><a href="/">Home</a></li>
23
- <li><a href="/">Developer Guide</a></li>
24
- <li><a href="/">API</a></li>
25
- <li><a href="/">Contribute</a></li>
26
- </ul>
27
- :$.js
28
- it('should get text a menu link', () => {
29
- const text = $('#menu');
30
- console.log(text.$$('li')[2].$('a').getText()); // outputs: "API"
31
- });
32
-
33
- it('should get text a menu link - JS Function', () => {
34
- const text = $('#menu');
35
- console.log(text.$$(function() { // Arrow function is not allowed here.
36
- // this is Element https://developer.mozilla.org/en-US/docs/Web/API/Element
37
- // in this particular example it is HTMLUListElement
38
- // TypeScript users may do something like this
39
- // return (this as Element).querySelectorAll('li')
40
- return this.querySelectorAll('li'); // Element[]
41
- })[2].$('a').getText()); // outputs: "API"
42
- });
43
- * </example>
44
- *
45
- * @alias $$
46
- * @param {String|Function} selector selector or JS Function to fetch multiple elements
47
- * @return {Element[]}
48
- * @type utility
49
- *
50
- */
51
12
  async function $$(selector) {
52
13
  const res = await _utils.findElements.call(this, selector);
53
14
  return _getElementObject.getElements.call(this, selector, res);
@@ -9,49 +9,6 @@ var _utils = require("../../utils");
9
9
 
10
10
  var _getElementObject = require("../../utils/getElementObject");
11
11
 
12
- /**
13
- * The `$` command is a short way to call the [`findElement`](/docs/api/webdriver.html#findelement) command in order
14
- * to fetch a single element on the page similar to the `$` command from the browser scope. The difference when calling
15
- * it from an element scope is that the driver will look within the children of that element.
16
- *
17
- * Note: chaining `$` and `$$` commands only make sense when you use multiple selector strategies. You will otherwise
18
- * make unnecessary requests that slow down the test (e.g. `$('body').$('div')` will trigger two request whereas
19
- * `$('body div')` does literary the same with just one request)
20
- *
21
- * For more information on how to select specific elements, see [`Selectors`](/docs/selectors.html).
22
- *
23
- * <example>
24
- :index.html
25
- <ul id="menu">
26
- <li><a href="/">Home</a></li>
27
- <li><a href="/">Developer Guide</a></li>
28
- <li><a href="/">API</a></li>
29
- <li><a href="/">Contribute</a></li>
30
- </ul>
31
- :$.js
32
- it('should get text a menu link', () => {
33
- const text = $('#menu');
34
- console.log(text.$$('li')[2].$('a').getText()); // outputs: "API"
35
- });
36
-
37
- it('should get text a menu link - JS Function', () => {
38
- const text = $('#menu');
39
- console.log(text.$$('li')[2].$(function() { // Arrow function is not allowed here.
40
- // this is Element https://developer.mozilla.org/en-US/docs/Web/API/Element
41
- // in this particular example it is HTMLLIElement
42
- // TypeScript users may do something like this
43
- // return (this as Element).querySelector('a')
44
- return this.querySelector('a'); // Element
45
- }).getText()); // outputs: "API"
46
- });
47
- * </example>
48
- *
49
- * @alias $
50
- * @param {String|Function} selector selector or JS Function to fetch a certain element
51
- * @return {Element}
52
- * @type utility
53
- *
54
- */
55
12
  async function $(selector) {
56
13
  const res = await _utils.findElement.call(this, selector);
57
14
  return _getElementObject.getElement.call(this, selector, res);