admc / wd

A node.js client for webdriver/selenium 2.
Other
1.53k stars 402 forks source link

_init() fails if SauceLabs responds with an error #520

Open derhuerst opened 6 years ago

derhuerst commented 6 years ago

I tried to run my tests at SauceLabs, but had an invalid API key. The SauceLabs API responded with the following body:

You used username 'derhuerst' and access key '1a04c633-6a58-1234-8287-43ecc070' to authenticate, which are not valid Sauce Labs credentials.

The following desired capabilities were received:
{'browserName': 'Chrome',
 'javascriptEnabled': True,
 'platform': 'Windows 10',
 'recordVideo': False,
 'version': ''}

Two issues in combination cause the wd not to handle this correctly:

Instead of calling the callback with the error from SauceLabs, wd will choke and throw an uncaught error TypeError: Cannot read property 'value' of undefined.

The full stack trace:

TypeError: Cannot read property 'value' of undefined
    at /Users/j/web/fs-read-stream-over-http/node_modules/wd/lib/webdriver.js:134:85
    at Request._callback (/Users/j/web/fs-read-stream-over-http/node_modules/wd/lib/http-utils.js:88:7)
    at Request.self.callback (/Users/j/web/fs-read-stream-over-http/node_modules/wd/node_modules/request/request.js:186:22)
    at Request.emit (events.js:160:13)
    at Request.<anonymous> (/Users/j/web/fs-read-stream-over-http/node_modules/wd/node_modules/request/request.js:1081:10)
    at Request.emit (events.js:160:13)
    at IncomingMessage.<anonymous> (/Users/j/web/fs-read-stream-over-http/node_modules/wd/node_modules/request/request.js:1001:12)
    at Object.onceWrapper (events.js:255:19)
    at IncomingMessage.emit (events.js:165:20)
    at endReadableNT (_stream_readable.js:1101:12)