selenium-webdriver 4.0.0-alpha.3 → 4.0.0-alpha.4

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.
Files changed (95) hide show
  1. package/CHANGES.md +8 -1
  2. package/LICENSE +202 -0
  3. package/NOTICE +2 -0
  4. package/README.md +0 -0
  5. package/chrome.js +0 -0
  6. package/edge.js +0 -0
  7. package/example/chrome_android.js +0 -0
  8. package/example/chrome_mobile_emulation.js +0 -0
  9. package/example/firefox_channels.js +0 -0
  10. package/example/google_search.js +0 -0
  11. package/example/google_search_test.js +0 -0
  12. package/example/headless.js +0 -0
  13. package/example/logging.js +0 -0
  14. package/firefox.js +20 -3
  15. package/http/index.js +0 -0
  16. package/http/util.js +0 -0
  17. package/ie.js +0 -0
  18. package/index.js +0 -0
  19. package/io/exec.js +0 -0
  20. package/io/index.js +0 -0
  21. package/io/zip.js +0 -0
  22. package/lib/actions.js +0 -0
  23. package/lib/by.js +0 -0
  24. package/lib/capabilities.js +0 -0
  25. package/lib/command.js +0 -0
  26. package/lib/error.js +0 -0
  27. package/lib/http.js +0 -0
  28. package/lib/input.js +0 -0
  29. package/lib/logging.js +0 -0
  30. package/lib/promise.js +0 -0
  31. package/lib/proxy.js +0 -0
  32. package/lib/session.js +0 -0
  33. package/lib/symbols.js +0 -0
  34. package/lib/until.js +0 -0
  35. package/lib/webdriver.js +0 -0
  36. package/net/index.js +0 -0
  37. package/net/portprober.js +0 -0
  38. package/package.json +1 -1
  39. package/proxy.js +0 -0
  40. package/remote/index.js +0 -0
  41. package/safari.js +0 -0
  42. package/testing/index.js +0 -0
  43. package/BUILD.bazel +0 -88
  44. package/jasmine.json +0 -11
  45. package/lib/README +0 -5
  46. package/lib/atoms/BUILD.bazel +0 -28
  47. package/lib/atoms/make-atoms-module.js +0 -12
  48. package/lib/test/bootstrap_jasmine.js +0 -28
  49. package/lib/test/build.js +0 -156
  50. package/lib/test/data/actions/click.html +0 -24
  51. package/lib/test/data/actions/drag.html +0 -77
  52. package/lib/test/data/actions/record_click.html +0 -21
  53. package/lib/test/data/chrome/download.html +0 -2
  54. package/lib/test/data/firefox/webextension.xpi +0 -0
  55. package/lib/test/fileserver.js +0 -337
  56. package/lib/test/httpserver.js +0 -120
  57. package/lib/test/index.js +0 -87
  58. package/lib/test/resources.js +0 -40
  59. package/test/actions_test.js +0 -206
  60. package/test/builder_test.js +0 -106
  61. package/test/chrome/devtools_test.js +0 -93
  62. package/test/chrome/options_test.js +0 -121
  63. package/test/chrome/service_test.js +0 -45
  64. package/test/cookie_test.js +0 -210
  65. package/test/element_finding_test.js +0 -431
  66. package/test/execute_script_test.js +0 -355
  67. package/test/fingerprint_test.js +0 -63
  68. package/test/firefox_test.js +0 -233
  69. package/test/frame_test.js +0 -45
  70. package/test/http/http_test.js +0 -229
  71. package/test/http/util_test.js +0 -178
  72. package/test/io/io_test.js +0 -364
  73. package/test/io/zip_test.js +0 -126
  74. package/test/lib/by_test.js +0 -160
  75. package/test/lib/capabilities_test.js +0 -129
  76. package/test/lib/error_test.js +0 -333
  77. package/test/lib/http_test.js +0 -576
  78. package/test/lib/input_test.js +0 -1379
  79. package/test/lib/logging_test.js +0 -272
  80. package/test/lib/promise_test.js +0 -674
  81. package/test/lib/testutil.js +0 -90
  82. package/test/lib/until_test.js +0 -478
  83. package/test/lib/webdriver_test.js +0 -1692
  84. package/test/logging_test.js +0 -160
  85. package/test/net/index_test.js +0 -60
  86. package/test/net/portprober_test.js +0 -128
  87. package/test/page_loading_test.js +0 -156
  88. package/test/proxy_test.js +0 -167
  89. package/test/rect_test.js +0 -51
  90. package/test/remote_test.js +0 -98
  91. package/test/safari_test.js +0 -44
  92. package/test/stale_element_test.js +0 -60
  93. package/test/upload_test.js +0 -78
  94. package/test/window_test.js +0 -168
  95. package/tools/init_jasmine.js +0 -7
@@ -1,121 +0,0 @@
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
- const assert = require('assert');
21
- const fs = require('fs');
22
-
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('../..');
28
-
29
-
30
- describe('chrome.Options', function() {
31
- describe('addArguments', function() {
32
- it('takes var_args', function() {
33
- let options = new chrome.Options();
34
- assert.deepEqual(
35
- options[symbols.serialize](),
36
- {browserName: 'chrome', 'goog:chromeOptions': {}});
37
-
38
- options.addArguments('a', 'b');
39
- assert.deepEqual(
40
- options[symbols.serialize](),
41
- {
42
- browserName: 'chrome',
43
- 'goog:chromeOptions': {
44
- args: ['a', 'b']
45
- }
46
- });
47
- });
48
-
49
- it('flattens input arrays', function() {
50
- let options = new chrome.Options();
51
- assert.deepEqual(
52
- options[symbols.serialize](),
53
- {browserName: 'chrome', 'goog:chromeOptions': {}});
54
-
55
- options.addArguments(['a', 'b'], 'c', [1, 2], 3);
56
- assert.deepEqual(
57
- options[symbols.serialize](),
58
- {
59
- browserName: 'chrome',
60
- 'goog:chromeOptions': {
61
- args: ['a', 'b', 'c', 1, 2, 3]
62
- }
63
- });
64
- });
65
- });
66
-
67
- describe('addExtensions', function() {
68
- it('takes var_args', function() {
69
- let options = new chrome.Options();
70
- assert.strictEqual(options.options_.extensions, undefined);
71
-
72
- options.addExtensions('a', 'b');
73
- assert.deepEqual(options.options_.extensions, ['a', 'b']);
74
- });
75
-
76
- it('flattens input arrays', function() {
77
- let options = new chrome.Options();
78
- assert.strictEqual(options.options_.extensions, undefined);
79
-
80
- options.addExtensions(['a', 'b'], 'c', [1, 2], 3);
81
- assert.deepEqual(options.options_.extensions, ['a', 'b', 'c', 1, 2, 3]);
82
- });
83
- });
84
-
85
- describe('serialize', function() {
86
- it('base64 encodes extensions', async function() {
87
- let expected = fs.readFileSync(__filename, 'base64');
88
- let wire = new chrome.Options()
89
- .addExtensions(__filename)
90
- [symbols.serialize]();
91
-
92
- assert.equal(wire['goog:chromeOptions'].extensions.length, 1);
93
- assert.equal(await wire['goog:chromeOptions'].extensions[0], expected);
94
- });
95
- });
96
- });
97
-
98
- test.suite(function(env) {
99
- var driver;
100
-
101
- afterEach(function() {
102
- return driver.quit();
103
- });
104
-
105
- describe('Chrome options', function() {
106
- it('can start Chrome with custom args', async function() {
107
- var options = new chrome.Options().
108
- addArguments('user-agent=foo;bar');
109
-
110
- driver = await env.builder()
111
- .setChromeOptions(options)
112
- .build();
113
-
114
- await driver.get(test.Pages.ajaxyPage);
115
-
116
- var userAgent =
117
- await driver.executeScript('return window.navigator.userAgent');
118
- assert.equal(userAgent, 'foo;bar');
119
- });
120
- });
121
- }, {browsers: ['chrome']});
@@ -1,45 +0,0 @@
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
- const assert = require('assert');
21
-
22
- const chrome = require('../../chrome');
23
- const test = require('../../lib/test');
24
- const webdriver = require('../..');
25
-
26
-
27
- test.suite(function(env) {
28
- describe('chromedriver', function() {
29
- var service;
30
- afterEach(function() {
31
- if (service) {
32
- return service.kill();
33
- }
34
- });
35
-
36
- it('can be started on a custom path', function() {
37
- service = new chrome.ServiceBuilder()
38
- .setPath('/foo/bar/baz')
39
- .build();
40
- return service.start().then(function(url) {
41
- assert.ok(url.endsWith('/foo/bar/baz'), 'unexpected url: ' + url);
42
- });
43
- });
44
- });
45
- }, {browsers: ['chrome']});
@@ -1,210 +0,0 @@
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
- var assert = require('assert'),
21
- url = require('url');
22
-
23
- var {Pages, ignore, suite} = require('../lib/test'),
24
- fileserver = require('../lib/test/fileserver'),
25
- {Browser} = require('..');
26
-
27
-
28
- suite(function(env) {
29
- var driver;
30
-
31
- before(async function() {
32
- driver = await env.builder().build();
33
- });
34
-
35
- after(function() {
36
- return driver.quit();
37
- });
38
-
39
- describe('Cookie Management;', function() {
40
-
41
- beforeEach(async function() {
42
- await driver.get(fileserver.Pages.ajaxyPage);
43
- await driver.manage().deleteAllCookies();
44
- return assertHasCookies();
45
- });
46
-
47
- it('can add new cookies', async function() {
48
- var cookie = createCookieSpec();
49
-
50
- await driver.manage().addCookie(cookie);
51
- await driver.manage().getCookie(cookie.name).then(function(actual) {
52
- assert.equal(actual.value, cookie.value);
53
- });
54
- });
55
-
56
- it('can get all cookies', async function() {
57
- var cookie1 = createCookieSpec();
58
- var cookie2 = createCookieSpec();
59
-
60
- await driver.manage().addCookie(cookie1);
61
- await driver.manage().addCookie(cookie2);
62
-
63
- return assertHasCookies(cookie1, cookie2);
64
- });
65
-
66
- ignore(env.browsers(Browser.IE)).
67
- it('only returns cookies visible to the current page', async function() {
68
- var cookie1 = createCookieSpec();
69
-
70
- await driver.manage().addCookie(cookie1);
71
-
72
- var pageUrl = fileserver.whereIs('page/1');
73
- var cookie2 = createCookieSpec({
74
- path: url.parse(pageUrl).pathname
75
- });
76
- await driver.get(pageUrl);
77
- await driver.manage().addCookie(cookie2);
78
- await assertHasCookies(cookie1, cookie2);
79
-
80
- await driver.get(fileserver.Pages.ajaxyPage);
81
- await assertHasCookies(cookie1);
82
-
83
- await driver.get(pageUrl);
84
- await assertHasCookies(cookie1, cookie2);
85
- });
86
-
87
- it('can delete all cookies', async function() {
88
- var cookie1 = createCookieSpec();
89
- var cookie2 = createCookieSpec();
90
-
91
- await driver.executeScript(
92
- 'document.cookie = arguments[0] + "=" + arguments[1];' +
93
- 'document.cookie = arguments[2] + "=" + arguments[3];',
94
- cookie1.name, cookie1.value, cookie2.name, cookie2.value);
95
- await assertHasCookies(cookie1, cookie2);
96
-
97
- await driver.manage().deleteAllCookies();
98
- await assertHasCookies();
99
- });
100
-
101
- it('can delete cookies by name', async function() {
102
- var cookie1 = createCookieSpec();
103
- var cookie2 = createCookieSpec();
104
-
105
- await driver.executeScript(
106
- 'document.cookie = arguments[0] + "=" + arguments[1];' +
107
- 'document.cookie = arguments[2] + "=" + arguments[3];',
108
- cookie1.name, cookie1.value, cookie2.name, cookie2.value);
109
- await assertHasCookies(cookie1, cookie2);
110
-
111
- await driver.manage().deleteCookie(cookie1.name);
112
- await assertHasCookies(cookie2);
113
- });
114
-
115
- it('should only delete cookie with exact name', async function() {
116
- var cookie1 = createCookieSpec();
117
- var cookie2 = createCookieSpec();
118
- var cookie3 = {name: cookie1.name + 'xx', value: cookie1.value};
119
-
120
- await driver.executeScript(
121
- 'document.cookie = arguments[0] + "=" + arguments[1];' +
122
- 'document.cookie = arguments[2] + "=" + arguments[3];' +
123
- 'document.cookie = arguments[4] + "=" + arguments[5];',
124
- cookie1.name, cookie1.value, cookie2.name, cookie2.value,
125
- cookie3.name, cookie3.value);
126
- await assertHasCookies(cookie1, cookie2, cookie3);
127
-
128
- await driver.manage().deleteCookie(cookie1.name);
129
- await assertHasCookies(cookie2, cookie3);
130
- });
131
-
132
- it('can delete cookies set higher in the path', async function() {
133
- var cookie = createCookieSpec();
134
- var childUrl = fileserver.whereIs('child/childPage.html');
135
- var grandchildUrl = fileserver.whereIs(
136
- 'child/grandchild/grandchildPage.html');
137
-
138
- await driver.get(childUrl);
139
- await driver.manage().addCookie(cookie);
140
- await assertHasCookies(cookie);
141
-
142
- await driver.get(grandchildUrl);
143
- await assertHasCookies(cookie);
144
-
145
- await driver.manage().deleteCookie(cookie.name);
146
- await assertHasCookies();
147
-
148
- await driver.get(childUrl);
149
- await assertHasCookies();
150
- });
151
-
152
- ignore(env.browsers(
153
- Browser.FIREFOX,
154
- Browser.IE)).
155
- it('should retain cookie expiry', async function() {
156
- let expirationDelay = 5 * 1000;
157
- let expiry = new Date(Date.now() + expirationDelay);
158
- let cookie = createCookieSpec({expiry});
159
-
160
- await driver.manage().addCookie(cookie);
161
- await driver.manage().getCookie(cookie.name).then(function(actual) {
162
- assert.equal(actual.value, cookie.value);
163
-
164
- // expiry times should be in seconds since January 1, 1970 UTC
165
- assert.equal(actual.expiry, Math.floor(expiry.getTime() / 1000));
166
- });
167
-
168
- await driver.sleep(expirationDelay);
169
- await assertHasCookies();
170
- });
171
- });
172
-
173
- function createCookieSpec(opt_options) {
174
- let spec = {
175
- name: getRandomString(),
176
- value: getRandomString()
177
- };
178
- if (opt_options) {
179
- spec = Object.assign(spec, opt_options);
180
- }
181
- return spec;
182
- }
183
-
184
- function buildCookieMap(cookies) {
185
- var map = {};
186
- cookies.forEach(function(cookie) {
187
- map[cookie.name] = cookie;
188
- });
189
- return map;
190
- }
191
-
192
- function assertHasCookies(...expected) {
193
- return driver.manage().getCookies().then(function(cookies) {
194
- assert.equal(cookies.length, expected.length,
195
- 'Wrong # of cookies.' +
196
- '\n Expected: ' + JSON.stringify(expected) +
197
- '\n Was : ' + JSON.stringify(cookies));
198
-
199
- var map = buildCookieMap(cookies);
200
- for (var i = 0; i < expected.length; ++i) {
201
- assert.equal(expected[i].value, map[expected[i].name].value);
202
- }
203
- });
204
- }
205
-
206
- function getRandomString() {
207
- var x = 1234567890;
208
- return Math.floor(Math.random() * x).toString(36);
209
- }
210
- });