Skip to content

Commit a435a8d

Browse files
committed
[js] Surface in the API a way to configure a socks proxy
Fixes #2679
1 parent 0718a9a commit a435a8d

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

javascript/node/selenium-webdriver/CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Added support for Safari 10 safaridriver. safaridriver may be disabled
88
via tha API, `safari.Options#useLegacyDriver`, to use the safari
99
extension driver.
10+
* Updated the `lib/proxy` module to support configuring a SOCKS proxy.
1011

1112
### API Changes
1213

javascript/node/selenium-webdriver/lib/proxy.js

+28
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,34 @@ exports.manual = function(options) {
7676
};
7777

7878

79+
/**
80+
* Creates a proxy configuration for a socks proxy.
81+
*
82+
* __Example:__
83+
*
84+
* const {Capabilities} = require('selenium-webdriver');
85+
* const proxy = require('selenium-webdriver/lib/proxy');
86+
*
87+
* let capabilities = new Capabilities();
88+
* capabilities.setProxy(proxy.socks('localhost:1234', 'bob', 'password'));
89+
*
90+
*
91+
* @param {string} host The proxy host, in the form `hostname:port`.
92+
* @param {string} username The user name to authenticate as.
93+
* @param {string} password The password to authenticate with.
94+
* @return {!ProxyConfig} A new proxy configuration object.
95+
* @see https://en.wikipedia.org/wiki/SOCKS
96+
*/
97+
exports.socks = function(host, username, password) {
98+
return /** @type {!ProxyConfig} */({
99+
proxyType: 'manual',
100+
socksProxy: host,
101+
socksUsername: username,
102+
socksPassword: password
103+
});
104+
};
105+
106+
79107
/**
80108
* Configures WebDriver to configure the browser proxy using the PAC file at
81109
* the given URL.

0 commit comments

Comments
 (0)