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/http/util.js
CHANGED
|
@@ -61,38 +61,54 @@ exports.getStatus = getStatus;
|
|
|
61
61
|
* Waits for a WebDriver server to be healthy and accepting requests.
|
|
62
62
|
* @param {string} url Base URL of the server to query.
|
|
63
63
|
* @param {number} timeout How long to wait for the server.
|
|
64
|
-
* @
|
|
65
|
-
* server is ready
|
|
64
|
+
* @param {Promise=} opt_cancelToken A promise used as a cancellation signal:
|
|
65
|
+
* if resolved before the server is ready, the wait will be terminated
|
|
66
|
+
* early with a {@link promise.CancellationError}.
|
|
67
|
+
* @return {!Promise} A promise that will resolve when the server is ready, or
|
|
68
|
+
* if the wait is cancelled.
|
|
66
69
|
*/
|
|
67
|
-
exports.waitForServer = function(url, timeout) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
70
|
+
exports.waitForServer = function(url, timeout, opt_cancelToken) {
|
|
71
|
+
return new Promise((onResolve, onReject) => {
|
|
72
|
+
let start = Date.now();
|
|
73
|
+
|
|
74
|
+
let done = false;
|
|
75
|
+
let resolve = (status) => {
|
|
76
|
+
done = true;
|
|
77
|
+
onResolve(status);
|
|
78
|
+
};
|
|
79
|
+
let reject = (err) => {
|
|
80
|
+
done = true;
|
|
81
|
+
onReject(err);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
if (opt_cancelToken) {
|
|
85
|
+
opt_cancelToken.then(_ => reject(new promise.CancellationError));
|
|
83
86
|
}
|
|
84
87
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
} else {
|
|
89
|
-
setTimeout(function() {
|
|
90
|
-
if (ready.promise.isPending()) {
|
|
91
|
-
checkServerStatus();
|
|
92
|
-
}
|
|
93
|
-
}, 50);
|
|
88
|
+
checkServerStatus();
|
|
89
|
+
function checkServerStatus() {
|
|
90
|
+
return getStatus(url).then(status => resolve(status), onError);
|
|
94
91
|
}
|
|
95
|
-
|
|
92
|
+
|
|
93
|
+
function onError(e) {
|
|
94
|
+
// Some servers don't support the status command. If they are able to
|
|
95
|
+
// response with an error, then can consider the server ready.
|
|
96
|
+
if (e instanceof error.UnsupportedOperationError) {
|
|
97
|
+
resolve({});
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (Date.now() - start > timeout) {
|
|
102
|
+
reject(Error('Timed out waiting for the WebDriver server at ' + url));
|
|
103
|
+
} else {
|
|
104
|
+
setTimeout(function() {
|
|
105
|
+
if (!done) {
|
|
106
|
+
checkServerStatus();
|
|
107
|
+
}
|
|
108
|
+
}, 50);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
96
112
|
};
|
|
97
113
|
|
|
98
114
|
|
|
@@ -101,39 +117,59 @@ exports.waitForServer = function(url, timeout) {
|
|
|
101
117
|
* timeout expires.
|
|
102
118
|
* @param {string} url The URL to poll.
|
|
103
119
|
* @param {number} timeout How long to wait, in milliseconds.
|
|
104
|
-
* @
|
|
105
|
-
*
|
|
120
|
+
* @param {Promise=} opt_cancelToken A promise used as a cancellation signal:
|
|
121
|
+
* if resolved before the a 2xx response is received, the wait will be
|
|
122
|
+
* terminated early with a {@link promise.CancellationError}.
|
|
123
|
+
* @return {!Promise} A promise that will resolve when a 2xx is received from
|
|
124
|
+
* the given URL, or if the wait is cancelled.
|
|
106
125
|
*/
|
|
107
|
-
exports.waitForUrl = function(url, timeout) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
exports.waitForUrl = function(url, timeout, opt_cancelToken) {
|
|
127
|
+
return new Promise((onResolve, onReject) => {
|
|
128
|
+
let client = new HttpClient(url);
|
|
129
|
+
let request = new HttpRequest('GET', '');
|
|
130
|
+
let start = Date.now();
|
|
131
|
+
|
|
132
|
+
let done = false;
|
|
133
|
+
let resolve = () => {
|
|
134
|
+
done = true;
|
|
135
|
+
onResolve();
|
|
136
|
+
};
|
|
137
|
+
let reject = (err) => {
|
|
138
|
+
done = true;
|
|
139
|
+
onReject(err);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
if (opt_cancelToken) {
|
|
143
|
+
opt_cancelToken.then(_ => reject(new promise.CancellationError));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
testUrl();
|
|
147
|
+
|
|
148
|
+
function testUrl() {
|
|
149
|
+
client.send(request).then(onResponse, onError);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function onError() {
|
|
153
|
+
if (Date.now() - start > timeout) {
|
|
154
|
+
reject(Error('Timed out waiting for the URL to return 2xx: ' + url));
|
|
155
|
+
} else {
|
|
156
|
+
setTimeout(function() {
|
|
157
|
+
if (!done) {
|
|
158
|
+
testUrl();
|
|
159
|
+
}
|
|
160
|
+
}, 50);
|
|
161
|
+
}
|
|
129
162
|
}
|
|
130
|
-
}
|
|
131
163
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
164
|
+
function onResponse(response) {
|
|
165
|
+
if (done) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (response.status > 199 && response.status < 300) {
|
|
169
|
+
resolve();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
onError();
|
|
136
173
|
}
|
|
137
|
-
|
|
138
|
-
}
|
|
174
|
+
});
|
|
139
175
|
};
|
package/ie.js
CHANGED
|
@@ -403,12 +403,15 @@ function createServiceFromCapabilities(capabilities) {
|
|
|
403
403
|
*/
|
|
404
404
|
class Driver extends webdriver.WebDriver {
|
|
405
405
|
/**
|
|
406
|
+
* Creates a new session for Microsoft's Internet Explorer.
|
|
407
|
+
*
|
|
406
408
|
* @param {(capabilities.Capabilities|Options)=} opt_config The configuration
|
|
407
409
|
* options.
|
|
408
410
|
* @param {promise.ControlFlow=} opt_flow The control flow to use,
|
|
409
411
|
* or {@code null} to use the currently active flow.
|
|
412
|
+
* @return {!Driver} A new driver instance.
|
|
410
413
|
*/
|
|
411
|
-
|
|
414
|
+
static createSession(opt_config, opt_flow) {
|
|
412
415
|
var caps = opt_config instanceof Options ?
|
|
413
416
|
opt_config.toCapabilities() :
|
|
414
417
|
(opt_config || capabilities.Capabilities.ie());
|
|
@@ -416,16 +419,9 @@ class Driver extends webdriver.WebDriver {
|
|
|
416
419
|
var service = createServiceFromCapabilities(caps);
|
|
417
420
|
var client = service.start().then(url => new http.HttpClient(url));
|
|
418
421
|
var executor = new http.Executor(client);
|
|
419
|
-
var driver = webdriver.WebDriver.createSession(executor, caps, opt_flow);
|
|
420
|
-
|
|
421
|
-
super(driver.getSession(), executor, driver.controlFlow());
|
|
422
|
-
|
|
423
|
-
let boundQuit = this.quit.bind(this);
|
|
424
422
|
|
|
425
|
-
/** @
|
|
426
|
-
|
|
427
|
-
return boundQuit().finally(service.kill.bind(service));
|
|
428
|
-
};
|
|
423
|
+
return /** @type {!Driver} */(webdriver.WebDriver.createSession(
|
|
424
|
+
executor, caps, opt_flow, this, () => service.kill()));
|
|
429
425
|
}
|
|
430
426
|
|
|
431
427
|
/**
|