selenium-webdriver 3.0.0-beta-1 → 3.0.1
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.
- package/CHANGES.md +109 -0
- package/LICENSE +1 -1
- package/README.md +7 -6
- package/chrome.js +31 -128
- package/edge.js +13 -91
- package/example/chrome_android.js +18 -13
- package/example/chrome_mobile_emulation.js +19 -15
- package/example/google_search.js +11 -11
- package/example/google_search_generator.js +23 -18
- package/example/google_search_test.js +31 -17
- package/example/logging.js +9 -17
- package/example/parallel_flows.js +3 -0
- package/firefox/binary.js +17 -0
- package/firefox/index.js +198 -101
- package/firefox/profile.js +24 -3
- package/http/util.js +95 -59
- package/ie.js +6 -10
- package/index.js +636 -2
- package/lib/actions.js +18 -10
- package/lib/atoms/getAttribute.js +11 -0
- package/lib/atoms/isDisplayed.js +106 -0
- package/lib/firefox/amd64/libnoblur64.so +0 -0
- package/lib/firefox/i386/libnoblur.so +0 -0
- package/lib/firefox/webdriver.xpi +0 -0
- package/lib/http.js +159 -46
- package/lib/logging.js +7 -1
- package/lib/promise.js +602 -358
- package/lib/proxy.js +28 -0
- package/lib/session.js +1 -1
- package/lib/test/build.js +26 -28
- package/lib/test/data/formPage.html +1 -0
- package/lib/test/fileserver.js +12 -10
- package/lib/test/httpserver.js +4 -6
- package/lib/test/index.js +18 -11
- package/lib/test/promise.js +79 -0
- package/lib/webdriver.js +587 -479
- package/opera.js +12 -88
- package/package.json +13 -14
- package/phantomjs.js +7 -14
- package/remote/index.js +201 -30
- package/safari.js +62 -416
- package/test/actions_test.js +9 -11
- package/test/chrome/options_test.js +8 -8
- package/test/chrome/service_test.js +2 -2
- package/test/cookie_test.js +57 -57
- package/test/element_finding_test.js +201 -185
- package/test/execute_script_test.js +108 -111
- package/test/fingerprint_test.js +16 -11
- package/test/firefox/firefox_test.js +75 -49
- package/test/firefox/profile_test.js +1 -3
- package/test/http/util_test.js +21 -27
- package/test/io_test.js +2 -5
- package/test/lib/http_test.js +8 -6
- package/test/lib/promise_aplus_test.js +48 -44
- package/test/lib/promise_error_test.js +687 -611
- package/test/lib/promise_flow_test.js +1810 -1806
- package/test/lib/promise_generator_test.js +227 -225
- package/test/lib/promise_test.js +864 -835
- package/test/lib/until_test.js +1 -1
- package/test/lib/webdriver_test.js +520 -424
- package/test/logging_test.js +43 -45
- package/test/net/portprober_test.js +23 -24
- package/test/page_loading_test.js +84 -78
- package/test/phantomjs/execute_phantomjs_test.js +11 -25
- package/test/proxy_test.js +23 -23
- package/test/remote_test.js +22 -22
- package/test/safari_test.js +108 -0
- package/test/session_test.js +11 -10
- package/test/stale_element_test.js +18 -16
- package/test/tag_name_test.js +7 -5
- package/test/testing/assert_test.js +2 -3
- package/test/testing/index_test.js +163 -117
- package/test/upload_test.js +13 -13
- package/test/window_test.js +94 -70
- package/testing/index.js +176 -37
- package/builder.js +0 -553
- package/lib/safari/client.js +0 -56
package/lib/proxy.js
CHANGED
|
@@ -76,6 +76,34 @@ exports.manual = function(options) {
|
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
|
|
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
|
+
|
|
79
107
|
/**
|
|
80
108
|
* Configures WebDriver to configure the browser proxy using the PAC file at
|
|
81
109
|
* the given URL.
|
package/lib/session.js
CHANGED
package/lib/test/build.js
CHANGED
|
@@ -21,8 +21,7 @@ const spawn = require('child_process').spawn,
|
|
|
21
21
|
fs = require('fs'),
|
|
22
22
|
path = require('path');
|
|
23
23
|
|
|
24
|
-
const isDevMode = require('../devmode')
|
|
25
|
-
promise = require('../promise');
|
|
24
|
+
const isDevMode = require('../devmode');
|
|
26
25
|
|
|
27
26
|
var projectRoot = path.normalize(path.join(__dirname, '../../../../..'));
|
|
28
27
|
|
|
@@ -69,7 +68,7 @@ Build.prototype.onlyOnce = function() {
|
|
|
69
68
|
|
|
70
69
|
/**
|
|
71
70
|
* Executes the build.
|
|
72
|
-
* @return {!
|
|
71
|
+
* @return {!Promise} A promise that will be resolved when
|
|
73
72
|
* the build has completed.
|
|
74
73
|
* @throws {Error} If no targets were specified.
|
|
75
74
|
*/
|
|
@@ -86,7 +85,7 @@ Build.prototype.go = function() {
|
|
|
86
85
|
});
|
|
87
86
|
|
|
88
87
|
if (!targets.length) {
|
|
89
|
-
return
|
|
88
|
+
return Promise.resolve();
|
|
90
89
|
}
|
|
91
90
|
}
|
|
92
91
|
|
|
@@ -100,31 +99,30 @@ Build.prototype.go = function() {
|
|
|
100
99
|
cmd = path.join(projectRoot, 'go');
|
|
101
100
|
}
|
|
102
101
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
102
|
+
return new Promise((resolve, reject) => {
|
|
103
|
+
spawn(cmd, args, {
|
|
104
|
+
cwd: projectRoot,
|
|
105
|
+
env: process.env,
|
|
106
|
+
stdio: ['ignore', process.stdout, process.stderr]
|
|
107
|
+
}).on('exit', function(code, signal) {
|
|
108
|
+
if (code === 0) {
|
|
109
|
+
targets.forEach(function(target) {
|
|
110
|
+
builtTargets[target] = 1;
|
|
111
|
+
});
|
|
112
|
+
return resolve();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
var msg = 'Unable to build artifacts';
|
|
116
|
+
if (code) { // May be null.
|
|
117
|
+
msg += '; code=' + code;
|
|
118
|
+
}
|
|
119
|
+
if (signal) {
|
|
120
|
+
msg += '; signal=' + signal;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
reject(Error(msg));
|
|
124
|
+
});
|
|
125
125
|
});
|
|
126
|
-
|
|
127
|
-
return result.promise;
|
|
128
126
|
};
|
|
129
127
|
|
|
130
128
|
|
package/lib/test/fileserver.js
CHANGED
|
@@ -28,8 +28,7 @@ var serveIndex = require('serve-index');
|
|
|
28
28
|
|
|
29
29
|
var Server = require('./httpserver').Server,
|
|
30
30
|
resources = require('./resources'),
|
|
31
|
-
isDevMode = require('../devmode')
|
|
32
|
-
promise = require('../promise');
|
|
31
|
+
isDevMode = require('../devmode');
|
|
33
32
|
|
|
34
33
|
var WEB_ROOT = '/common';
|
|
35
34
|
var JS_ROOT = '/javascript';
|
|
@@ -194,15 +193,18 @@ function sendDelayedResponse(request, response) {
|
|
|
194
193
|
}
|
|
195
194
|
|
|
196
195
|
|
|
197
|
-
function handleUpload(request, response
|
|
198
|
-
multer({
|
|
199
|
-
|
|
200
|
-
|
|
196
|
+
function handleUpload(request, response) {
|
|
197
|
+
let upload = multer({storage: multer.memoryStorage()}).any();
|
|
198
|
+
upload(request, response, function(err) {
|
|
199
|
+
if (err) {
|
|
200
|
+
response.writeHead(500);
|
|
201
|
+
response.end(err + '');
|
|
202
|
+
} else {
|
|
201
203
|
response.writeHead(200);
|
|
202
|
-
response.write(
|
|
204
|
+
response.write(request.files[0].buffer);
|
|
203
205
|
response.end('<script>window.top.window.onUploadDone();</script>');
|
|
204
206
|
}
|
|
205
|
-
})
|
|
207
|
+
});
|
|
206
208
|
}
|
|
207
209
|
|
|
208
210
|
|
|
@@ -269,7 +271,7 @@ function sendIndex(request, response) {
|
|
|
269
271
|
/**
|
|
270
272
|
* Starts the server on the specified port.
|
|
271
273
|
* @param {number=} opt_port The port to use, or 0 for any free port.
|
|
272
|
-
* @return {!
|
|
274
|
+
* @return {!Promise<Host>} A promise that will resolve
|
|
273
275
|
* with the server host when it has fully started.
|
|
274
276
|
*/
|
|
275
277
|
exports.start = server.start.bind(server);
|
|
@@ -277,7 +279,7 @@ exports.start = server.start.bind(server);
|
|
|
277
279
|
|
|
278
280
|
/**
|
|
279
281
|
* Stops the server.
|
|
280
|
-
* @return {!
|
|
282
|
+
* @return {!Promise} A promise that will resolve when the
|
|
281
283
|
* server has closed all connections.
|
|
282
284
|
*/
|
|
283
285
|
exports.stop = server.stop.bind(server);
|
package/lib/test/httpserver.js
CHANGED
|
@@ -50,14 +50,14 @@ var Server = function(requestHandler) {
|
|
|
50
50
|
* Starts the server on the given port. If no port, or 0, is provided,
|
|
51
51
|
* the server will be started on a random port.
|
|
52
52
|
* @param {number=} opt_port The port to start on.
|
|
53
|
-
* @return {!
|
|
53
|
+
* @return {!Promise<Host>} A promise that will resolve
|
|
54
54
|
* with the server host when it has fully started.
|
|
55
55
|
*/
|
|
56
56
|
this.start = function(opt_port) {
|
|
57
57
|
assert(typeof opt_port !== 'function',
|
|
58
58
|
"start invoked with function, not port (mocha callback)?");
|
|
59
59
|
var port = opt_port || portprober.findFreePort('localhost');
|
|
60
|
-
return
|
|
60
|
+
return Promise.resolve(port).then(port => {
|
|
61
61
|
return promise.checkedNodeCall(
|
|
62
62
|
server.listen.bind(server, port, 'localhost'));
|
|
63
63
|
}).then(function() {
|
|
@@ -67,13 +67,11 @@ var Server = function(requestHandler) {
|
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* Stops the server.
|
|
70
|
-
* @return {!
|
|
70
|
+
* @return {!Promise} A promise that will resolve when the
|
|
71
71
|
* server has closed all connections.
|
|
72
72
|
*/
|
|
73
73
|
this.stop = function() {
|
|
74
|
-
|
|
75
|
-
server.close(d.fulfill);
|
|
76
|
-
return d.promise;
|
|
74
|
+
return new Promise(resolve => server.close(resolve));
|
|
77
75
|
};
|
|
78
76
|
|
|
79
77
|
/**
|
package/lib/test/index.js
CHANGED
|
@@ -24,6 +24,7 @@ var build = require('./build'),
|
|
|
24
24
|
webdriver = require('../../'),
|
|
25
25
|
flow = webdriver.promise.controlFlow(),
|
|
26
26
|
firefox = require('../../firefox'),
|
|
27
|
+
safari = require('../../safari'),
|
|
27
28
|
remote = require('../../remote'),
|
|
28
29
|
testing = require('../../testing'),
|
|
29
30
|
fileserver = require('./fileserver');
|
|
@@ -113,6 +114,8 @@ var browsersToTest = (function() {
|
|
|
113
114
|
console.log('Running tests using loopback address')
|
|
114
115
|
}
|
|
115
116
|
}
|
|
117
|
+
console.log(
|
|
118
|
+
'Promise manager is enabled? ' + webdriver.promise.USE_PROMISE_MANAGER);
|
|
116
119
|
|
|
117
120
|
return browsers;
|
|
118
121
|
})();
|
|
@@ -215,27 +218,31 @@ function suite(fn, opt_options) {
|
|
|
215
218
|
|
|
216
219
|
try {
|
|
217
220
|
|
|
221
|
+
before(function() {
|
|
222
|
+
if (isDevMode) {
|
|
223
|
+
return build.of(
|
|
224
|
+
'//javascript/atoms/fragments:is-displayed',
|
|
225
|
+
'//javascript/webdriver/atoms:getAttribute')
|
|
226
|
+
.onlyOnce().go();
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
|
|
218
230
|
// Server is only started if required for a specific config.
|
|
219
|
-
|
|
231
|
+
after(function() {
|
|
220
232
|
if (seleniumServer) {
|
|
221
233
|
return seleniumServer.stop();
|
|
222
234
|
}
|
|
223
235
|
});
|
|
224
236
|
|
|
225
237
|
browsers.forEach(function(browser) {
|
|
226
|
-
|
|
238
|
+
describe('[' + browser + ']', function() {
|
|
227
239
|
|
|
228
240
|
if (isDevMode && nativeRun) {
|
|
229
241
|
if (browser === LEGACY_FIREFOX) {
|
|
230
|
-
|
|
242
|
+
before(function() {
|
|
231
243
|
return build.of('//javascript/firefox-driver:webdriver')
|
|
232
244
|
.onlyOnce().go();
|
|
233
245
|
});
|
|
234
|
-
} else if (browser === webdriver.Browser.SAFARI) {
|
|
235
|
-
testing.before(function() {
|
|
236
|
-
return build.of('//javascript/safari-driver:client')
|
|
237
|
-
.onlyOnce().go();
|
|
238
|
-
});
|
|
239
246
|
}
|
|
240
247
|
}
|
|
241
248
|
|
|
@@ -247,7 +254,7 @@ function suite(fn, opt_options) {
|
|
|
247
254
|
serverJar, {loopback: useLoopback});
|
|
248
255
|
}
|
|
249
256
|
|
|
250
|
-
|
|
257
|
+
before(function() {
|
|
251
258
|
this.timeout(0);
|
|
252
259
|
return seleniumServer.start(60 * 1000);
|
|
253
260
|
});
|
|
@@ -263,14 +270,14 @@ function suite(fn, opt_options) {
|
|
|
263
270
|
|
|
264
271
|
// GLOBAL TEST SETUP
|
|
265
272
|
|
|
266
|
-
|
|
273
|
+
before(function() {
|
|
267
274
|
// Do not pass register fileserver.start directly with testing.before,
|
|
268
275
|
// as start takes an optional port, which before assumes is an async
|
|
269
276
|
// callback.
|
|
270
277
|
return fileserver.start();
|
|
271
278
|
});
|
|
272
279
|
|
|
273
|
-
|
|
280
|
+
after(function() {
|
|
274
281
|
return fileserver.stop();
|
|
275
282
|
});
|
|
276
283
|
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
|
+
// or more contributor license agreements. See the NOTICE file
|
|
3
|
+
// distributed with this work for additional information
|
|
4
|
+
// regarding copyright ownership. The SFC licenses this file
|
|
5
|
+
// to you under the Apache License, Version 2.0 (the
|
|
6
|
+
// "License"); you may not use this file except in compliance
|
|
7
|
+
// with the License. You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing,
|
|
12
|
+
// software distributed under the License is distributed on an
|
|
13
|
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
// KIND, either express or implied. See the License for the
|
|
15
|
+
// specific language governing permissions and limitations
|
|
16
|
+
// under the License.
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Configures a block of mocha tests, ensuring the promise manager is either
|
|
23
|
+
* enabled or disabled for the tests' execution.
|
|
24
|
+
* for their execution.
|
|
25
|
+
*/
|
|
26
|
+
function withPromiseManager(enabled, fn) {
|
|
27
|
+
describe(`SELENIUM_PROMISE_MANAGER=${enabled}`, function() {
|
|
28
|
+
let saved;
|
|
29
|
+
|
|
30
|
+
function changeState() {
|
|
31
|
+
saved = process.env.SELENIUM_PROMISE_MANAGER;
|
|
32
|
+
process.env.SELENIUM_PROMISE_MANAGER = enabled;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function restoreState() {
|
|
36
|
+
if (saved === undefined) {
|
|
37
|
+
delete process.env.SELENIUM_PROMISE_MANAGER;
|
|
38
|
+
} else {
|
|
39
|
+
process.env.SELENIUM_PROMISE_MANAGER = saved;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
before(changeState);
|
|
44
|
+
after(restoreState);
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
changeState();
|
|
48
|
+
fn();
|
|
49
|
+
} finally {
|
|
50
|
+
restoreState();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Defines a set of tests to run both with and without the promise manager
|
|
58
|
+
* enabled.
|
|
59
|
+
*/
|
|
60
|
+
exports.promiseManagerSuite = function(fn) {
|
|
61
|
+
withPromiseManager(true, fn);
|
|
62
|
+
withPromiseManager(false, fn);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Ensures the promise manager is enabled when the provided tests run.
|
|
68
|
+
*/
|
|
69
|
+
exports.enablePromiseManager = function(fn) {
|
|
70
|
+
withPromiseManager(true, fn);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Ensures the promise manager is disabled when the provided tests run.
|
|
76
|
+
*/
|
|
77
|
+
exports.disablePromiseManager = function(fn) {
|
|
78
|
+
withPromiseManager(false, fn);
|
|
79
|
+
};
|