selenium-webdriver 3.1.0 → 3.6.0
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 +112 -0
- package/NOTICE +1 -1
- package/README.md +5 -11
- package/chrome.js +122 -33
- package/edge.js +2 -2
- package/example/async_await_test.js +69 -0
- package/example/chrome_android.js +2 -3
- package/example/chrome_mobile_emulation.js +3 -4
- package/example/firefox_channels.js +3 -3
- package/example/google_search.js +3 -3
- package/example/google_search_generator.js +2 -5
- package/example/google_search_test.js +5 -6
- package/example/headless.js +55 -0
- package/example/logging.js +3 -3
- package/example/parallel_flows.js +4 -7
- package/firefox/binary.js +3 -0
- package/firefox/extension.js +118 -81
- package/firefox/index.js +117 -263
- package/firefox/profile.js +18 -137
- package/ie.js +2 -2
- package/index.js +4 -1
- package/io/index.js +59 -0
- package/io/zip.js +214 -0
- package/lib/atoms/get-attribute.js +9 -0
- package/lib/atoms/is-displayed.js +73 -78
- package/lib/by.js +8 -0
- package/lib/capabilities.js +61 -22
- package/lib/command.js +2 -0
- package/lib/error.js +32 -2
- package/lib/http.js +53 -44
- package/lib/promise.js +72 -25
- package/lib/test/data/click_tests/disabled_element.html +12 -0
- package/lib/test/data/content-editable.html +10 -0
- package/lib/test/data/firefox/webextension.xpi +0 -0
- package/lib/test/data/key_logger.html +34 -0
- package/lib/test/data/nestedElements.html +10 -1
- package/lib/test/data/scrolling_tests/page_with_partially_hidden_element.html +14 -0
- package/lib/test/data/single_text_input.html +12 -0
- package/lib/test/index.js +4 -36
- package/lib/webdriver.js +147 -55
- package/net/portprober.js +1 -1
- package/opera.js +1 -1
- package/package.json +2 -2
- package/phantomjs.js +2 -2
- package/remote/index.js +21 -14
- package/safari.js +2 -2
- package/test/firefox/extension_test.js +41 -17
- package/test/firefox/firefox_test.js +37 -19
- package/test/firefox/profile_test.js +14 -59
- package/test/http/http_test.js +18 -0
- package/test/{io_test.js → io/io_test.js} +40 -1
- package/test/io/zip_test.js +128 -0
- package/test/lib/by_test.js +21 -0
- package/test/lib/error_test.js +21 -1
- package/test/lib/http_test.js +11 -3
- package/test/lib/webdriver_test.js +107 -3
- package/test/page_loading_test.js +0 -6
- package/test/remote_test.js +3 -3
- package/test/session_test.js +68 -23
- package/testing/index.js +2 -3
- package/lib/atoms/getAttribute.js +0 -12
- package/lib/firefox/amd64/libnoblur64.so +0 -0
- package/lib/firefox/i386/libnoblur.so +0 -0
- package/lib/firefox/webdriver.json +0 -69
- package/lib/firefox/webdriver.xpi +0 -0
package/CHANGES.md
CHANGED
|
@@ -1,3 +1,114 @@
|
|
|
1
|
+
## v3.6.0
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* The Capabilities factory methods should only specify the name of the browser.
|
|
6
|
+
* Protect against the remote end sometimes not returning a list to findElements
|
|
7
|
+
commands.
|
|
8
|
+
* Properly reset state in `remote.DriverService#kill()`
|
|
9
|
+
* The firefox module will no longer apply the preferences required by the legacy
|
|
10
|
+
FirefoxDriver. These preferences were only required when using the legacy
|
|
11
|
+
driver, support for which was dropped in v3.5.0.
|
|
12
|
+
|
|
13
|
+
### API Changes
|
|
14
|
+
|
|
15
|
+
* Added new methods to `selenium-webdriver/firefox.Options`:
|
|
16
|
+
- addArguments()
|
|
17
|
+
- headless()
|
|
18
|
+
- windowSize()
|
|
19
|
+
* Deprecated `selenium-webdriver/firefox/binary.Binary`
|
|
20
|
+
* Removed `selenium-webdriver/firefox.Options#useGeckoDriver()`
|
|
21
|
+
* Removed the unused `selenium-webdriver/firefox/profile.decode()`
|
|
22
|
+
* Removed methods from `selenium-webdriver/firefox/profile.Profile` that had
|
|
23
|
+
no effect since support for the legacy FirefoxDriver was dropped in 3.5.0:
|
|
24
|
+
- setNativeEventsEnabled
|
|
25
|
+
- nativeEventsEnabled
|
|
26
|
+
- getPort
|
|
27
|
+
- setPort
|
|
28
|
+
* Removed `selenium-webdriver/firefox.ServiceBuilder#setFirefoxBinary()`; custom
|
|
29
|
+
binaries should be configured through the `firefox.Options` class.
|
|
30
|
+
* Removed `selenium-webdriver/firefox.Capability`. These hold overs from the
|
|
31
|
+
legacy FirefoxDriver are no longer supported.
|
|
32
|
+
|
|
33
|
+
### Changes for W3C WebDriver Spec Compliance
|
|
34
|
+
|
|
35
|
+
* Deprecated `error.ElementNotVisibleError` in favor of the more generic
|
|
36
|
+
`error.ElementNotInteractableError`.
|
|
37
|
+
* Support the `httpOnly` option when adding a cookie.
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## v3.5.0
|
|
41
|
+
|
|
42
|
+
### Notice
|
|
43
|
+
|
|
44
|
+
Native support for Firefox 45 (ESR) has been removed. Users will have to connect
|
|
45
|
+
to a remote Selenium server that supports Firefox 45.
|
|
46
|
+
|
|
47
|
+
### Changes
|
|
48
|
+
|
|
49
|
+
* Removed native support for Firefox 46 and older.
|
|
50
|
+
- The `SELENIUM_MARIONETTE` enviornment variable no longer has an effect.
|
|
51
|
+
- `selenium-webdriver/firefox.Capability.MARIONETTE` is deprecated.
|
|
52
|
+
- `selenium-webdriver/firefox.Options#useGeckoDriver()` is deprecated and now a no-op.
|
|
53
|
+
* `firefox.Options` will no longer discard the `"moz:firefoxOptions"` set in
|
|
54
|
+
user provided capabilities (via `Builder.withCapabilities({})`). When both
|
|
55
|
+
are used, the settings in `firefox.Options` will be applied _last_.
|
|
56
|
+
* Added `chrome.Options#headless()` and `chrome.Options#windowSize()`, which
|
|
57
|
+
may be used to start Chrome in headless mode (requires Chrome 59+) and to set
|
|
58
|
+
the initial window size, respectively.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
### Changes for W3C WebDriver Spec Compliance
|
|
62
|
+
|
|
63
|
+
* Added `error.WebDriverError#remoteStacktrace` to capture the stacktrace
|
|
64
|
+
reported by a remote WebDriver endpoint (if any).
|
|
65
|
+
* Fixed `WebElement#sendKeys` to send text as a string instead of an array of
|
|
66
|
+
strings.
|
|
67
|
+
|
|
68
|
+
## v3.4.0
|
|
69
|
+
|
|
70
|
+
### Notice
|
|
71
|
+
|
|
72
|
+
This release requires [geckodriver 0.15.0](https://github.com/mozilla/geckodriver/releases/tag/v0.15.0) or newer.
|
|
73
|
+
|
|
74
|
+
### API Changes
|
|
75
|
+
|
|
76
|
+
* Added `Options#getTimeouts()` for retrieving the currently configured session
|
|
77
|
+
timeouts (i.e. implicit wait). This method will only work with W3C compatible
|
|
78
|
+
WebDriver implementations.
|
|
79
|
+
* Deprecated the `Timeouts` class in favor of `Options#setTimeouts()`, which
|
|
80
|
+
supports setting multiple timeouts at once.
|
|
81
|
+
* Added support for emulating different network conditions (e.g., offline, 2G, WiFi) on Chrome.
|
|
82
|
+
|
|
83
|
+
### Changes for W3C WebDriver Spec Compliance
|
|
84
|
+
|
|
85
|
+
* Fixed W3C response parsing, which expects response data to always be a JSON
|
|
86
|
+
object with a `value` key.
|
|
87
|
+
* Added W3C endpoints for interacting with various types of
|
|
88
|
+
[user prompts](https://w3c.github.io/webdriver/webdriver-spec.html#user-prompts).
|
|
89
|
+
* Added W3C endpoints for remotely executing scripts.
|
|
90
|
+
* Added W3C endpoints to get current window handle and all windows handles.
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
## v3.3.0
|
|
94
|
+
|
|
95
|
+
* Added warning log messages when the user creates new managed promises, or
|
|
96
|
+
schedules unchained tasks. Users may opt in to printing these log messages
|
|
97
|
+
with
|
|
98
|
+
|
|
99
|
+
```js
|
|
100
|
+
const {logging} = require('selenium-webdriver');
|
|
101
|
+
logging.installConsoleHandler();
|
|
102
|
+
logging.getLogger('promise.ControlFlow').setLevel(logging.Level.WARNING);
|
|
103
|
+
```
|
|
104
|
+
* If the `JAVA_HOME` environment variable is set, use it to locate java.exe.
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
## v3.2.0
|
|
108
|
+
|
|
109
|
+
* Release skipped to stay in sync with the main Selenium project.
|
|
110
|
+
|
|
111
|
+
|
|
1
112
|
## v3.1.0
|
|
2
113
|
|
|
3
114
|
* The `lib` package is once again platform agnostic (excluding `lib/devmode`).
|
|
@@ -17,6 +128,7 @@
|
|
|
17
128
|
* Use the proper wire command for WebElement.getLocation() and
|
|
18
129
|
WebElement.getSize() for W3C compliant drivers.
|
|
19
130
|
|
|
131
|
+
|
|
20
132
|
## v3.0.1
|
|
21
133
|
|
|
22
134
|
* More API adjustments to align with native Promises
|
package/NOTICE
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Copyright 2011-
|
|
1
|
+
Copyright 2011-2017 Software Freedom Conservancy
|
|
2
2
|
Copyright 2004-2011 Selenium committers
|
package/README.md
CHANGED
|
@@ -17,16 +17,13 @@ be placed on your system [PATH]. Apple's safaridriver is shipped with
|
|
|
17
17
|
Safari 10 for OS X El Capitan and macOS Sierra. You will need to enable Remote
|
|
18
18
|
Automation in the Develop menu of Safari 10 before testing.
|
|
19
19
|
|
|
20
|
-
> **NOTE:** Mozilla's [geckodriver] is only required for Firefox 47+.
|
|
21
|
-
> Everything you need for Firefox 38-46 is included with this package.
|
|
22
|
-
|
|
23
20
|
|
|
24
21
|
| Browser | Component |
|
|
25
22
|
| ----------------- | ---------------------------------- |
|
|
26
23
|
| Chrome | [chromedriver(.exe)][chrome] |
|
|
27
24
|
| Internet Explorer | [IEDriverServer.exe][release] |
|
|
28
25
|
| Edge | [MicrosoftWebDriver.msi][edge] |
|
|
29
|
-
| Firefox
|
|
26
|
+
| Firefox | [geckodriver(.exe)][geckodriver] |
|
|
30
27
|
| PhantomJS | [phantomjs(.exe)][phantomjs] |
|
|
31
28
|
| Opera | [operadriver(.exe)][opera] |
|
|
32
29
|
| Safari | [safaridriver] |
|
|
@@ -36,17 +33,14 @@ Automation in the Develop menu of Safari 10 before testing.
|
|
|
36
33
|
The sample below and others are included in the `example` directory. You may
|
|
37
34
|
also find the tests for selenium-webdriver informative.
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
By = webdriver.By,
|
|
41
|
-
until = webdriver.until;
|
|
36
|
+
const {Builder, By, Key, until} = require('selenium-webdriver');
|
|
42
37
|
|
|
43
|
-
|
|
38
|
+
let driver = new Builder()
|
|
44
39
|
.forBrowser('firefox')
|
|
45
40
|
.build();
|
|
46
41
|
|
|
47
42
|
driver.get('http://www.google.com/ncr');
|
|
48
|
-
driver.findElement(By.name('q')).sendKeys('webdriver');
|
|
49
|
-
driver.findElement(By.name('btnG')).click();
|
|
43
|
+
driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
|
|
50
44
|
driver.wait(until.titleIs('webdriver - Google Search'), 1000);
|
|
51
45
|
driver.quit();
|
|
52
46
|
|
|
@@ -193,7 +187,7 @@ the issue tracker
|
|
|
193
187
|
- __Do not__ post empty "I see this too" or "Any updates?" comments. These
|
|
194
188
|
provide no additional information and clutter the log.
|
|
195
189
|
- __Do not__ report regressions on closed bugs as they are not actively
|
|
196
|
-
monitored for
|
|
190
|
+
monitored for updates (especially bugs that are >6 months old). Please open a
|
|
197
191
|
new issue and reference the original bug in your report.
|
|
198
192
|
|
|
199
193
|
## License
|
package/chrome.js
CHANGED
|
@@ -36,6 +36,20 @@
|
|
|
36
36
|
* a unique browser session with a clean user profile (unless otherwise
|
|
37
37
|
* configured through the {@link Options} class).
|
|
38
38
|
*
|
|
39
|
+
* __Headless Chrome__ <a id="headless"></a>
|
|
40
|
+
*
|
|
41
|
+
* To start Chrome in headless mode, simply call
|
|
42
|
+
* {@linkplain Options#headless Options.headless()}. Note, starting in headless
|
|
43
|
+
* mode currently also disables GPU acceleration.
|
|
44
|
+
*
|
|
45
|
+
* let chrome = require('selenium-webdriver/chrome');
|
|
46
|
+
* let {Builder} = require('selenium-webdriver');
|
|
47
|
+
*
|
|
48
|
+
* let driver = new Builder()
|
|
49
|
+
* .forBrowser('chrome')
|
|
50
|
+
* .setChromeOptions(new chrome.Options().headless())
|
|
51
|
+
* .build();
|
|
52
|
+
*
|
|
39
53
|
* __Customizing the ChromeDriver Server__ <a id="custom-server"></a>
|
|
40
54
|
*
|
|
41
55
|
* By default, every Chrome session will use a single driver service, which is
|
|
@@ -114,19 +128,19 @@
|
|
|
114
128
|
|
|
115
129
|
'use strict';
|
|
116
130
|
|
|
117
|
-
const fs = require('fs')
|
|
118
|
-
|
|
131
|
+
const fs = require('fs');
|
|
132
|
+
const util = require('util');
|
|
119
133
|
|
|
120
|
-
const http = require('./http')
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
134
|
+
const http = require('./http');
|
|
135
|
+
const io = require('./io');
|
|
136
|
+
const {Capabilities, Capability} = require('./lib/capabilities');
|
|
137
|
+
const command = require('./lib/command');
|
|
138
|
+
const logging = require('./lib/logging');
|
|
139
|
+
const promise = require('./lib/promise');
|
|
140
|
+
const Symbols = require('./lib/symbols');
|
|
141
|
+
const webdriver = require('./lib/webdriver');
|
|
142
|
+
const portprober = require('./net/portprober');
|
|
143
|
+
const remote = require('./remote');
|
|
130
144
|
|
|
131
145
|
|
|
132
146
|
/**
|
|
@@ -143,7 +157,9 @@ const CHROMEDRIVER_EXE =
|
|
|
143
157
|
* @enum {string}
|
|
144
158
|
*/
|
|
145
159
|
const Command = {
|
|
146
|
-
LAUNCH_APP: 'launchApp'
|
|
160
|
+
LAUNCH_APP: 'launchApp',
|
|
161
|
+
GET_NETWORK_CONDITIONS: 'getNetworkConditions',
|
|
162
|
+
SET_NETWORK_CONDITIONS: 'setNetworkConditions'
|
|
147
163
|
};
|
|
148
164
|
|
|
149
165
|
|
|
@@ -169,6 +185,14 @@ function configureExecutor(executor) {
|
|
|
169
185
|
Command.LAUNCH_APP,
|
|
170
186
|
'POST',
|
|
171
187
|
'/session/:sessionId/chromium/launch_app');
|
|
188
|
+
executor.defineCommand(
|
|
189
|
+
Command.GET_NETWORK_CONDITIONS,
|
|
190
|
+
'GET',
|
|
191
|
+
'/session/:sessionId/chromium/network_conditions');
|
|
192
|
+
executor.defineCommand(
|
|
193
|
+
Command.SET_NETWORK_CONDITIONS,
|
|
194
|
+
'POST',
|
|
195
|
+
'/session/:sessionId/chromium/network_conditions');
|
|
172
196
|
}
|
|
173
197
|
|
|
174
198
|
|
|
@@ -283,11 +307,7 @@ function getDefaultService() {
|
|
|
283
307
|
}
|
|
284
308
|
|
|
285
309
|
|
|
286
|
-
|
|
287
|
-
* @type {string}
|
|
288
|
-
* @const
|
|
289
|
-
*/
|
|
290
|
-
let OPTIONS_CAPABILITY_KEY = 'chromeOptions';
|
|
310
|
+
const OPTIONS_CAPABILITY_KEY = 'chromeOptions';
|
|
291
311
|
|
|
292
312
|
|
|
293
313
|
/**
|
|
@@ -352,28 +372,61 @@ class Options {
|
|
|
352
372
|
* browser. Each argument may be specified with or without the "--" prefix
|
|
353
373
|
* (e.g. "--foo" and "foo"). Arguments with an associated value should be
|
|
354
374
|
* delimited by an "=": "foo=bar".
|
|
355
|
-
*
|
|
375
|
+
*
|
|
376
|
+
* @param {...(string|!Array<string>)} args The arguments to add.
|
|
356
377
|
* @return {!Options} A self reference.
|
|
357
378
|
*/
|
|
358
|
-
addArguments(
|
|
359
|
-
let
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
this.options_.args = args;
|
|
379
|
+
addArguments(...args) {
|
|
380
|
+
let newArgs = (this.options_.args || []).concat(...args);
|
|
381
|
+
if (newArgs.length) {
|
|
382
|
+
this.options_.args = newArgs;
|
|
363
383
|
}
|
|
364
384
|
return this;
|
|
365
385
|
}
|
|
366
386
|
|
|
387
|
+
/**
|
|
388
|
+
* Configures the chromedriver to start Chrome in headless mode.
|
|
389
|
+
*
|
|
390
|
+
* > __NOTE:__ Resizing the browser window in headless mode is only supported
|
|
391
|
+
* > in Chrome 60. Users are encouraged to set an initial window size with
|
|
392
|
+
* > the {@link #windowSize windowSize({width, height})} option.
|
|
393
|
+
*
|
|
394
|
+
* @return {!Options} A self reference.
|
|
395
|
+
*/
|
|
396
|
+
headless() {
|
|
397
|
+
// TODO(jleyba): Remove `disable-gpu` once head Chrome no longer requires
|
|
398
|
+
// that to be set.
|
|
399
|
+
return this.addArguments('headless', 'disable-gpu');
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Sets the initial window size.
|
|
404
|
+
*
|
|
405
|
+
* @param {{width: number, height: number}} size The desired window size.
|
|
406
|
+
* @return {!Options} A self reference.
|
|
407
|
+
* @throws {TypeError} if width or height is unspecified, not a number, or
|
|
408
|
+
* less than or equal to 0.
|
|
409
|
+
*/
|
|
410
|
+
windowSize({width, height}) {
|
|
411
|
+
function checkArg(arg) {
|
|
412
|
+
if (typeof arg !== 'number' || arg <= 0) {
|
|
413
|
+
throw TypeError('Arguments must be {width, height} with numbers > 0');
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
checkArg(width);
|
|
417
|
+
checkArg(height);
|
|
418
|
+
return this.addArguments(`window-size=${width},${height}`);
|
|
419
|
+
}
|
|
420
|
+
|
|
367
421
|
/**
|
|
368
422
|
* List of Chrome command line switches to exclude that ChromeDriver by default
|
|
369
423
|
* passes when starting Chrome. Do not prefix switches with "--".
|
|
370
424
|
*
|
|
371
|
-
* @param {...(string|!Array<string>)}
|
|
425
|
+
* @param {...(string|!Array<string>)} args The switches to exclude.
|
|
372
426
|
* @return {!Options} A self reference.
|
|
373
427
|
*/
|
|
374
|
-
excludeSwitches(
|
|
375
|
-
let switches = this.options_.excludeSwitches || [];
|
|
376
|
-
switches = switches.concat.apply(switches, arguments);
|
|
428
|
+
excludeSwitches(...args) {
|
|
429
|
+
let switches = (this.options_.excludeSwitches || []).concat(...args);
|
|
377
430
|
if (switches.length) {
|
|
378
431
|
this.options_.excludeSwitches = switches;
|
|
379
432
|
}
|
|
@@ -384,13 +437,12 @@ class Options {
|
|
|
384
437
|
* Add additional extensions to install when launching Chrome. Each extension
|
|
385
438
|
* should be specified as the path to the packed CRX file, or a Buffer for an
|
|
386
439
|
* extension.
|
|
387
|
-
* @param {...(string|!Buffer|!Array<(string|!Buffer)>)}
|
|
440
|
+
* @param {...(string|!Buffer|!Array<(string|!Buffer)>)} args The
|
|
388
441
|
* extensions to add.
|
|
389
442
|
* @return {!Options} A self reference.
|
|
390
443
|
*/
|
|
391
|
-
addExtensions(
|
|
392
|
-
this.extensions_ =
|
|
393
|
-
this.extensions_.concat.apply(this.extensions_, arguments);
|
|
444
|
+
addExtensions(...args) {
|
|
445
|
+
this.extensions_ = this.extensions_.concat(...args);
|
|
394
446
|
return this;
|
|
395
447
|
}
|
|
396
448
|
|
|
@@ -706,7 +758,7 @@ class Driver extends webdriver.WebDriver {
|
|
|
706
758
|
(opt_config || Capabilities.chrome());
|
|
707
759
|
|
|
708
760
|
return /** @type {!Driver} */(
|
|
709
|
-
|
|
761
|
+
super.createSession(executor, caps, opt_flow));
|
|
710
762
|
}
|
|
711
763
|
|
|
712
764
|
/**
|
|
@@ -727,6 +779,43 @@ class Driver extends webdriver.WebDriver {
|
|
|
727
779
|
new command.Command(Command.LAUNCH_APP).setParameter('id', id),
|
|
728
780
|
'Driver.launchApp()');
|
|
729
781
|
}
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* Schedules a command to get Chrome network emulation settings.
|
|
785
|
+
* @return {!promise.Thenable<T>} A promise that will be resolved
|
|
786
|
+
* when network emulation settings are retrievied.
|
|
787
|
+
*/
|
|
788
|
+
getNetworkConditions() {
|
|
789
|
+
return this.schedule(
|
|
790
|
+
new command.Command(Command.GET_NETWORK_CONDITIONS),
|
|
791
|
+
'Driver.getNetworkConditions()');
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* Schedules a command to set Chrome network emulation settings.
|
|
796
|
+
*
|
|
797
|
+
* __Sample Usage:__
|
|
798
|
+
*
|
|
799
|
+
* driver.setNetworkConditions({
|
|
800
|
+
* offline: false,
|
|
801
|
+
* latency: 5, // Additional latency (ms).
|
|
802
|
+
* download_throughput: 500 * 1024, // Maximal aggregated download throughput.
|
|
803
|
+
* upload_throughput: 500 * 1024 // Maximal aggregated upload throughput.
|
|
804
|
+
* });
|
|
805
|
+
*
|
|
806
|
+
* @param {Object} spec Defines the network conditions to set
|
|
807
|
+
* @return {!promise.Thenable<void>} A promise that will be resolved
|
|
808
|
+
* when network emulation settings are set.
|
|
809
|
+
*/
|
|
810
|
+
setNetworkConditions(spec) {
|
|
811
|
+
if (!spec || typeof spec !== 'object') {
|
|
812
|
+
throw TypeError('setNetworkConditions called with non-network-conditions parameter');
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
return this.schedule(
|
|
816
|
+
new command.Command(Command.SET_NETWORK_CONDITIONS).setParameter('network_conditions', spec),
|
|
817
|
+
'Driver.setNetworkConditions(' + JSON.stringify(spec) + ')');
|
|
818
|
+
}
|
|
730
819
|
}
|
|
731
820
|
|
|
732
821
|
|
package/edge.js
CHANGED
|
@@ -278,8 +278,8 @@ class Driver extends webdriver.WebDriver {
|
|
|
278
278
|
opt_config instanceof Options ? opt_config.toCapabilities() :
|
|
279
279
|
(opt_config || capabilities.Capabilities.edge());
|
|
280
280
|
|
|
281
|
-
return /** @type {!Driver} */(
|
|
282
|
-
executor, caps, opt_flow,
|
|
281
|
+
return /** @type {!Driver} */(super.createSession(
|
|
282
|
+
executor, caps, opt_flow, () => service.kill()));
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
/**
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
/**
|
|
19
|
+
* @fileoverview Example Mocha tests using async/await.
|
|
20
|
+
*
|
|
21
|
+
* Usage:
|
|
22
|
+
*
|
|
23
|
+
* mocha -t 20000 --harmony_async_await \
|
|
24
|
+
* selenium-webdriver/example/async_await_test.js
|
|
25
|
+
*
|
|
26
|
+
* You can change which browser is started with the SELENIUM_BROWSER environment
|
|
27
|
+
* variable:
|
|
28
|
+
*
|
|
29
|
+
* SELENIUM_BROWSER=chrome \
|
|
30
|
+
* mocha -t 20000 --harmony_async_await \
|
|
31
|
+
* selenium-webdriver/example/async_await_test.js
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
'use strict';
|
|
35
|
+
|
|
36
|
+
const assert = require('assert');
|
|
37
|
+
const {Builder, By, Key, promise, until} = require('..');
|
|
38
|
+
|
|
39
|
+
// async/await do not work well when the promise manager is enabled.
|
|
40
|
+
// See https://github.com/SeleniumHQ/selenium/issues/3037
|
|
41
|
+
//
|
|
42
|
+
// 3037 does not impact these specific examples, but it is still recommended
|
|
43
|
+
// that you disable the promise manager when using async/await.
|
|
44
|
+
promise.USE_PROMISE_MANAGER = false;
|
|
45
|
+
|
|
46
|
+
describe('Google Search', function() {
|
|
47
|
+
let driver;
|
|
48
|
+
|
|
49
|
+
beforeEach(async function() {
|
|
50
|
+
driver = await new Builder().forBrowser('firefox').build();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
afterEach(async function() {
|
|
54
|
+
await driver.quit();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('example', async function() {
|
|
58
|
+
await driver.get('https://www.google.com/ncr');
|
|
59
|
+
|
|
60
|
+
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
|
|
61
|
+
|
|
62
|
+
await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
|
|
63
|
+
|
|
64
|
+
let url = await driver.getCurrentUrl();
|
|
65
|
+
assert.ok(
|
|
66
|
+
url.startsWith('https://www.google.com/search'),
|
|
67
|
+
'unexpected url: ' + url);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
'use strict';
|
|
25
25
|
|
|
26
|
-
const {Builder, By, promise, until} = require('..');
|
|
26
|
+
const {Builder, By, Key, promise, until} = require('..');
|
|
27
27
|
const {Options} = require('../chrome');
|
|
28
28
|
|
|
29
29
|
promise.consume(function* () {
|
|
@@ -34,8 +34,7 @@ promise.consume(function* () {
|
|
|
34
34
|
.setChromeOptions(new Options().androidChrome())
|
|
35
35
|
.build();
|
|
36
36
|
yield driver.get('http://www.google.com/ncr');
|
|
37
|
-
yield driver.findElement(By.name('q')).sendKeys('webdriver');
|
|
38
|
-
yield driver.findElement(By.name('btnG')).click();
|
|
37
|
+
yield driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
|
|
39
38
|
yield driver.wait(until.titleIs('webdriver - Google Search'), 1000);
|
|
40
39
|
} finally {
|
|
41
40
|
yield driver && driver.quit();
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
'use strict';
|
|
24
24
|
|
|
25
|
-
const {Builder, By, promise, until} = require('..');
|
|
25
|
+
const {Builder, By, Key, promise, until} = require('..');
|
|
26
26
|
const {Options} = require('../chrome');
|
|
27
27
|
|
|
28
28
|
promise.consume(function* () {
|
|
@@ -31,11 +31,10 @@ promise.consume(function* () {
|
|
|
31
31
|
driver = yield new Builder()
|
|
32
32
|
.forBrowser('chrome')
|
|
33
33
|
.setChromeOptions(
|
|
34
|
-
new Options().setMobileEmulation({deviceName: '
|
|
34
|
+
new Options().setMobileEmulation({deviceName: 'Nexus 5X'}))
|
|
35
35
|
.build();
|
|
36
36
|
yield driver.get('http://www.google.com/ncr');
|
|
37
|
-
yield driver.findElement(By.name('q')).sendKeys('webdriver');
|
|
38
|
-
yield driver.findElement(By.name('btnG')).click();
|
|
37
|
+
yield driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
|
|
39
38
|
yield driver.wait(until.titleIs('webdriver - Google Search'), 1000);
|
|
40
39
|
} finally {
|
|
41
40
|
yield driver && driver.quit();
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
'use strict';
|
|
29
29
|
|
|
30
|
-
const {Builder, By, promise, until} = require('..');
|
|
30
|
+
const {Builder, By, Key, promise, until} = require('..');
|
|
31
31
|
const {Channel, Options} = require('../firefox');
|
|
32
32
|
|
|
33
33
|
let i = 0;
|
|
@@ -45,8 +45,8 @@ function doSearch(driver) {
|
|
|
45
45
|
.then(_ => promise.delayed(750))
|
|
46
46
|
// Now do the rest.
|
|
47
47
|
.then(_ => driver.get('http://www.google.com/ncr'))
|
|
48
|
-
.then(_ =>
|
|
49
|
-
|
|
48
|
+
.then(_ =>
|
|
49
|
+
driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN))
|
|
50
50
|
.then(_ => driver.wait(until.titleIs('webdriver - Google Search'), 1000))
|
|
51
51
|
.then(_ => driver.quit());
|
|
52
52
|
}
|
package/example/google_search.js
CHANGED
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
* node selenium-webdriver/example/google_search.js
|
|
38
38
|
*/
|
|
39
39
|
|
|
40
|
-
const {Builder, By, until} = require('..');
|
|
40
|
+
const {Builder, By, Key, until} = require('..');
|
|
41
41
|
|
|
42
42
|
var driver = new Builder()
|
|
43
43
|
.forBrowser('firefox')
|
|
44
44
|
.build();
|
|
45
45
|
|
|
46
46
|
driver.get('http://www.google.com/ncr')
|
|
47
|
-
.then(_ =>
|
|
48
|
-
|
|
47
|
+
.then(_ =>
|
|
48
|
+
driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN))
|
|
49
49
|
.then(_ => driver.wait(until.titleIs('webdriver - Google Search'), 1000))
|
|
50
50
|
.then(_ => driver.quit());
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
'use strict';
|
|
30
30
|
|
|
31
|
-
const {Builder, By, promise, until} = require('..');
|
|
31
|
+
const {Builder, By, Key, promise, until} = require('..');
|
|
32
32
|
|
|
33
33
|
promise.consume(function* () {
|
|
34
34
|
let driver;
|
|
@@ -38,10 +38,7 @@ promise.consume(function* () {
|
|
|
38
38
|
yield driver.get('http://www.google.com/ncr');
|
|
39
39
|
|
|
40
40
|
let q = yield driver.findElement(By.name('q'));
|
|
41
|
-
yield q.sendKeys('webdriver');
|
|
42
|
-
|
|
43
|
-
let btnG = yield driver.findElement(By.name('btnG'));
|
|
44
|
-
yield btnG.click();
|
|
41
|
+
yield q.sendKeys('webdriver', Key.RETURN);
|
|
45
42
|
|
|
46
43
|
yield driver.wait(until.titleIs('webdriver - Google Search'), 1000);
|
|
47
44
|
} finally {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* mocha -t 10000 selenium-webdriver/example/google_search_test.js
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
|
-
const {Builder, By, until} = require('..');
|
|
32
|
+
const {Builder, By, Key, until} = require('..');
|
|
33
33
|
const test = require('../testing');
|
|
34
34
|
|
|
35
35
|
test.describe('Google Search', function() {
|
|
@@ -41,9 +41,9 @@ test.describe('Google Search', function() {
|
|
|
41
41
|
|
|
42
42
|
// You can write tests either using traditional promises.
|
|
43
43
|
it('works with promises', function() {
|
|
44
|
-
return driver.get('http://www.google.com')
|
|
45
|
-
.then(_ =>
|
|
46
|
-
|
|
44
|
+
return driver.get('http://www.google.com/ncr')
|
|
45
|
+
.then(_ =>
|
|
46
|
+
driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN))
|
|
47
47
|
.then(_ => driver.wait(until.titleIs('webdriver - Google Search'), 1000));
|
|
48
48
|
});
|
|
49
49
|
|
|
@@ -52,8 +52,7 @@ test.describe('Google Search', function() {
|
|
|
52
52
|
// generator.
|
|
53
53
|
test.it('works with generators', function*() {
|
|
54
54
|
yield driver.get('http://www.google.com/ncr');
|
|
55
|
-
yield driver.findElement(By.name('q')).sendKeys('webdriver');
|
|
56
|
-
yield driver.findElement(By.name('btnG')).click();
|
|
55
|
+
yield driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
|
|
57
56
|
yield driver.wait(until.titleIs('webdriver - Google Search'), 1000);
|
|
58
57
|
});
|
|
59
58
|
|