selenium-webdriver 3.3.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.
Files changed (117) hide show
  1. package/CHANGES.md +273 -0
  2. package/NOTICE +1 -1
  3. package/README.md +28 -36
  4. package/chrome.js +221 -146
  5. package/edge.js +43 -118
  6. package/example/chrome_android.js +8 -9
  7. package/example/chrome_mobile_emulation.js +9 -10
  8. package/example/firefox_channels.js +23 -19
  9. package/example/google_search.js +3 -3
  10. package/example/google_search_test.js +39 -27
  11. package/example/headless.js +55 -0
  12. package/example/logging.js +40 -7
  13. package/firefox.js +769 -0
  14. package/http/index.js +41 -4
  15. package/http/util.js +11 -6
  16. package/ie.js +57 -98
  17. package/index.js +182 -115
  18. package/io/index.js +59 -0
  19. package/io/zip.js +214 -0
  20. package/jasmine.json +11 -0
  21. package/lib/actions.js +68 -63
  22. package/lib/atoms/get-attribute.js +9 -0
  23. package/lib/atoms/is-displayed.js +73 -78
  24. package/lib/by.js +9 -1
  25. package/lib/capabilities.js +303 -201
  26. package/lib/command.js +28 -50
  27. package/lib/error.js +113 -42
  28. package/lib/http.js +167 -135
  29. package/lib/input.js +1044 -8
  30. package/lib/promise.js +222 -3331
  31. package/lib/proxy.js +134 -39
  32. package/lib/test/bootstrap_jasmine.js +28 -0
  33. package/lib/test/data/actions/click.html +24 -0
  34. package/lib/test/data/actions/drag.html +77 -0
  35. package/lib/test/data/actions/record_click.html +21 -0
  36. package/lib/test/data/chrome/download.html +2 -0
  37. package/lib/test/data/click_tests/disabled_element.html +12 -0
  38. package/lib/test/data/content-editable.html +10 -0
  39. package/lib/test/data/firefox/webextension.xpi +0 -0
  40. package/lib/test/data/inputs.html +42 -0
  41. package/lib/test/data/key_logger.html +34 -0
  42. package/lib/test/data/nestedElements.html +10 -1
  43. package/lib/test/data/scrolling_tests/page_with_partially_hidden_element.html +14 -0
  44. package/lib/test/data/selectPage.html +12 -0
  45. package/lib/test/data/simpleTest.html +5 -0
  46. package/lib/test/data/single_text_input.html +12 -0
  47. package/lib/test/data/upload_invisible.html +45 -0
  48. package/lib/test/fileserver.js +23 -19
  49. package/lib/test/index.js +30 -244
  50. package/lib/test/resources.js +0 -1
  51. package/lib/webdriver.js +770 -939
  52. package/net/index.js +21 -25
  53. package/net/portprober.js +51 -68
  54. package/package.json +6 -4
  55. package/remote/index.js +18 -30
  56. package/safari.js +42 -129
  57. package/test/actions_test.js +173 -18
  58. package/test/builder_test.js +106 -0
  59. package/test/chrome/devtools_test.js +93 -0
  60. package/test/chrome/options_test.js +48 -154
  61. package/test/chrome/service_test.js +7 -7
  62. package/test/cookie_test.js +77 -63
  63. package/test/element_finding_test.js +206 -201
  64. package/test/execute_script_test.js +115 -114
  65. package/test/fingerprint_test.js +16 -15
  66. package/test/firefox_test.js +251 -0
  67. package/test/http/http_test.js +18 -1
  68. package/test/http/util_test.js +2 -2
  69. package/test/{io_test.js → io/io_test.js} +40 -1
  70. package/test/io/zip_test.js +127 -0
  71. package/test/lib/by_test.js +21 -0
  72. package/test/lib/error_test.js +55 -8
  73. package/test/lib/http_test.js +18 -130
  74. package/test/lib/input_test.js +1379 -0
  75. package/test/lib/promise_test.js +473 -908
  76. package/test/lib/webdriver_test.js +357 -825
  77. package/test/logging_test.js +37 -43
  78. package/test/page_loading_test.js +70 -86
  79. package/test/proxy_test.js +64 -72
  80. package/test/rect_test.js +14 -25
  81. package/test/remote_test.js +13 -32
  82. package/test/safari_test.js +7 -71
  83. package/test/stale_element_test.js +20 -23
  84. package/test/tag_name_test.js +10 -9
  85. package/test/upload_test.js +27 -35
  86. package/test/window_test.js +72 -85
  87. package/testing/index.js +386 -315
  88. package/.npmignore +0 -2
  89. package/example/async_await_test.js +0 -68
  90. package/example/google_search_generator.js +0 -50
  91. package/example/parallel_flows.js +0 -54
  92. package/firefox/binary.js +0 -344
  93. package/firefox/extension.js +0 -187
  94. package/firefox/index.js +0 -722
  95. package/firefox/profile.js +0 -430
  96. package/lib/atoms/getAttribute.js +0 -12
  97. package/lib/events.js +0 -210
  98. package/lib/firefox/webdriver.json +0 -70
  99. package/lib/firefox/webdriver.xpi +0 -0
  100. package/lib/test/data/firefox/jetpack-sample.xpi +0 -0
  101. package/lib/test/data/firefox/sample.xpi +0 -0
  102. package/lib/test/promise.js +0 -79
  103. package/opera.js +0 -405
  104. package/phantomjs.js +0 -282
  105. package/test/firefox/extension_test.js +0 -96
  106. package/test/firefox/firefox_test.js +0 -226
  107. package/test/firefox/profile_test.js +0 -185
  108. package/test/lib/events_test.js +0 -177
  109. package/test/lib/promise_aplus_test.js +0 -78
  110. package/test/lib/promise_error_test.js +0 -884
  111. package/test/lib/promise_flow_test.js +0 -2288
  112. package/test/lib/promise_generator_test.js +0 -310
  113. package/test/phantomjs/execute_phantomjs_test.js +0 -59
  114. package/test/session_test.js +0 -54
  115. package/test/testing/assert_test.js +0 -373
  116. package/test/testing/index_test.js +0 -224
  117. package/testing/assert.js +0 -378
@@ -22,6 +22,7 @@
22
22
  * WebDriver session.
23
23
  */
24
24
 
25
+ const proxy = require('./proxy');
25
26
  const Symbols = require('./symbols');
26
27
 
27
28
 
@@ -30,161 +31,190 @@ const Symbols = require('./symbols');
30
31
  * @enum {string}
31
32
  */
32
33
  const Browser = {
33
- ANDROID: 'android',
34
34
  CHROME: 'chrome',
35
35
  EDGE: 'MicrosoftEdge',
36
36
  FIREFOX: 'firefox',
37
37
  IE: 'internet explorer',
38
38
  INTERNET_EXPLORER: 'internet explorer',
39
- IPAD: 'iPad',
40
- IPHONE: 'iPhone',
41
- OPERA: 'opera',
42
- PHANTOM_JS: 'phantomjs',
43
39
  SAFARI: 'safari',
44
- HTMLUNIT: 'htmlunit'
45
40
  };
46
41
 
47
42
 
48
43
  /**
49
- * Common Capability keys.
44
+ * Strategies for waiting for [document readiness] after a navigation
45
+ * event.
46
+ *
47
+ * [document readiness]: https://html.spec.whatwg.org/#current-document-readiness
48
+ *
50
49
  * @enum {string}
51
50
  */
52
- const Capability = {
51
+ const PageLoadStrategy = {
52
+ /**
53
+ * Indicates WebDriver should not wait on the document readiness state after a
54
+ * navigation event.
55
+ */
56
+ NONE: 'none',
53
57
 
54
58
  /**
55
- * Indicates whether a driver should accept all SSL certs by default. This
56
- * capability only applies when requesting a new session. To query whether
57
- * a driver can handle insecure SSL certs, see {@link #SECURE_SSL}.
59
+ * Indicates WebDriver should wait for the document readiness state to
60
+ * become "interactive" after navigation.
58
61
  */
59
- ACCEPT_SSL_CERTS: 'acceptSslCerts',
62
+ EAGER: 'eager',
63
+
64
+ /**
65
+ * Indicates WebDriver should wait for the document readiness state to
66
+ * be "complete" after navigation. This is the default page loading strategy.
67
+ */
68
+ NORMAL: 'normal'
69
+ };
70
+
71
+
72
+ /**
73
+ * Common platform names. These platforms are not explicitly defined by the
74
+ * WebDriver spec, however, their use is encouraged for interoperability.
75
+ *
76
+ * @enum {string}
77
+ * @see <https://w3c.github.io/webdriver/webdriver-spec.html>
78
+ */
79
+ const Platform = {
80
+ LINUX: 'linux',
81
+ MAC: 'mac',
82
+ WINDOWS: 'windows'
83
+ };
84
+
85
+
86
+ /**
87
+ * Record object defining the timeouts that apply to certain WebDriver actions.
88
+ *
89
+ * @record
90
+ */
91
+ function Timeouts() {}
92
+
93
+ /**
94
+ * Defines when, in milliseconds, to interupt a script that is being
95
+ * {@linkplain ./webdriver.IWebDriver#executeScript evaluated}.
96
+ * @type {number}
97
+ */
98
+ Timeouts.prototype.script;
99
+
100
+ /**
101
+ * The timeout, in milliseconds, to apply to navigation events along with the
102
+ * {@link PageLoadStrategy}.
103
+ * @type {number}
104
+ */
105
+ Timeouts.prototype.pageLoad;
106
+
107
+ /**
108
+ * The maximimum amount of time, in milliseconds, to spend attempting to
109
+ * {@linkplain ./webdriver.IWebDriver#findElement locate} an element on the
110
+ * current page.
111
+ * @type {number}
112
+ */
113
+ Timeouts.prototype.implicit;
60
114
 
61
115
 
116
+ /**
117
+ * The possible default actions a WebDriver session can take to respond to
118
+ * unhandled user prompts (`window.alert()`, `window.confirm()`, and
119
+ * `window.prompt()`).
120
+ *
121
+ * @enum {string}
122
+ */
123
+ const UserPromptHandler = {
124
+ /** All prompts should be silently accepted. */
125
+ ACCEPT: 'accept',
126
+ /** All prompts should be silently dismissed. */
127
+ DISMISS: 'dismiss',
62
128
  /**
63
- * The browser name. Common browser names are defined in the {@link Browser}
64
- * enum.
129
+ * All prompts should be automatically accepted, but an error should be
130
+ * returned to the next (or currently executing) WebDriver command.
65
131
  */
66
- BROWSER_NAME: 'browserName',
132
+ ACCEPT_AND_NOTIFY: 'accept and notify',
133
+ /**
134
+ * All prompts should be automatically dismissed, but an error should be
135
+ * returned to the next (or currently executing) WebDriver command.
136
+ */
137
+ DISMISS_AND_NOTIFY: 'dismiss and notify',
138
+ /** All prompts should be left unhandled. */
139
+ IGNORE: 'ignore'
140
+ };
141
+
142
+
143
+ /**
144
+ * The standard WebDriver capability keys.
145
+ *
146
+ * @enum {string}
147
+ * @see <https://w3c.github.io/webdriver/webdriver-spec.html#capabilities>
148
+ */
149
+ const Capability = {
67
150
 
68
151
  /**
69
- * Defines how elements should be scrolled into the viewport for interaction.
70
- * This capability will be set to zero (0) if elements are aligned with the
71
- * top of the viewport, or one (1) if aligned with the bottom. The default
72
- * behavior is to align with the top of the viewport.
152
+ * Indicates whether a WebDriver session implicity trusts otherwise untrusted
153
+ * and self-signed TLS certificates during navigation.
73
154
  */
74
- ELEMENT_SCROLL_BEHAVIOR: 'elementScrollBehavior',
155
+ ACCEPT_INSECURE_TLS_CERTS: 'acceptInsecureCerts',
75
156
 
76
157
  /**
77
- * Whether the driver is capable of handling modal alerts (e.g. alert,
78
- * confirm, prompt). To define how a driver <i>should</i> handle alerts,
79
- * use {@link #UNEXPECTED_ALERT_BEHAVIOR}.
158
+ * The browser name. Common browser names are defined in the
159
+ * {@link ./capabilities.Browser Browser} enum.
80
160
  */
81
- HANDLES_ALERTS: 'handlesAlerts',
161
+ BROWSER_NAME: 'browserName',
162
+
163
+ /** Identifies the browser version. */
164
+ BROWSER_VERSION: 'browserVersion',
82
165
 
83
166
  /**
84
167
  * Key for the logging driver logging preferences.
168
+ * The browser name. Common browser names are defined in the
169
+ * {@link ./capabilities.Browser Browser} enum.
85
170
  */
86
171
  LOGGING_PREFS: 'loggingPrefs',
87
172
 
88
173
  /**
89
- * Whether this session generates native events when simulating user input.
174
+ * Defines the session's
175
+ * {@linkplain ./capabilities.PageLoadStrategy page loading strategy}.
90
176
  */
91
- NATIVE_EVENTS: 'nativeEvents',
177
+ PAGE_LOAD_STRATEGY: 'pageLoadStrategy',
92
178
 
93
179
  /**
94
- * Describes the platform the browser is running on. Will be one of
95
- * ANDROID, IOS, LINUX, MAC, UNIX, or WINDOWS. When <i>requesting</i> a
96
- * session, ANY may be used to indicate no platform preference (this is
97
- * semantically equivalent to omitting the platform capability).
180
+ * Identifies the operating system of the endpoint node. Common values
181
+ * recognized by the most WebDriver server implementations are predefined in
182
+ * the {@link ./capabilities.Platform Platform} enum.
98
183
  */
99
- PLATFORM: 'platform',
184
+ PLATFORM_NAME: 'platformName',
100
185
 
101
186
  /**
102
187
  * Describes the proxy configuration to use for a new WebDriver session.
103
188
  */
104
189
  PROXY: 'proxy',
105
190
 
106
- /** Whether the driver supports changing the browser's orientation. */
107
- ROTATABLE: 'rotatable',
108
-
109
191
  /**
110
- * Whether a driver is only capable of handling secure SSL certs. To request
111
- * that a driver accept insecure SSL certs by default, use
112
- * {@link #ACCEPT_SSL_CERTS}.
192
+ * Indicates whether the remote end supports all of the window resizing and
193
+ * positioning commands:
194
+ *
195
+ * - {@linkplain ./webdriver.Window#getRect Window.getRect()}
196
+ * - {@linkplain ./webdriver.Window#setRect Window.setRect()}
197
+ * - {@linkplain ./webdriver.Window#maximize Window.maximize()}
198
+ * - {@linkplain ./webdriver.Window#minimize Window.minimize()}
199
+ * - {@linkplain ./webdriver.Window#fullscreen Window.fullscreen()}
113
200
  */
114
- SECURE_SSL: 'secureSsl',
115
-
116
- /** Whether the driver supports manipulating the app cache. */
117
- SUPPORTS_APPLICATION_CACHE: 'applicationCacheEnabled',
118
-
119
- /** Whether the driver supports locating elements with CSS selectors. */
120
- SUPPORTS_CSS_SELECTORS: 'cssSelectorsEnabled',
121
-
122
- /** Whether the browser supports JavaScript. */
123
- SUPPORTS_JAVASCRIPT: 'javascriptEnabled',
124
-
125
- /** Whether the driver supports controlling the browser's location info. */
126
- SUPPORTS_LOCATION_CONTEXT: 'locationContextEnabled',
127
-
128
- /** Whether the driver supports taking screenshots. */
129
- TAKES_SCREENSHOT: 'takesScreenshot',
201
+ SET_WINDOW_RECT: 'setWindowRect',
130
202
 
131
203
  /**
132
- * Defines how the driver should handle unexpected alerts. The value should
133
- * be one of "accept", "dismiss", or "ignore".
204
+ * Describes the {@linkplain ./capabilities.Timeouts timeouts} imposed on
205
+ * certain session operations.
134
206
  */
135
- UNEXPECTED_ALERT_BEHAVIOR: 'unexpectedAlertBehavior',
207
+ TIMEOUTS: 'timeouts',
136
208
 
137
- /** Defines the browser version. */
138
- VERSION: 'version'
209
+ /**
210
+ * Defines how a WebDriver session should
211
+ * {@linkplain ./capabilities.UserPromptHandler respond} to unhandled user
212
+ * prompts.
213
+ */
214
+ UNHANDLED_PROMPT_BEHAVIOR: 'unhandledPromptBehavior',
139
215
  };
140
216
 
141
217
 
142
- /**
143
- * Describes how a proxy should be configured for a WebDriver session.
144
- * @record
145
- */
146
- function ProxyConfig() {}
147
-
148
- /**
149
- * The proxy type. Must be one of {"manual", "pac", "system"}.
150
- * @type {string}
151
- */
152
- ProxyConfig.prototype.proxyType;
153
-
154
- /**
155
- * URL for the PAC file to use. Only used if {@link #proxyType} is "pac".
156
- * @type {(string|undefined)}
157
- */
158
- ProxyConfig.prototype.proxyAutoconfigUrl;
159
-
160
- /**
161
- * The proxy host for FTP requests. Only used if {@link #proxyType} is "manual".
162
- * @type {(string|undefined)}
163
- */
164
- ProxyConfig.prototype.ftpProxy;
165
-
166
- /**
167
- * The proxy host for HTTP requests. Only used if {@link #proxyType} is
168
- * "manual".
169
- * @type {(string|undefined)}
170
- */
171
- ProxyConfig.prototype.httpProxy;
172
-
173
- /**
174
- * The proxy host for HTTPS requests. Only used if {@link #proxyType} is
175
- * "manual".
176
- * @type {(string|undefined)}
177
- */
178
- ProxyConfig.prototype.sslProxy;
179
-
180
- /**
181
- * A comma delimited list of hosts which should bypass all proxies. Only used if
182
- * {@link #proxyType} is "manual".
183
- * @type {(string|undefined)}
184
- */
185
- ProxyConfig.prototype.noProxy;
186
-
187
-
188
218
  /**
189
219
  * Converts a generic hash object to a map.
190
220
  * @param {!Object<string, ?>} hash The hash object.
@@ -204,128 +234,93 @@ function toMap(hash) {
204
234
  /**
205
235
  * Describes a set of capabilities for a WebDriver session.
206
236
  */
207
- class Capabilities extends Map {
237
+ class Capabilities {
208
238
  /**
209
- * @param {(Capabilities|Map<string, ?>|Object)=} opt_other Another set of
239
+ * @param {(Capabilities|Map<string, ?>|Object)=} other Another set of
210
240
  * capabilities to initialize this instance from.
211
241
  */
212
- constructor(opt_other) {
213
- if (opt_other && !(opt_other instanceof Map)) {
214
- opt_other = toMap(opt_other);
242
+ constructor(other = undefined) {
243
+ if (other instanceof Capabilities) {
244
+ other = other.map_;
245
+ } else if (other && !(other instanceof Map)) {
246
+ other = toMap(other);
215
247
  }
216
- super(opt_other);
217
- }
218
-
219
- /**
220
- * @return {!Capabilities} A basic set of capabilities for Android.
221
- */
222
- static android() {
223
- return new Capabilities()
224
- .set(Capability.BROWSER_NAME, Browser.ANDROID)
225
- .set(Capability.PLATFORM, 'ANDROID');
248
+ /** @private @const {!Map<string, ?>} */
249
+ this.map_ = new Map(other);
226
250
  }
227
251
 
228
252
  /**
229
253
  * @return {!Capabilities} A basic set of capabilities for Chrome.
230
254
  */
231
255
  static chrome() {
232
- return new Capabilities().set(Capability.BROWSER_NAME, Browser.CHROME);
256
+ return new Capabilities().setBrowserName(Browser.CHROME);
233
257
  }
234
258
 
235
259
  /**
236
260
  * @return {!Capabilities} A basic set of capabilities for Microsoft Edge.
237
261
  */
238
262
  static edge() {
239
- return new Capabilities()
240
- .set(Capability.BROWSER_NAME, Browser.EDGE)
241
- .set(Capability.PLATFORM, 'WINDOWS');
263
+ return new Capabilities().setBrowserName(Browser.EDGE);
242
264
  }
243
265
 
244
266
  /**
245
267
  * @return {!Capabilities} A basic set of capabilities for Firefox.
246
268
  */
247
269
  static firefox() {
248
- return new Capabilities().set(Capability.BROWSER_NAME, Browser.FIREFOX);
270
+ return new Capabilities().setBrowserName(Browser.FIREFOX);
249
271
  }
250
272
 
251
273
  /**
252
274
  * @return {!Capabilities} A basic set of capabilities for Internet Explorer.
253
275
  */
254
276
  static ie() {
255
- return new Capabilities().
256
- set(Capability.BROWSER_NAME, Browser.INTERNET_EXPLORER).
257
- set(Capability.PLATFORM, 'WINDOWS');
258
- }
259
-
260
- /**
261
- * @return {!Capabilities} A basic set of capabilities for iPad.
262
- */
263
- static ipad() {
264
- return new Capabilities().
265
- set(Capability.BROWSER_NAME, Browser.IPAD).
266
- set(Capability.PLATFORM, 'MAC');
267
- }
268
-
269
- /**
270
- * @return {!Capabilities} A basic set of capabilities for iPhone.
271
- */
272
- static iphone() {
273
- return new Capabilities().
274
- set(Capability.BROWSER_NAME, Browser.IPHONE).
275
- set(Capability.PLATFORM, 'MAC');
277
+ return new Capabilities().setBrowserName(Browser.INTERNET_EXPLORER);
276
278
  }
277
279
 
278
280
  /**
279
- * @return {!Capabilities} A basic set of capabilities for Opera.
281
+ * @return {!Capabilities} A basic set of capabilities for Safari.
280
282
  */
281
- static opera() {
282
- return new Capabilities().
283
- set(Capability.BROWSER_NAME, Browser.OPERA);
283
+ static safari() {
284
+ return new Capabilities().setBrowserName(Browser.SAFARI);
284
285
  }
285
286
 
286
287
  /**
287
- * @return {!Capabilities} A basic set of capabilities for PhantomJS.
288
+ * @return {!Object<string, ?>} The JSON representation of this instance.
289
+ * Note, the returned object may contain nested promised values.
290
+ * @suppress {checkTypes} Suppress [] access on a struct (state inherited from
291
+ * Map).
288
292
  */
289
- static phantomjs() {
290
- return new Capabilities().
291
- set(Capability.BROWSER_NAME, Browser.PHANTOM_JS);
293
+ [Symbols.serialize]() {
294
+ return serialize(this);
292
295
  }
293
296
 
294
297
  /**
295
- * @return {!Capabilities} A basic set of capabilities for Safari.
298
+ * @param {string} key the parameter key to get.
299
+ * @return {T} the stored parameter value.
300
+ * @template T
296
301
  */
297
- static safari() {
298
- return new Capabilities().
299
- set(Capability.BROWSER_NAME, Browser.SAFARI).
300
- set(Capability.PLATFORM, 'MAC');
302
+ get(key) {
303
+ return this.map_.get(key);
301
304
  }
302
305
 
303
306
  /**
304
- * @return {!Capabilities} A basic set of capabilities for HTMLUnit.
307
+ * @param {string} key the key to test.
308
+ * @return {boolean} whether this capability set has the specified key.
305
309
  */
306
- static htmlunit() {
307
- return new Capabilities().
308
- set(Capability.BROWSER_NAME, Browser.HTMLUNIT);
310
+ has(key) {
311
+ return this.map_.has(key);
309
312
  }
310
313
 
311
314
  /**
312
- * @return {!Capabilities} A basic set of capabilities for HTMLUnit
313
- * with enabled Javascript.
315
+ * @return {!Iterator<string>} an iterator of the keys set.
314
316
  */
315
- static htmlunitwithjs() {
316
- return new Capabilities().
317
- set(Capability.BROWSER_NAME, Browser.HTMLUNIT).
318
- set(Capability.SUPPORTS_JAVASCRIPT, true);
317
+ keys() {
318
+ return this.map_.keys();
319
319
  }
320
320
 
321
- /**
322
- * @return {!Object<string, ?>} The JSON representation of this instance.
323
- * Note, the returned object may contain nested promised values.
324
- * @suppress {checkTypes} Suppress [] access on a struct (state inherited from
325
- * Map).
326
- */
327
- [Symbols.serialize]() {
328
- return serialize(this);
321
+ /** @return {number} The number of capabilities set. */
322
+ get size() {
323
+ return this.map_.size;
329
324
  }
330
325
 
331
326
  /**
@@ -339,7 +334,12 @@ class Capabilities extends Map {
339
334
  throw new TypeError('no capabilities provided for merge');
340
335
  }
341
336
 
342
- if (!(other instanceof Map)) {
337
+ let map;
338
+ if (other instanceof Capabilities) {
339
+ map = other.map_;
340
+ } else if (other instanceof Map) {
341
+ map = other;
342
+ } else {
343
343
  other = toMap(other);
344
344
  }
345
345
 
@@ -350,21 +350,121 @@ class Capabilities extends Map {
350
350
  return this;
351
351
  }
352
352
 
353
+ /**
354
+ * Deletes an entry from this set of capabilities.
355
+ *
356
+ * @param {string} key the capability key to delete.
357
+ */
358
+ delete(key) {
359
+ this.map_.delete(key);
360
+ }
361
+
353
362
  /**
354
363
  * @param {string} key The capability key.
355
364
  * @param {*} value The capability value.
356
365
  * @return {!Capabilities} A self reference.
357
366
  * @throws {TypeError} If the `key` is not a string.
358
- * @override
359
367
  */
360
368
  set(key, value) {
361
369
  if (typeof key !== 'string') {
362
370
  throw new TypeError('Capability keys must be strings: ' + typeof key);
363
371
  }
364
- super.set(key, value);
372
+ this.map_.set(key, value);
365
373
  return this;
366
374
  }
367
375
 
376
+ /**
377
+ * Sets whether a WebDriver session should implicitly accept self-signed, or
378
+ * other untrusted TLS certificates on navigation.
379
+ *
380
+ * @param {boolean} accept whether to accept insecure certs.
381
+ * @return {!Capabilities} a self reference.
382
+ */
383
+ setAcceptInsecureCerts(accept) {
384
+ return this.set(Capability.ACCEPT_INSECURE_TLS_CERTS, accept);
385
+ }
386
+
387
+ /**
388
+ * @return {boolean} whether the session is configured to accept insecure
389
+ * TLS certificates.
390
+ */
391
+ getAcceptInsecureCerts() {
392
+ return this.get(Capability.ACCEPT_INSECURE_TLS_CERTS);
393
+ }
394
+
395
+ /**
396
+ * Sets the name of the target browser.
397
+ *
398
+ * @param {(Browser|string)} name the browser name.
399
+ * @return {!Capabilities} a self reference.
400
+ */
401
+ setBrowserName(name) {
402
+ return this.set(Capability.BROWSER_NAME, name);
403
+ }
404
+
405
+ /**
406
+ * @return {(string|undefined)} the configured browser name, or undefined if
407
+ * not set.
408
+ */
409
+ getBrowserName() {
410
+ return this.get(Capability.BROWSER_NAME);
411
+ }
412
+
413
+ /**
414
+ * Sets the desired version of the target browser.
415
+ *
416
+ * @param {string} version the desired version.
417
+ * @return {!Capabilities} a self reference.
418
+ */
419
+ setBrowserVersion(version) {
420
+ return this.set(Capability.BROWSER_VERSION, version);
421
+ }
422
+
423
+ /**
424
+ * @return {(string|undefined)} the configured browser version, or undefined
425
+ * if not set.
426
+ */
427
+ getBrowserVersion() {
428
+ return this.get(Capability.BROWSER_VERSION);
429
+ }
430
+
431
+ /**
432
+ * Sets the desired page loading strategy for a new WebDriver session.
433
+ *
434
+ * @param {PageLoadStrategy} strategy the desired strategy.
435
+ * @return {!Capabilities} a self reference.
436
+ */
437
+ setPageLoadStrategy(strategy) {
438
+ return this.set(Capability.PAGE_LOAD_STRATEGY, strategy);
439
+ }
440
+
441
+ /**
442
+ * Returns the configured page load strategy.
443
+ *
444
+ * @return {(string|undefined)} the page load strategy.
445
+ */
446
+ getPageLoadStrategy() {
447
+ return this.get(Capability.PAGE_LOAD_STRATEGY);
448
+ }
449
+
450
+ /**
451
+ * Sets the target platform.
452
+ *
453
+ * @param {(Platform|string)} platform the target platform.
454
+ * @return {!Capabilities} a self reference.
455
+ */
456
+ setPlatform(platform) {
457
+ return this.set(Capability.PLATFORM_NAME, platform);
458
+ }
459
+
460
+ /**
461
+ * @return {(string|undefined)} the configured platform or undefined if not
462
+ * set.
463
+ */
464
+ getPlatform() {
465
+ return this.get(Capability.PLATFORM_NAME);
466
+ }
467
+
368
468
  /**
369
469
  * Sets the logging preferences. Preferences may be specified as a
370
470
  * {@link ./logging.Preferences} instance, or as a map of log-type to
@@ -379,7 +479,7 @@ class Capabilities extends Map {
379
479
 
380
480
  /**
381
481
  * Sets the proxy configuration for this instance.
382
- * @param {ProxyConfig} proxy The desired proxy configuration.
482
+ * @param {proxy.Config} proxy The desired proxy configuration.
383
483
  * @return {!Capabilities} A self reference.
384
484
  */
385
485
  setProxy(proxy) {
@@ -387,33 +487,32 @@ class Capabilities extends Map {
387
487
  }
388
488
 
389
489
  /**
390
- * Sets whether native events should be used.
391
- * @param {boolean} enabled Whether to enable native events.
392
- * @return {!Capabilities} A self reference.
490
+ * @return {(proxy.Config|undefined)} the configured proxy settings, or
491
+ * undefined if not set.
393
492
  */
394
- setEnableNativeEvents(enabled) {
395
- return this.set(Capability.NATIVE_EVENTS, enabled);
493
+ getProxy() {
494
+ return this.get(Capability.PROXY);
396
495
  }
397
496
 
398
497
  /**
399
- * Sets how elements should be scrolled into view for interaction.
400
- * @param {number} behavior The desired scroll behavior: either 0 to align
401
- * with the top of the viewport or 1 to align with the bottom.
498
+ * Sets the default action to take with an unexpected alert before returning
499
+ * an error. If unspecified, WebDriver will default to
500
+ * {@link UserPromptHandler.DISMISS_AND_NOTIFY}.
501
+ *
502
+ * @param {?UserPromptHandler} behavior The way WebDriver should respond to
503
+ * unhandled user prompts.
402
504
  * @return {!Capabilities} A self reference.
403
505
  */
404
- setScrollBehavior(behavior) {
405
- return this.set(Capability.ELEMENT_SCROLL_BEHAVIOR, behavior);
506
+ setAlertBehavior(behavior) {
507
+ return this.set(Capability.UNHANDLED_PROMPT_BEHAVIOR, behavior);
406
508
  }
407
509
 
408
510
  /**
409
- * Sets the default action to take with an unexpected alert before returning
410
- * an error.
411
- * @param {string} behavior The desired behavior should be "accept",
412
- * "dismiss", or "ignore". Defaults to "dismiss".
413
- * @return {!Capabilities} A self reference.
511
+ * @return {(UserPromptHandler|undefined)} the behavior pattern for responding
512
+ * to unhandled user prompts, or undefined if not set.
414
513
  */
415
- setAlertBehavior(behavior) {
416
- return this.set(Capability.UNEXPECTED_ALERT_BEHAVIOR, behavior);
514
+ getAlertBehavior() {
515
+ return this.get(Capability.UNHANDLED_PROMPT_BEHAVIOR);
417
516
  }
418
517
  }
419
518
 
@@ -443,8 +542,11 @@ function serialize(caps) {
443
542
 
444
543
 
445
544
  module.exports = {
446
- Browser: Browser,
447
- Capabilities: Capabilities,
448
- Capability: Capability,
449
- ProxyConfig: ProxyConfig
545
+ Browser,
546
+ Capabilities,
547
+ Capability,
548
+ PageLoadStrategy,
549
+ Platform,
550
+ Timeouts,
551
+ UserPromptHandler,
450
552
  };