Skip to content

Commit 0983a17

Browse files
committed
feat: Allow specifying all initialization parameters supported by WebdriverIO
1 parent c490a77 commit 0983a17

File tree

3 files changed

+31
-15
lines changed

3 files changed

+31
-15
lines changed

Gruntfile.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ module.exports = function (grunt) {
6363

6464
'html-dom-snapshot': {
6565
options: {
66-
browserCapabilities: {
67-
browserName: 'phantomjs'
66+
webdriver: {
67+
desiredCapabilities: {
68+
browserName: 'phantomjs'
69+
}
6870
},
6971
snapshots: 'test/snapshots'
7072
},
@@ -355,6 +357,9 @@ module.exports = function (grunt) {
355357
},
356358
'invalid-file': {
357359
options: {
360+
browserCapabilities: {
361+
browserName: 'phantomjs'
362+
},
358363
screenshots: 'test/screenshots',
359364
force: true
360365
},

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ Default options support the most usual usage scenario:
6565
```js
6666
'html-dom-snapshot': {
6767
options: {
68-
browserCapabilities: {
69-
browserName: 'chrome',
70-
chromeOptions: {
71-
args: ['--headless']
68+
webdriver: {
69+
desiredCapabilities: {
70+
browserName: 'chrome',
71+
chromeOptions: {
72+
args: ['--headless']
73+
}
7274
}
7375
},
7476
viewport: {
@@ -92,11 +94,11 @@ Default options support the most usual usage scenario:
9294

9395
### Options
9496

95-
#### browserCapabilities
97+
#### webdriver
9698
Type: `Object`
9799
Default value: see above
98100

99-
Chooses the web browser to take snapshots with. Passed as `desiredCapabilities` to `webdriverio.remote`. This object has to contain the property `browserName` and optionally other properties depending on the web browser driver. The following browser names are the most usually used: `chrome`, `edge`, `firefox`, `ie`, `phantomjs`, `safari`. Depending on what browser you specify, you will need to load the corresponding Selenium driver. These are current versions of the drivers:
101+
Chooses the web browser to take snapshots with, Selenium host and other parameters supported by WebdriverIO as input for the `webdriverio.remote` method. This object has to contain the property `desiredCapabilities` with `browserName` and optionally other properties depending on the web browser driver. The following browser names are the most usually used: `chrome`, `edge`, `firefox`, `ie`, `phantomjs`, `safari`. Depending on what browser you specify, you will need to load the corresponding Selenium driver. These are current versions of the drivers:
100102

101103
```js
102104
'selenium_standalone': {
@@ -497,6 +499,7 @@ your code using Grunt.
497499
498500
## Release History
499501
502+
* 2018-03-29 [v1.1.0] Allow specifying all initialization parameters supported by WebdriverIO
500503
* 2018-03-28 [v1.0.2] Stop Selenium and Chromedriver processes on unexpected Grunt process abortion
501504
* 2018-03-28 [v1.0.1] Workaround for hanging chromedriver after finishing the task
502505
* 2018-03-11 [v1.0.0] Require Node.js >= 6

tasks/html-dom-snapshot.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ module.exports = function (grunt) {
3636
const done = this.async()
3737
const data = this.data
3838
const options = this.options({
39-
browserCapabilities: {
40-
browserName: 'chrome',
41-
chromeOptions: {
42-
args: ['--headless']
39+
webdriver: {
40+
desiredCapabilities: {
41+
browserName: 'chrome',
42+
chromeOptions: {
43+
args: ['--headless']
44+
}
4345
}
4446
},
4547
viewport: {
@@ -58,17 +60,22 @@ module.exports = function (grunt) {
5860
const pages = data.pages
5961
const snapshots = options.dest
6062
const viewport = options.viewport
63+
const webdriver = options.webdriver
64+
const browserCapabilities = options.browserCapabilities
6165
const lastViewport = {
6266
width: viewport.width,
6367
height: viewport.height
6468
}
65-
let client = webdriverio.remote({
66-
desiredCapabilities: options.browserCapabilities
67-
})
6869
let urlCount = 0
6970
let snapshotCount = 0
7071
let screenshotCount = 0
7172
let commands
73+
if (browserCapabilities) {
74+
grunt.log.warn('The property "browserCapabilities" is deprecated. ' +
75+
'Use "webdriver.desiredCapabilities" with the same content.')
76+
webdriver.desiredCapabilities = browserCapabilities
77+
delete options.browserCapabilities
78+
}
7279
if (pages) {
7380
grunt.log.warn('The property "pages" is deprecated. ' +
7481
'Use "commands" with the same content.')
@@ -82,6 +89,7 @@ module.exports = function (grunt) {
8289

8390
grunt.verbose.writeln('Open web browser window for the target "' +
8491
target + '".')
92+
let client = webdriverio.remote(webdriver)
8593
client.init()
8694
.then(function () {
8795
nodeCleanup(stop)

0 commit comments

Comments
 (0)