selenium-webdriver 3.6.0 → 4.0.0-alpha.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 +181 -0
- package/README.md +25 -27
- package/chrome.js +113 -127
- package/edge.js +42 -117
- package/example/chrome_android.js +8 -8
- package/example/chrome_mobile_emulation.js +8 -8
- package/example/firefox_channels.js +22 -18
- package/example/google_search_test.js +39 -26
- package/example/logging.js +39 -6
- package/firefox.js +769 -0
- package/http/index.js +41 -4
- package/http/util.js +11 -6
- package/ie.js +56 -97
- package/index.js +178 -114
- package/jasmine.json +11 -0
- package/lib/actions.js +68 -63
- package/lib/by.js +1 -1
- package/lib/capabilities.js +255 -192
- package/lib/command.js +26 -50
- package/lib/error.js +85 -44
- package/lib/http.js +133 -110
- package/lib/input.js +1044 -8
- package/lib/promise.js +222 -3323
- package/lib/proxy.js +134 -39
- package/lib/test/bootstrap_jasmine.js +28 -0
- package/lib/test/data/actions/click.html +24 -0
- package/lib/test/data/actions/drag.html +77 -0
- package/lib/test/data/actions/record_click.html +21 -0
- package/lib/test/data/chrome/download.html +2 -0
- package/lib/test/data/inputs.html +42 -0
- package/lib/test/data/selectPage.html +12 -0
- package/lib/test/data/simpleTest.html +5 -0
- package/lib/test/data/upload_invisible.html +45 -0
- package/lib/test/fileserver.js +23 -19
- package/lib/test/index.js +30 -212
- package/lib/test/resources.js +0 -1
- package/lib/webdriver.js +675 -936
- package/net/index.js +21 -25
- package/net/portprober.js +51 -68
- package/package.json +5 -3
- package/remote/index.js +5 -19
- package/safari.js +41 -128
- package/test/actions_test.js +173 -18
- package/test/{session_test.js → builder_test.js} +44 -37
- package/test/chrome/devtools_test.js +93 -0
- package/test/chrome/options_test.js +48 -154
- package/test/chrome/service_test.js +7 -7
- package/test/cookie_test.js +77 -63
- package/test/element_finding_test.js +206 -201
- package/test/execute_script_test.js +115 -114
- package/test/fingerprint_test.js +16 -15
- package/test/firefox_test.js +251 -0
- package/test/http/http_test.js +0 -1
- package/test/http/util_test.js +2 -2
- package/test/io/zip_test.js +6 -7
- package/test/lib/error_test.js +34 -7
- package/test/lib/http_test.js +8 -128
- package/test/lib/input_test.js +1379 -0
- package/test/lib/promise_test.js +473 -908
- package/test/lib/webdriver_test.js +296 -868
- package/test/logging_test.js +37 -43
- package/test/page_loading_test.js +71 -81
- package/test/proxy_test.js +64 -72
- package/test/rect_test.js +14 -25
- package/test/remote_test.js +10 -29
- package/test/safari_test.js +7 -71
- package/test/stale_element_test.js +20 -23
- package/test/tag_name_test.js +10 -9
- package/test/upload_test.js +27 -35
- package/test/window_test.js +72 -85
- package/testing/index.js +386 -314
- package/.npmignore +0 -2
- package/example/async_await_test.js +0 -69
- package/example/google_search_generator.js +0 -47
- package/example/parallel_flows.js +0 -51
- package/firefox/binary.js +0 -347
- package/firefox/extension.js +0 -224
- package/firefox/index.js +0 -576
- package/firefox/profile.js +0 -311
- package/lib/events.js +0 -210
- package/lib/test/data/firefox/jetpack-sample.xpi +0 -0
- package/lib/test/data/firefox/sample.xpi +0 -0
- package/lib/test/promise.js +0 -79
- package/opera.js +0 -405
- package/phantomjs.js +0 -282
- package/test/firefox/extension_test.js +0 -120
- package/test/firefox/firefox_test.js +0 -244
- package/test/firefox/profile_test.js +0 -140
- package/test/lib/events_test.js +0 -177
- package/test/lib/promise_aplus_test.js +0 -78
- package/test/lib/promise_error_test.js +0 -884
- package/test/lib/promise_flow_test.js +0 -2288
- package/test/lib/promise_generator_test.js +0 -310
- package/test/phantomjs/execute_phantomjs_test.js +0 -59
- package/test/testing/assert_test.js +0 -373
- package/test/testing/index_test.js +0 -224
- package/testing/assert.js +0 -378
|
@@ -17,186 +17,80 @@
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
const assert = require('assert');
|
|
21
|
+
const fs = require('fs');
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var test = require('../../lib/test');
|
|
23
|
+
const chrome = require('../../chrome');
|
|
24
|
+
const proxy = require('../../proxy');
|
|
25
|
+
const symbols = require('../../lib/symbols');
|
|
26
|
+
const test = require('../../lib/test');
|
|
27
|
+
const webdriver = require('../..');
|
|
29
28
|
|
|
30
29
|
|
|
31
30
|
describe('chrome.Options', function() {
|
|
32
|
-
describe('fromCapabilities', function() {
|
|
33
|
-
|
|
34
|
-
it('should return a new Options instance if none were defined',
|
|
35
|
-
function() {
|
|
36
|
-
var options = chrome.Options.fromCapabilities(
|
|
37
|
-
new webdriver.Capabilities());
|
|
38
|
-
assert(options).instanceOf(chrome.Options);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('should return options instance if present', function() {
|
|
42
|
-
var options = new chrome.Options();
|
|
43
|
-
var caps = options.toCapabilities();
|
|
44
|
-
assert(caps).instanceOf(webdriver.Capabilities);
|
|
45
|
-
assert(chrome.Options.fromCapabilities(caps)).equalTo(options);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('should rebuild options from wire representation', function() {
|
|
49
|
-
var expectedExtension = fs.readFileSync(__filename, 'base64');
|
|
50
|
-
var caps = webdriver.Capabilities.chrome().set('chromeOptions', {
|
|
51
|
-
args: ['a', 'b'],
|
|
52
|
-
extensions: [__filename],
|
|
53
|
-
binary: 'binaryPath',
|
|
54
|
-
logPath: 'logFilePath',
|
|
55
|
-
detach: true,
|
|
56
|
-
localState: 'localStateValue',
|
|
57
|
-
prefs: 'prefsValue'
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
var options = chrome.Options.fromCapabilities(caps);
|
|
61
|
-
var json = options[symbols.serialize]();
|
|
62
|
-
|
|
63
|
-
assert(json.args.length).equalTo(2);
|
|
64
|
-
assert(json.args[0]).equalTo('a');
|
|
65
|
-
assert(json.args[1]).equalTo('b');
|
|
66
|
-
assert(json.extensions.length).equalTo(1);
|
|
67
|
-
assert(json.extensions[0]).equalTo(expectedExtension);
|
|
68
|
-
assert(json.binary).equalTo('binaryPath');
|
|
69
|
-
assert(json.logPath).equalTo('logFilePath');
|
|
70
|
-
assert(json.detach).equalTo(true);
|
|
71
|
-
assert(json.localState).equalTo('localStateValue');
|
|
72
|
-
assert(json.prefs).equalTo('prefsValue');
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('should rebuild options from incomplete wire representation',
|
|
76
|
-
function() {
|
|
77
|
-
var caps = webdriver.Capabilities.chrome().set('chromeOptions', {
|
|
78
|
-
logPath: 'logFilePath'
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
var options = chrome.Options.fromCapabilities(caps);
|
|
82
|
-
var json = options[symbols.serialize]();
|
|
83
|
-
assert(json.args).isUndefined();
|
|
84
|
-
assert(json.binary).isUndefined();
|
|
85
|
-
assert(json.detach).isUndefined();
|
|
86
|
-
assert(json.excludeSwitches).isUndefined();
|
|
87
|
-
assert(json.extensions).isUndefined();
|
|
88
|
-
assert(json.localState).isUndefined();
|
|
89
|
-
assert(json.logPath).equalTo('logFilePath');
|
|
90
|
-
assert(json.prefs).isUndefined();
|
|
91
|
-
assert(json.minidumpPath).isUndefined();
|
|
92
|
-
assert(json.mobileEmulation).isUndefined();
|
|
93
|
-
assert(json.perfLoggingPrefs).isUndefined();
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('should extract supported WebDriver capabilities', function() {
|
|
97
|
-
var proxyPrefs = proxy.direct();
|
|
98
|
-
var logPrefs = {};
|
|
99
|
-
var caps = webdriver.Capabilities.chrome().
|
|
100
|
-
set(webdriver.Capability.PROXY, proxyPrefs).
|
|
101
|
-
set(webdriver.Capability.LOGGING_PREFS, logPrefs);
|
|
102
|
-
|
|
103
|
-
var options = chrome.Options.fromCapabilities(caps);
|
|
104
|
-
assert(options.proxy_).equalTo(proxyPrefs);
|
|
105
|
-
assert(options.logPrefs_).equalTo(logPrefs);
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
|
|
109
31
|
describe('addArguments', function() {
|
|
110
32
|
it('takes var_args', function() {
|
|
111
|
-
|
|
112
|
-
assert
|
|
33
|
+
let options = new chrome.Options();
|
|
34
|
+
assert.deepEqual(
|
|
35
|
+
options[symbols.serialize](),
|
|
36
|
+
{browserName: 'chrome', chromeOptions: {}});
|
|
113
37
|
|
|
114
38
|
options.addArguments('a', 'b');
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
39
|
+
assert.deepEqual(
|
|
40
|
+
options[symbols.serialize](),
|
|
41
|
+
{
|
|
42
|
+
browserName: 'chrome',
|
|
43
|
+
chromeOptions: {
|
|
44
|
+
args: ['a', 'b']
|
|
45
|
+
}
|
|
46
|
+
});
|
|
119
47
|
});
|
|
120
48
|
|
|
121
49
|
it('flattens input arrays', function() {
|
|
122
|
-
|
|
123
|
-
assert
|
|
50
|
+
let options = new chrome.Options();
|
|
51
|
+
assert.deepEqual(
|
|
52
|
+
options[symbols.serialize](),
|
|
53
|
+
{browserName: 'chrome', chromeOptions: {}});
|
|
124
54
|
|
|
125
55
|
options.addArguments(['a', 'b'], 'c', [1, 2], 3);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
56
|
+
assert.deepEqual(
|
|
57
|
+
options[symbols.serialize](),
|
|
58
|
+
{
|
|
59
|
+
browserName: 'chrome',
|
|
60
|
+
chromeOptions: {
|
|
61
|
+
args: ['a', 'b', 'c', 1, 2, 3]
|
|
62
|
+
}
|
|
63
|
+
});
|
|
134
64
|
});
|
|
135
65
|
});
|
|
136
66
|
|
|
137
67
|
describe('addExtensions', function() {
|
|
138
68
|
it('takes var_args', function() {
|
|
139
|
-
|
|
140
|
-
assert(options.
|
|
69
|
+
let options = new chrome.Options();
|
|
70
|
+
assert.strictEqual(options.options_.extensions, undefined);
|
|
141
71
|
|
|
142
72
|
options.addExtensions('a', 'b');
|
|
143
|
-
assert(options.
|
|
144
|
-
assert(options.extensions_[0]).equalTo('a');
|
|
145
|
-
assert(options.extensions_[1]).equalTo('b');
|
|
73
|
+
assert.deepEqual(options.options_.extensions, ['a', 'b']);
|
|
146
74
|
});
|
|
147
75
|
|
|
148
76
|
it('flattens input arrays', function() {
|
|
149
|
-
|
|
150
|
-
assert(options.
|
|
77
|
+
let options = new chrome.Options();
|
|
78
|
+
assert.strictEqual(options.options_.extensions, undefined);
|
|
151
79
|
|
|
152
80
|
options.addExtensions(['a', 'b'], 'c', [1, 2], 3);
|
|
153
|
-
assert(options.
|
|
154
|
-
assert(options.extensions_[0]).equalTo('a');
|
|
155
|
-
assert(options.extensions_[1]).equalTo('b');
|
|
156
|
-
assert(options.extensions_[2]).equalTo('c');
|
|
157
|
-
assert(options.extensions_[3]).equalTo(1);
|
|
158
|
-
assert(options.extensions_[4]).equalTo(2);
|
|
159
|
-
assert(options.extensions_[5]).equalTo(3);
|
|
81
|
+
assert.deepEqual(options.options_.extensions, ['a', 'b', 'c', 1, 2, 3]);
|
|
160
82
|
});
|
|
161
83
|
});
|
|
162
84
|
|
|
163
85
|
describe('serialize', function() {
|
|
164
|
-
it('base64 encodes extensions', function() {
|
|
165
|
-
|
|
166
|
-
|
|
86
|
+
it('base64 encodes extensions', async function() {
|
|
87
|
+
let expected = fs.readFileSync(__filename, 'base64');
|
|
88
|
+
let wire = new chrome.Options()
|
|
167
89
|
.addExtensions(__filename)
|
|
168
90
|
[symbols.serialize]();
|
|
169
|
-
assert(wire.extensions.length).equalTo(1);
|
|
170
|
-
assert(wire.extensions[0]).equalTo(expected);
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
describe('toCapabilities', function() {
|
|
175
|
-
it('returns a new capabilities object if one is not provided', function() {
|
|
176
|
-
var options = new chrome.Options();
|
|
177
|
-
var caps = options.toCapabilities();
|
|
178
|
-
assert(caps.get('browserName')).equalTo('chrome');
|
|
179
|
-
assert(caps.get('chromeOptions')).equalTo(options);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it('adds to input capabilities object', function() {
|
|
183
|
-
var caps = webdriver.Capabilities.firefox();
|
|
184
|
-
var options = new chrome.Options();
|
|
185
|
-
assert(options.toCapabilities(caps)).equalTo(caps);
|
|
186
|
-
assert(caps.get('browserName')).equalTo('firefox');
|
|
187
|
-
assert(caps.get('chromeOptions')).equalTo(options);
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it('sets generic driver capabilities', function() {
|
|
191
|
-
var proxyPrefs = {};
|
|
192
|
-
var loggingPrefs = {};
|
|
193
|
-
var options = new chrome.Options().
|
|
194
|
-
setLoggingPrefs(loggingPrefs).
|
|
195
|
-
setProxy(proxyPrefs);
|
|
196
91
|
|
|
197
|
-
|
|
198
|
-
assert
|
|
199
|
-
assert(caps.get('loggingPrefs')).equalTo(loggingPrefs);
|
|
92
|
+
assert.equal(wire.chromeOptions.extensions.length, 1);
|
|
93
|
+
assert.equal(await wire.chromeOptions.extensions[0], expected);
|
|
200
94
|
});
|
|
201
95
|
});
|
|
202
96
|
});
|
|
@@ -204,24 +98,24 @@ describe('chrome.Options', function() {
|
|
|
204
98
|
test.suite(function(env) {
|
|
205
99
|
var driver;
|
|
206
100
|
|
|
207
|
-
|
|
101
|
+
afterEach(function() {
|
|
208
102
|
return driver.quit();
|
|
209
103
|
});
|
|
210
104
|
|
|
211
105
|
describe('Chrome options', function() {
|
|
212
|
-
|
|
106
|
+
it('can start Chrome with custom args', async function() {
|
|
213
107
|
var options = new chrome.Options().
|
|
214
108
|
addArguments('user-agent=foo;bar');
|
|
215
109
|
|
|
216
|
-
driver =
|
|
110
|
+
driver = await env.builder()
|
|
217
111
|
.setChromeOptions(options)
|
|
218
112
|
.build();
|
|
219
113
|
|
|
220
|
-
|
|
114
|
+
await driver.get(test.Pages.ajaxyPage);
|
|
221
115
|
|
|
222
116
|
var userAgent =
|
|
223
|
-
|
|
224
|
-
assert(userAgent
|
|
117
|
+
await driver.executeScript('return window.navigator.userAgent');
|
|
118
|
+
assert.equal(userAgent, 'foo;bar');
|
|
225
119
|
});
|
|
226
120
|
});
|
|
227
121
|
}, {browsers: ['chrome']});
|
|
@@ -17,28 +17,28 @@
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
chrome = require('../../chrome'),
|
|
22
|
-
assert = require('../../testing/assert');
|
|
20
|
+
const assert = require('assert');
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
const chrome = require('../../chrome');
|
|
23
|
+
const test = require('../../lib/test');
|
|
24
|
+
const webdriver = require('../..');
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
test.suite(function(env) {
|
|
28
28
|
describe('chromedriver', function() {
|
|
29
29
|
var service;
|
|
30
|
-
|
|
30
|
+
afterEach(function() {
|
|
31
31
|
if (service) {
|
|
32
32
|
return service.kill();
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
it('can be started on a custom path', function() {
|
|
37
37
|
service = new chrome.ServiceBuilder()
|
|
38
38
|
.setPath('/foo/bar/baz')
|
|
39
39
|
.build();
|
|
40
40
|
return service.start().then(function(url) {
|
|
41
|
-
assert(url
|
|
41
|
+
assert.ok(url.endsWith('/foo/bar/baz'), 'unexpected url: ' + url);
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
44
|
});
|
package/test/cookie_test.js
CHANGED
|
@@ -20,157 +20,171 @@
|
|
|
20
20
|
var assert = require('assert'),
|
|
21
21
|
url = require('url');
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var {Pages, ignore, suite} = require('../lib/test'),
|
|
24
24
|
fileserver = require('../lib/test/fileserver'),
|
|
25
|
-
Browser = require('..')
|
|
26
|
-
Pages = test.Pages;
|
|
25
|
+
{Browser} = require('..');
|
|
27
26
|
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
suite(function(env) {
|
|
30
29
|
var driver;
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
driver =
|
|
31
|
+
before(async function() {
|
|
32
|
+
driver = await env.builder().build();
|
|
34
33
|
});
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
after(function() {
|
|
37
36
|
return driver.quit();
|
|
38
37
|
});
|
|
39
38
|
|
|
40
|
-
// Cookie handling is broken.
|
|
41
|
-
test.ignore(env.browsers(Browser.PHANTOM_JS, Browser.SAFARI)).
|
|
42
39
|
describe('Cookie Management;', function() {
|
|
43
40
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
beforeEach(async function() {
|
|
42
|
+
await driver.get(fileserver.Pages.ajaxyPage);
|
|
43
|
+
await driver.manage().deleteAllCookies();
|
|
47
44
|
return assertHasCookies();
|
|
48
45
|
});
|
|
49
46
|
|
|
50
|
-
|
|
47
|
+
it('can add new cookies', async function() {
|
|
51
48
|
var cookie = createCookieSpec();
|
|
52
49
|
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
await driver.manage().addCookie(cookie);
|
|
51
|
+
await driver.manage().getCookie(cookie.name).then(function(actual) {
|
|
55
52
|
assert.equal(actual.value, cookie.value);
|
|
56
53
|
});
|
|
57
54
|
});
|
|
58
55
|
|
|
59
|
-
|
|
56
|
+
it('can get all cookies', async function() {
|
|
60
57
|
var cookie1 = createCookieSpec();
|
|
61
58
|
var cookie2 = createCookieSpec();
|
|
62
59
|
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
await driver.manage().addCookie(cookie1);
|
|
61
|
+
await driver.manage().addCookie(cookie2);
|
|
65
62
|
|
|
66
63
|
return assertHasCookies(cookie1, cookie2);
|
|
67
64
|
});
|
|
68
65
|
|
|
69
|
-
|
|
70
|
-
it('only returns cookies visible to the current page', function
|
|
66
|
+
ignore(env.browsers(Browser.IE)).
|
|
67
|
+
it('only returns cookies visible to the current page', async function() {
|
|
71
68
|
var cookie1 = createCookieSpec();
|
|
72
69
|
|
|
73
|
-
|
|
70
|
+
await driver.manage().addCookie(cookie1);
|
|
74
71
|
|
|
75
72
|
var pageUrl = fileserver.whereIs('page/1');
|
|
76
73
|
var cookie2 = createCookieSpec({
|
|
77
74
|
path: url.parse(pageUrl).pathname
|
|
78
75
|
});
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
await driver.get(pageUrl);
|
|
77
|
+
await driver.manage().addCookie(cookie2);
|
|
78
|
+
await assertHasCookies(cookie1, cookie2);
|
|
82
79
|
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
await driver.get(fileserver.Pages.ajaxyPage);
|
|
81
|
+
await assertHasCookies(cookie1);
|
|
85
82
|
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
await driver.get(pageUrl);
|
|
84
|
+
await assertHasCookies(cookie1, cookie2);
|
|
88
85
|
});
|
|
89
86
|
|
|
90
|
-
|
|
87
|
+
it('can delete all cookies', async function() {
|
|
91
88
|
var cookie1 = createCookieSpec();
|
|
92
89
|
var cookie2 = createCookieSpec();
|
|
93
90
|
|
|
94
|
-
|
|
91
|
+
await driver.executeScript(
|
|
95
92
|
'document.cookie = arguments[0] + "=" + arguments[1];' +
|
|
96
93
|
'document.cookie = arguments[2] + "=" + arguments[3];',
|
|
97
94
|
cookie1.name, cookie1.value, cookie2.name, cookie2.value);
|
|
98
|
-
|
|
95
|
+
await assertHasCookies(cookie1, cookie2);
|
|
99
96
|
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
await driver.manage().deleteAllCookies();
|
|
98
|
+
await assertHasCookies();
|
|
102
99
|
});
|
|
103
100
|
|
|
104
|
-
|
|
101
|
+
it('can delete cookies by name', async function() {
|
|
105
102
|
var cookie1 = createCookieSpec();
|
|
106
103
|
var cookie2 = createCookieSpec();
|
|
107
104
|
|
|
108
|
-
|
|
105
|
+
await driver.executeScript(
|
|
109
106
|
'document.cookie = arguments[0] + "=" + arguments[1];' +
|
|
110
107
|
'document.cookie = arguments[2] + "=" + arguments[3];',
|
|
111
108
|
cookie1.name, cookie1.value, cookie2.name, cookie2.value);
|
|
112
|
-
|
|
109
|
+
await assertHasCookies(cookie1, cookie2);
|
|
113
110
|
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
await driver.manage().deleteCookie(cookie1.name);
|
|
112
|
+
await assertHasCookies(cookie2);
|
|
116
113
|
});
|
|
117
114
|
|
|
118
|
-
|
|
115
|
+
it('should only delete cookie with exact name', async function() {
|
|
119
116
|
var cookie1 = createCookieSpec();
|
|
120
117
|
var cookie2 = createCookieSpec();
|
|
121
118
|
var cookie3 = {name: cookie1.name + 'xx', value: cookie1.value};
|
|
122
119
|
|
|
123
|
-
|
|
120
|
+
await driver.executeScript(
|
|
124
121
|
'document.cookie = arguments[0] + "=" + arguments[1];' +
|
|
125
122
|
'document.cookie = arguments[2] + "=" + arguments[3];' +
|
|
126
123
|
'document.cookie = arguments[4] + "=" + arguments[5];',
|
|
127
124
|
cookie1.name, cookie1.value, cookie2.name, cookie2.value,
|
|
128
125
|
cookie3.name, cookie3.value);
|
|
129
|
-
|
|
126
|
+
await assertHasCookies(cookie1, cookie2, cookie3);
|
|
130
127
|
|
|
131
|
-
|
|
132
|
-
|
|
128
|
+
await driver.manage().deleteCookie(cookie1.name);
|
|
129
|
+
await assertHasCookies(cookie2, cookie3);
|
|
133
130
|
});
|
|
134
131
|
|
|
135
|
-
|
|
132
|
+
it('can delete cookies set higher in the path', async function() {
|
|
136
133
|
var cookie = createCookieSpec();
|
|
137
134
|
var childUrl = fileserver.whereIs('child/childPage.html');
|
|
138
135
|
var grandchildUrl = fileserver.whereIs(
|
|
139
136
|
'child/grandchild/grandchildPage.html');
|
|
140
137
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
138
|
+
await driver.get(childUrl);
|
|
139
|
+
await driver.manage().addCookie(cookie);
|
|
140
|
+
await assertHasCookies(cookie);
|
|
144
141
|
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
await driver.get(grandchildUrl);
|
|
143
|
+
await assertHasCookies(cookie);
|
|
147
144
|
|
|
148
|
-
|
|
149
|
-
|
|
145
|
+
await driver.manage().deleteCookie(cookie.name);
|
|
146
|
+
await assertHasCookies();
|
|
150
147
|
|
|
151
|
-
|
|
152
|
-
|
|
148
|
+
await driver.get(childUrl);
|
|
149
|
+
await assertHasCookies();
|
|
153
150
|
});
|
|
154
151
|
|
|
155
|
-
|
|
156
|
-
Browser.ANDROID,
|
|
152
|
+
ignore(env.browsers(
|
|
157
153
|
Browser.FIREFOX,
|
|
158
|
-
'legacy-' + Browser.FIREFOX,
|
|
159
154
|
Browser.IE)).
|
|
160
|
-
it('should retain cookie expiry', function
|
|
155
|
+
it('should retain cookie expiry', async function() {
|
|
161
156
|
let expirationDelay = 5 * 1000;
|
|
162
157
|
let expiry = new Date(Date.now() + expirationDelay);
|
|
163
158
|
let cookie = createCookieSpec({expiry});
|
|
164
159
|
|
|
165
|
-
|
|
166
|
-
|
|
160
|
+
await driver.manage().addCookie(cookie);
|
|
161
|
+
await driver.manage().getCookie(cookie.name).then(function(actual) {
|
|
167
162
|
assert.equal(actual.value, cookie.value);
|
|
168
|
-
|
|
169
|
-
|
|
163
|
+
|
|
164
|
+
// expiry times should be in seconds since January 1, 1970 UTC
|
|
165
|
+
try {
|
|
166
|
+
assert.equal(actual.expiry, Math.floor(expiry.getTime() / 1000));
|
|
167
|
+
assert.notEqual(
|
|
168
|
+
env.browser.name, Browser.SAFARI,
|
|
169
|
+
'Safari cookie expiry fixed; update test');
|
|
170
|
+
} catch (ex) {
|
|
171
|
+
if (env.browser.name !== Browser.SAFARI
|
|
172
|
+
|| !(ex instanceof assert.AssertionError)) {
|
|
173
|
+
throw ex;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Safari returns milliseconds (and is off by a few seconds...)
|
|
177
|
+
let diff = Math.abs(actual.expiry - expiry.getTime());
|
|
178
|
+
if (diff > 2000) {
|
|
179
|
+
assert.fail(
|
|
180
|
+
actual.expiry, expiry.getTime(),
|
|
181
|
+
'Expect Safari to return expiry in millis since epoch ± 2s');
|
|
182
|
+
}
|
|
183
|
+
}
|
|
170
184
|
});
|
|
171
185
|
|
|
172
|
-
|
|
173
|
-
|
|
186
|
+
await driver.sleep(expirationDelay);
|
|
187
|
+
await assertHasCookies();
|
|
174
188
|
});
|
|
175
189
|
});
|
|
176
190
|
|