Skip to content

Commit a93dafc

Browse files
rsquiresrossimochristian-bromann
committed
Feature/read timeout (webdriverio#4906)
* Revert "Remove `connectionRetryTimeout` option (webdriverio#4822)" This reverts commit 2df99a9. * Forward connectionRetryTimeout to 'request' lib * Validate timeout is set for retry * Apply suggestions from code review Co-Authored-By: Christian Bromann <github@christian-bromann.com> Co-authored-by: Ross Squires <ross.squires@gmail.com> Co-authored-by: Christian Bromann <github@christian-bromann.com>
1 parent dd288ae commit a93dafc

File tree

12 files changed

+37
-2
lines changed

12 files changed

+37
-2
lines changed

docs/BrowserObject.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ console.log(browser.config)
7272
waitforInterval: 250,
7373
logLevel: 'debug',
7474
baseUrl: 'http://localhost',
75+
connectionRetryTimeout: 90000,
7576
connectionRetryCount: 3,
7677
specs: [ 'err.js' ],
7778
fakeUser: 'maxmustermann', // <-- custom option

docs/Options.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ When running in standalone mode, the only log generated by WebdriverIO will be t
7878
Type: `String`<br>
7979
Default: `null`
8080

81+
### `connectionRetryTimeout`
82+
Timeout for any WebDriver request to a driver or grid.
83+
84+
Type: `Number`<br>
85+
Default: `90000`
86+
8187
### `connectionRetryCount`
8288
Maximum count of request retries to the Selenium server.
8389

examples/pageobject/wdio.conf.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ exports.config = {
4444
// Default timeout for all waitForXXX commands.
4545
waitforTimeout: 150000,
4646
//
47+
// Default timeout in milliseconds for request
48+
// if browser driver or grid doesn't send response
49+
connectionRetryTimeout: 90000,
50+
//
4751
// Default request retries count
4852
connectionRetryCount: 3,
4953
//

packages/wdio-cli/src/templates/wdio.conf.tpl.ejs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ exports.config = {
141141
// Default timeout for all waitFor* commands.
142142
waitforTimeout: 10000,
143143
//
144+
// Default timeout in milliseconds for request
145+
// if browser driver or grid doesn't send response
146+
connectionRetryTimeout: 90000,
147+
//
144148
// Default request retries count
145149
connectionRetryCount: 3,
146150
//

packages/wdio-config/src/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const DEFAULT_CONFIGS = {
1919
maxInstances: 100,
2020
maxInstancesPerCapability: 100,
2121
filesToWatch: [],
22+
connectionRetryTimeout: 90000,
2223
connectionRetryCount: 3,
2324
execArgv: [],
2425
runnerEnv: {},

packages/wdio-junit-reporter/tests/__fixtures__/runner.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
],
5555
"maxInstances": 1,
5656
"maxInstancesPerCapability": 100,
57+
"connectionRetryTimeout": 90000,
5758
"connectionRetryCount": 3,
5859
"execArgv": [],
5960
"runnerEnv": {},

packages/webdriver/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ Shorten `url` command calls by setting a base url.
9595
Type: `String`<br>
9696
Default: *null*
9797

98+
### connectionRetryTimeout
99+
Timeout for any WebDriver request to a driver or grid.
100+
101+
Type: `Number`<br>
102+
Default: *90000*
103+
98104
### connectionRetryCount
99105
Count of request retries to the Selenium server.
100106

packages/webdriver/src/constants.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ export const DEFAULTS = {
4949
default: 'info',
5050
match: /(trace|debug|info|warn|error|silent)/
5151
},
52+
/**
53+
* Timeout for any WebDriver request to a driver or grid
54+
*/
55+
connectionRetryTimeout: {
56+
type: 'number',
57+
default: 90000
58+
},
5259
/**
5360
* Count of request retries to the Selenium server
5461
*/

packages/webdriver/src/request.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ export default class WebDriverRequest extends EventEmitter {
5050
...DEFAULT_HEADERS,
5151
...(typeof options.headers === 'object' ? options.headers : {})
5252
},
53-
qs: typeof options.queryParams === 'object' ? options.queryParams : {}
53+
qs: typeof options.queryParams === 'object' ? options.queryParams : {},
54+
timeout: options.connectionRetryTimeout
5455
}
5556

5657
/**

packages/webdriver/tests/request.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,16 @@ describe('webdriver request', () => {
4141
hostname: 'localhost',
4242
port: 4445,
4343
path: '/wd/hub/',
44-
headers: { foo: 'bar' }
44+
headers: { foo: 'bar' },
45+
connectionRetryTimeout: 10 * 1000
4546
}, 'foobar12345')
4647

4748
expect(options.agent.protocol).toBe('https:')
4849
expect(options.uri.href)
4950
.toBe('https://localhost:4445/wd/hub/session/foobar12345/element')
5051
expect(Object.keys(options.headers))
5152
.toEqual(['Connection', 'Accept', 'User-Agent', 'foo'])
53+
expect(options.timeout).toBe(10 * 1000)
5254
})
5355

5456
it('passes a custom agent', () => {

0 commit comments

Comments
 (0)