webdriverio 4.9.10 → 4.10.2

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 (37) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/build/lib/cli.js +13 -5
  3. package/build/lib/commands/getElementSize.js +1 -1
  4. package/build/lib/commands/getValue.js +4 -4
  5. package/build/lib/commands/touchAction.js +10 -2
  6. package/build/lib/helpers/utilities.js +8 -8
  7. package/build/lib/helpers/wdio.conf.ejs +2 -2
  8. package/build/lib/launcher.js +13 -10
  9. package/build/lib/protocol/elementIdProperty.js +44 -0
  10. package/build/lib/protocol/keys.js +0 -3
  11. package/build/lib/protocol/toggleTouchIdEnrollment.js +4 -1
  12. package/build/lib/protocol/touchId.js +4 -1
  13. package/build/lib/utils/BaseReporter.js +1 -1
  14. package/build/lib/utils/ConfigParser.js +52 -27
  15. package/build/lib/utils/ReporterStats.js +4 -1
  16. package/build/package.json +1 -1
  17. package/docs/guide/getstarted/configuration.md +1 -1
  18. package/docs/guide/reporters/allure.md +1 -1
  19. package/docs/guide/reporters/dot.md +1 -1
  20. package/docs/guide/reporters/mochawesome.md +67 -0
  21. package/docs/guide/services/docker.md +145 -0
  22. package/docs/guide/services/webpack-dev-server.md +1 -1
  23. package/docs/guide/testrunner/configurationfile.md +2 -2
  24. package/docs/guide/testrunner/gettingstarted.md +2 -2
  25. package/docs/guide/testrunner/organizesuite.md +26 -4
  26. package/docs/guide/testrunner/reporters.md +12 -4
  27. package/docs/guide/testrunner/retry.md +1 -1
  28. package/docs/guide.md +2 -1
  29. package/lib/commands/getElementSize.js +1 -1
  30. package/lib/commands/getValue.js +4 -4
  31. package/lib/commands/touchAction.js +10 -2
  32. package/lib/protocol/elementIdProperty.js +33 -0
  33. package/lib/protocol/keys.js +0 -3
  34. package/lib/protocol/toggleTouchIdEnrollment.js +4 -1
  35. package/lib/protocol/touchId.js +4 -1
  36. package/package-lock.json +182 -124
  37. package/package.json +1 -1
@@ -0,0 +1,145 @@
1
+ name: docker
2
+ category: services
3
+ tags: guide
4
+ index: 13
5
+ title: WebdriverIO - Docker Service
6
+ ---
7
+
8
+ Docker Service
9
+ ===========================
10
+
11
+ This service allows user to seamlessly run test for/using a containerized application by utilizing a popular [Docker](https://www.docker.com/) service.
12
+ Currently it supports two modes of operation:
13
+ - using Docker to host Selenium (similar to Selenium Standalone Service)
14
+ - using Docker to run your containerized application
15
+
16
+ ## Installation
17
+
18
+ The easiest way is to keep `wdio-docker-service` as a devDependency in your `package.json`.
19
+
20
+ ```json
21
+ {
22
+ "devDependencies": {
23
+ "wdio-docker-service": "~1.x"
24
+ }
25
+ }
26
+ ```
27
+
28
+ You can simply do it by:
29
+
30
+ ```bash
31
+ npm install wdio-docker-service --save-dev
32
+ ```
33
+
34
+ ## Configuration
35
+
36
+ By default, Google Chrome, Firefox and PhantomJS are available when installed on the host system. In order to use the service you need to add docker to your service array:
37
+
38
+ ```js
39
+ // wdio.conf.js
40
+ exports.config = {
41
+ // ...
42
+ services: ['docker'],
43
+ // ...
44
+ // Options are set here as well
45
+ dockerLogs: './logs',
46
+ dockerOptions: {
47
+ image: 'selenium/standalone-chrome',
48
+ healthCheck: 'http://localhost:4444',
49
+ options: {
50
+ p: ['4444:4444'],
51
+ shmSize: '2g'
52
+ }
53
+ }
54
+ //...
55
+ };
56
+ ```
57
+
58
+ ## Options
59
+
60
+ ### dockerOptions
61
+ Various options required to run docker container
62
+
63
+ Type: `Object`
64
+
65
+ Default: `{
66
+ options: {
67
+ rm: true,
68
+ cidfile: [path to cidfile]
69
+ }
70
+ }`
71
+
72
+ Example:
73
+
74
+ ```javascript
75
+ dockerOptions: {
76
+ image: 'selenium/standalone-chrome',
77
+ healthCheck: 'http://localhost:4444',
78
+ options: {
79
+ p: ['4444:4444'],
80
+ shmSize: '2g'
81
+ }
82
+ }
83
+ ```
84
+
85
+ ### dockerOptions.image
86
+ Docker container name tag. Could be local or from Docker HUB.
87
+
88
+ Type: `String`
89
+
90
+ Required: `true`
91
+
92
+ ### dockerOptions.healthCheck
93
+ Url to an app exposed by your container. Normally this is a localhost url.
94
+ If healthCheck is not provided, Webdriver will start running tests immediately after Docker container is executed, which
95
+ maybe too early considering that it takes time for web service to start inside a Docker container.
96
+
97
+ Type: `String`
98
+
99
+ Example: `http://localhost:4444`
100
+
101
+ ### dockerOptions.options
102
+ Map of options used by `docker run` command. For more details on `run` command click [here](https://docs.docker.com/edge/engine/reference/commandline/run/).
103
+
104
+ Any single-letter option will be converted to `-[option]` (i.e. `d: true` -> `-d`).
105
+
106
+ Any option of two-character or more will
107
+ be converted to `--[option]` (i.e. `rm: true` -> `--rm`).
108
+
109
+ For options that may be used more than once
110
+ (i.e. `-e`,`-add-host`, `--expose`, etc.), please use array notation (i.e. `e: ["NODE_ENV=development", "FOO=bar"]`).
111
+
112
+ Type: `Object`
113
+
114
+ Example:
115
+
116
+ ```javascript
117
+ options: {
118
+ e: ['NODE_ENV=development', 'PROXY=http://myproxy:80']
119
+ p: ['4444:4444', '5900:5900'],
120
+ shmSize: '2g'
121
+ }
122
+ ```
123
+
124
+ ### dockerOptions.args
125
+ Any arguments you may want to pass into container. Corresponds to `[ARG...]` in Docker run CLI.
126
+
127
+ Type: `String`
128
+
129
+ ### dockerOptions.command
130
+ Any command you may want to pass into container. Corresponds to `[COMMAND]` in Docker run CLI.
131
+
132
+ Type: `String`
133
+
134
+ ### onDockerReady
135
+ A callback method which is called when Docker application is ready. Readiness is determined by ability to ping `healthCheck` url.
136
+
137
+ Type: `Function`
138
+
139
+ ### dockerLogs
140
+ Path to where logs from docker container should be stored
141
+
142
+ Type: `String`
143
+
144
+ ## Testing Use Cases / Recipes
145
+ Please visit our [Wiki](https://github.com/stsvilik/wdio-docker-service/wiki) for more details.
@@ -12,7 +12,7 @@ This allows you to run a local server with your built static assets using Webpac
12
12
 
13
13
  ## Installation
14
14
 
15
- ``bash
15
+ ```bash
16
16
  npm install wdio-webpack-dev-server-service --save-dev
17
17
  ```
18
18
 
@@ -279,7 +279,7 @@ exports.config = {
279
279
  beforeHook: function () {
280
280
  },
281
281
  /**
282
- * Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
282
+ * Hook that gets executed _after_ a hook within the suite ends (e.g. runs after calling
283
283
  * afterEach in Mocha)
284
284
  */
285
285
  afterHook: function () {
@@ -307,7 +307,7 @@ exports.config = {
307
307
  afterCommand: function (commandName, args, result, error) {
308
308
  },
309
309
  /**
310
- * Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
310
+ * Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) ends.
311
311
  * @param {Object} test test details
312
312
  */
313
313
  afterTest: function (test) {
@@ -39,8 +39,8 @@ Options:
39
39
  --waitforTimeout, -w timeout for all waitForXXX commands (default: 1000ms)
40
40
  --framework, -f defines the framework (Mocha, Jasmine or Cucumber) to run the specs (default: mocha)
41
41
  --reporters, -r reporters to print out the results on stdout
42
- --suite overwrites the specs attribute and runs the defined suite
43
- --spec run only a certain spec file - overrides specs piped from stdin
42
+ --suite runs the defined suite, can be combined with --spec
43
+ --spec runs a certain spec file, can be combined with --suite - overrides specs piped from stdin
44
44
  --cucumberOpts.* Cucumber options, see the full list options at https://github.com/webdriverio/wdio-cucumber-framework#cucumberopts-options
45
45
  --jasmineOpts.* Jasmine options, see the full list options at https://github.com/webdriverio/wdio-jasmine-framework#jasminenodeopts-options
46
46
  --mochaOpts.* Mocha options, see the full list options at http://mochajs.org
@@ -85,28 +85,48 @@ exports.config = {
85
85
  }
86
86
  ```
87
87
 
88
- If you now want to run a single suite only you can pass the suite name as cli argument like
88
+ Now, if you want to only run a single suite, you can pass the suite name as cli argument like:
89
89
 
90
90
  ```sh
91
91
  $ wdio wdio.conf.js --suite login
92
92
  ```
93
93
 
94
- or run multiple suites at once
94
+ or run multiple suites at once:
95
95
 
96
96
  ```sh
97
97
  $ wdio wdio.conf.js --suite login,otherFeature
98
98
  ```
99
99
 
100
- ## Run Single Test Suites
100
+ ## Run Selected Tests
101
101
 
102
- If you are working on your WebdriverIO tests you don't want to execute your whole suite everytime you added an assertion or any other code. With the `--spec` parameter you can specify which suite (Mocha, Jasmine) or feature (Cucumber) should be run. For example if you only want to run your login test, do:
102
+ In some cases, you may wish to only execute a single test or a subset of your suites. With the `--spec` parameter you can specify which suite (Mocha, Jasmine) or feature (Cucumber) should be run. For example if you only want to run your login test, do:
103
103
 
104
104
  ```sh
105
105
  $ wdio wdio.conf.js --spec ./test/specs/e2e/login.js
106
106
  ```
107
107
 
108
+ or run multiple specs at once:
109
+
110
+ ```sh
111
+ $ wdio wdio.conf.js --spec ./test/specs/signup.js,./test/specs/forgot-password.js
112
+ ```
113
+
114
+ If the spec passed in is not a path to a spec file, it is used as a filter for the specs defined in your configuration file. To run all specs with the word 'dialog' in them, you could use:
115
+
116
+ ```sh
117
+ $ wdio wdio.conf.js --spec dialog
118
+ ```
119
+
108
120
  Note that each test file is running in a single test runner process. Since we don't scan files in advance (see the next section for information on piping filenames to `wdio`) you _can't_ use for example `describe.only` at the top of your spec file to say Mocha to only run that suite. This feature will help you though to do that in the same way.
109
121
 
122
+ ## Run Suites and Test Specs
123
+
124
+ This will allow you to run an entire suite along with individual spec's.
125
+
126
+ ```sh
127
+ $ wdio wdio.conf.js --suite login --spec ./test/specs/signup.js
128
+ ```
129
+
110
130
  ## Run Multiple, Specific Test Specs
111
131
 
112
132
  It is sometimes necessary—in the context of continuous integration and otherwise—to specify multiple sets of specs to be run at runtime. WebdriverIO's `wdio` command line utility will accept piped input in the form of filenames (from `find`, `grep`, or others). These filenames will override the list of glob patterns or filenames specified in the configuration file's `spec` list.
@@ -120,3 +140,5 @@ _**Note:** This will_ not _override the `--spec` flag for running a single spec.
120
140
  ## Stop testing after failure
121
141
 
122
142
  With the `bail` option you can specify when WebdriverIO should stop the test run after test failures. This can be helpful when you have a big test suite and want to avoid long test runs when you already know that your build will break. The option expects a number that specifies after how many spec failures it should stop the whole test run. The default is `0` meaning that it always runs all tests specs it can find.
143
+
144
+ Please see http://webdriver.io/guide/getstarted/configuration.html#bail for additional information on the bail configuration.
@@ -14,10 +14,16 @@ You can write your own custom reporter for the wdio test runner that fits your n
14
14
  var util = require('util'),
15
15
  events = require('events');
16
16
 
17
- var CustomReporter = function(options) {
18
- // you can access reporter options via
19
- // `options.reporterOptions`
20
- // ...
17
+ var CustomReporter = function(baseReporter, config, options) {
18
+ // you can access reporter options via reporterOptions object against your custom reporter
19
+ // For example, in your configuration file you have:
20
+ // reporterOptions: {
21
+ // CustomReporter: {
22
+ // outputDir: './custom_report'
23
+ // }
24
+ // },
25
+ //
26
+ // then in your custom reporter, you can acess: options.outputDir
21
27
  };
22
28
 
23
29
  /**
@@ -50,6 +56,7 @@ You can register event handler for several events which get triggered during the
50
56
 
51
57
  ```txt
52
58
  'start'
59
+ 'runner:start'
53
60
  'suite:start'
54
61
  'hook:start'
55
62
  'hook:end'
@@ -59,6 +66,7 @@ You can register event handler for several events which get triggered during the
59
66
  'test:fail'
60
67
  'test:pending'
61
68
  'suite:end'
69
+ 'runner:end'
62
70
  'end'
63
71
  ```
64
72
 
@@ -73,7 +73,7 @@ module.exports = function () {
73
73
  /**
74
74
  * step definition that runs max 3 times (1 actual run + 2 reruns)
75
75
  */
76
- this.Given(/^some step definition$/, { retry: 2 }, () => {
76
+ this.Given(/^some step definition$/, { wrapperOptions: { retry: 2 } }, () => {
77
77
  // ...
78
78
  })
79
79
  // ...
package/docs/guide.md CHANGED
@@ -43,9 +43,10 @@ $ curl -L https://github.com/mozilla/geckodriver/releases/download/v0.16.0/gecko
43
43
 
44
44
  Note: Other geckodriver releases are available [here](https://github.com/mozilla/geckodriver/releases).
45
45
 
46
+ ** 4. Start selenium standalone server**
47
+
46
48
  Start the server by executing the following:
47
49
 
48
- ** 4. Start selenium standalone server**
49
50
  ```sh
50
51
  $ java -jar -Dwebdriver.gecko.driver=./geckodriver selenium-server-standalone-3.5.3.jar
51
52
  ```
@@ -27,7 +27,7 @@
27
27
  *
28
28
  * @alias browser.getElementSize
29
29
  * @param {String} selector element with requested size
30
- * @param {String*} prop size to receive (optional "width|height")
30
+ * @param {String*} prop size to receive [optional] ("width" or "height")
31
31
  * @return {Object|Number} requested element size (`{ width: <Number>, height: <Number> }`) or actual width/height as number if prop param is given
32
32
  * @uses protocol/elements, protocol/elementIdSize
33
33
  * @type property
@@ -18,7 +18,7 @@
18
18
  * @alias browser.getValue
19
19
  * @param {String} selector input, textarea, or select element
20
20
  * @return {String} requested input value
21
- * @uses protocol/elements, protocol/elementIdAttribute
21
+ * @uses protocol/elements, protocol/elementIdProperty
22
22
  * @type property
23
23
  *
24
24
  */
@@ -34,12 +34,12 @@ let getValue = function (selector) {
34
34
  throw new CommandError(7, selector || this.lastResult.selector)
35
35
  }
36
36
 
37
- let elementIdAttributeCommands = []
37
+ let elementIdPropertyCommands = []
38
38
  for (let elem of res.value) {
39
- elementIdAttributeCommands.push(this.elementIdAttribute(elem.ELEMENT, 'value'))
39
+ elementIdPropertyCommands.push(this.elementIdProperty(elem.ELEMENT, 'value'))
40
40
  }
41
41
 
42
- return this.unify(elementIdAttributeCommands, {
42
+ return this.unify(elementIdPropertyCommands, {
43
43
  extractValue: true
44
44
  })
45
45
  })
@@ -49,12 +49,20 @@
49
49
  'release'
50
50
  ])
51
51
 
52
+ // multi action using x y variables
53
+ // moveTo location is relative from the starting coordinate
54
+ browser.touchAction([
55
+ { action: 'press', x: 20, y: 550 },
56
+ { action: 'moveTo', x: 0, y: -500},
57
+ 'release'
58
+ ])
59
+
52
60
  // drag&drop to element
53
61
  screen.touchAction([
54
62
  'press',
55
63
  { action: 'moveTo', selector: '//UIAApplication[1]/UIAElement[2]' },
56
64
  'release'
57
- ]))
65
+ ])
58
66
  });
59
67
 
60
68
  :multiTouchAction.js
@@ -62,7 +70,7 @@
62
70
  // drag&drop with two fingers 200px down
63
71
  browser.touchAction([
64
72
  [{action: 'press', x: 10, y: 10}, { action: 'moveTo', x: 0, y: 200 }, 'release'],
65
- [{action: 'press', x: 100, y: 10}, { action: 'moveTo', x: 0, y: 200 }, 'release']]
73
+ [{action: 'press', x: 100, y: 10}, { action: 'moveTo', x: 0, y: 200 }, 'release']
66
74
  ])
67
75
  })
68
76
  * </example>
@@ -0,0 +1,33 @@
1
+ /**
2
+ *
3
+ * Get the value of an element's property.
4
+ *
5
+ * @param {String} ID ID of a WebElement JSON object to route the command to
6
+ * @param {String} propertyName property name of element you want to receive
7
+ *
8
+ * @return {String|null} The value of the property, or null if it is not set on the element.
9
+ *
10
+ * @see https://w3c.github.io/webdriver/webdriver-spec.html#dfn-get-element-property
11
+ * @type protocol
12
+ *
13
+ */
14
+
15
+ import { ProtocolError } from '../utils/ErrorHandler'
16
+ import { isUnknownCommand } from '../helpers/utilities'
17
+
18
+ export default function elementIdProperty (id, propertyName) {
19
+ if ((typeof id !== 'string' && typeof id !== 'number') || typeof propertyName !== 'string') {
20
+ throw new ProtocolError('number or type of arguments don\'t agree with elementIdProperty protocol command')
21
+ }
22
+
23
+ return this.requestHandler.create(`/session/:sessionId/element/${id}/property/${propertyName}`).catch((err) => {
24
+ /**
25
+ * use old path if W3C path failed
26
+ */
27
+ if (isUnknownCommand(err)) {
28
+ return this.elementIdAttribute(id, propertyName)
29
+ }
30
+
31
+ throw err
32
+ })
33
+ }
@@ -10,9 +10,6 @@
10
10
  * [here](https://w3c.github.io/webdriver/webdriver-spec.html#keyboard-actions).
11
11
  * To do that, the value has to correspond to a key from the table.
12
12
  *
13
- * This command is deprecated and will be removed soon. Make sure you don't use it in your
14
- * automation/test scripts anymore to avoid errors.
15
- *
16
13
  * @param {String|String[]} value The sequence of keys to type. An array must be provided. The server should flatten the array items to a single string to be typed.
17
14
  *
18
15
  * @see https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#sessionsessionidkeys
@@ -17,5 +17,8 @@
17
17
  *
18
18
  */
19
19
  export default function toggleTouchIdEnrollment () {
20
- return this.requestHandler.create('session/:session_id/appium/simulator/toggle_touch_id_enrollment')
20
+ return this.requestHandler.create({
21
+ path: '/session/:sessionId/appium/simulator/toggle_touch_id_enrollment',
22
+ method: 'POST'
23
+ })
21
24
  }
@@ -20,5 +20,8 @@
20
20
  */
21
21
 
22
22
  export default function touchId (match = true) {
23
- return this.requestHandler.create('/session/:sessionId/appium/simulator/touch_id', { match })
23
+ return this.requestHandler.create({
24
+ path: '/session/:sessionId/appium/simulator/touch_id',
25
+ method: 'POST'
26
+ }, { match })
24
27
  }