selenium-webdriver 4.0.0-alpha.5 → 4.0.0-beta.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 (49) hide show
  1. package/CHANGES.md +35 -1
  2. package/LICENSE +1 -1
  3. package/NOTICE +1 -1
  4. package/README.md +4 -4
  5. package/chrome.js +72 -592
  6. package/chromium.js +829 -0
  7. package/devtools/CDPConnection.js +37 -0
  8. package/edge.js +124 -86
  9. package/example/chrome_android.js +16 -13
  10. package/example/chrome_mobile_emulation.js +18 -14
  11. package/example/firefox_channels.js +35 -28
  12. package/example/google_search.js +9 -9
  13. package/example/google_search_test.js +20 -22
  14. package/example/headless.js +27 -19
  15. package/example/logging.js +34 -38
  16. package/firefox.js +200 -200
  17. package/http/index.js +131 -115
  18. package/http/util.js +56 -64
  19. package/ie.js +180 -104
  20. package/index.js +246 -199
  21. package/io/exec.js +34 -39
  22. package/io/index.js +142 -152
  23. package/io/zip.js +75 -65
  24. package/lib/actions.js +140 -122
  25. package/lib/atoms/find-elements.js +124 -0
  26. package/lib/atoms/get-attribute.js +79 -59
  27. package/lib/atoms/is-displayed.js +72 -73
  28. package/lib/atoms/mutation-listener.js +38 -0
  29. package/lib/by.js +192 -65
  30. package/lib/capabilities.js +82 -78
  31. package/lib/command.js +20 -20
  32. package/lib/error.js +134 -168
  33. package/lib/http.js +337 -230
  34. package/lib/input.js +325 -302
  35. package/lib/logging.js +127 -138
  36. package/lib/promise.js +60 -66
  37. package/lib/proxy.js +31 -41
  38. package/lib/session.js +12 -15
  39. package/lib/symbols.js +3 -4
  40. package/lib/until.js +162 -160
  41. package/lib/webdriver.js +1024 -541
  42. package/net/index.js +30 -36
  43. package/net/portprober.js +31 -144
  44. package/opera.js +406 -0
  45. package/package.json +19 -12
  46. package/proxy.js +2 -2
  47. package/remote/index.js +190 -187
  48. package/safari.js +40 -49
  49. package/testing/index.js +166 -155
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Licensed to the Software Freedom Conservancy (SFC) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The SFC licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+
20
+ class CDPConnection {
21
+ constructor(wsConnection) {
22
+ this._wsConnection = wsConnection
23
+ }
24
+
25
+ execute(method, id, params, callback) {
26
+ const message = {
27
+ method,
28
+ id: id,
29
+ }
30
+
31
+ const mergedMessage = Object.assign({ params: params }, message)
32
+
33
+ this._wsConnection.send(JSON.stringify(mergedMessage), callback)
34
+ }
35
+ }
36
+
37
+ exports.CdpConnection = CDPConnection
package/edge.js CHANGED
@@ -17,26 +17,37 @@
17
17
 
18
18
  /**
19
19
  * @fileoverview Defines a {@linkplain Driver WebDriver} client for
20
- * Microsoft's Edge web browser. Before using this module,
21
- * you must download and install the latest
22
- * [MicrosoftEdgeDriver](http://go.microsoft.com/fwlink/?LinkId=619687) server.
23
- * Ensure that the MicrosoftEdgeDriver is on your
24
- * [PATH](http://en.wikipedia.org/wiki/PATH_%28variable%29).
20
+ * Microsoft's Edge web browser. Both Edge (Chromium), and Edge Legacy (EdgeHTML) are
21
+ * supported. Before using this module, you must download and install the correct
22
+ * [WebDriver](https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/)
23
+ * server.
24
+ *
25
+ * Ensure that the either MicrosoftWebDriver (EdgeHTML) or msedgedriver (Chromium)
26
+ * is on your [PATH](http://en.wikipedia.org/wiki/PATH_%28variable%29). MicrosoftWebDriver
27
+ * and Edge Legacy (EdgeHTML) will be used by default.
28
+ *
29
+ * You may use {@link Options} to specify whether Edge Chromium should be used:
30
+
31
+ * var options = new edge.Options();
32
+ * options.useEdgeChromium(true);
33
+ * // configure browser options ...
34
+
35
+ * Note that Chromium-specific {@link Options} will be ignored when using Edge Legacy.
25
36
  *
26
37
  * There are three primary classes exported by this module:
27
38
  *
28
39
  * 1. {@linkplain ServiceBuilder}: configures the
29
40
  * {@link ./remote.DriverService remote.DriverService}
30
- * that manages the [MicrosoftEdgeDriver] child process.
41
+ * that manages the [WebDriver] child process.
31
42
  *
32
43
  * 2. {@linkplain Options}: defines configuration options for each new
33
- * MicrosoftEdgeDriver session, such as which
44
+ * WebDriver session, such as which
34
45
  * {@linkplain Options#setProxy proxy} to use when starting the browser.
35
46
  *
36
47
  * 3. {@linkplain Driver}: the WebDriver client; each new instance will control
37
48
  * a unique browser session.
38
49
  *
39
- * __Customizing the MicrosoftEdgeDriver Server__ <a id="custom-server"></a>
50
+ * __Customizing the WebDriver Server__ <a id="custom-server"></a>
40
51
  *
41
52
  * By default, every MicrosoftEdge session will use a single driver service,
42
53
  * which is started the first time a {@link Driver} instance is created and
@@ -65,99 +76,120 @@
65
76
  * operation, users should start MicrosoftEdge using the
66
77
  * {@link ./builder.Builder selenium-webdriver.Builder}.
67
78
  *
68
- * [MicrosoftEdgeDriver]: https://msdn.microsoft.com/en-us/library/mt188085(v=vs.85).aspx
79
+ * [WebDriver (EdgeHTML)]: https://docs.microsoft.com/en-us/microsoft-edge/webdriver
80
+ * [WebDriver (Chromium)]: https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium
69
81
  */
70
82
 
71
- 'use strict';
72
-
73
- const fs = require('fs');
74
- const util = require('util');
83
+ 'use strict'
75
84
 
76
- const http = require('./http');
77
- const io = require('./io');
78
- const portprober = require('./net/portprober');
79
- const promise = require('./lib/promise');
80
- const remote = require('./remote');
81
- const Symbols = require('./lib/symbols');
82
- const webdriver = require('./lib/webdriver');
83
- const {Browser, Capabilities} = require('./lib/capabilities');
84
-
85
- const EDGEDRIVER_EXE = 'MicrosoftWebDriver.exe';
85
+ const http = require('./http')
86
+ const io = require('./io')
87
+ const webdriver = require('./lib/webdriver')
88
+ const { Browser, Capabilities } = require('./lib/capabilities')
89
+ const chromium = require('./chromium')
86
90
 
91
+ const EDGE_CHROMIUM_BROWSER_NAME = 'msedge'
92
+ const EDGEDRIVER_LEGACY_EXE = 'MicrosoftWebDriver.exe'
93
+ const EDGEDRIVER_CHROMIUM_EXE =
94
+ process.platform === 'win32' ? 'msedgedriver.exe' : 'msedgedriver'
87
95
 
88
96
  /**
89
- * _Synchronously_ attempts to locate the edge driver executable on the current
90
- * system.
97
+ * _Synchronously_ attempts to locate the Edge driver executable
98
+ * on the current system. Searches for the legacy MicrosoftWebDriver by default.
91
99
  *
100
+ * @param {string=} browserName Name of the Edge driver executable to locate.
101
+ * May be either 'msedge' to locate the Edge Chromium driver, or 'MicrosoftEdge' to
102
+ * locate the Edge Legacy driver. If omitted, will attempt to locate Edge Legacy.
92
103
  * @return {?string} the located executable, or `null`.
93
104
  */
94
- function locateSynchronously() {
105
+ function locateSynchronously(browserName) {
106
+ browserName = browserName || Browser.EDGE
107
+
108
+ if (browserName === EDGE_CHROMIUM_BROWSER_NAME) {
109
+ return io.findInPath(EDGEDRIVER_CHROMIUM_EXE, true)
110
+ }
111
+
95
112
  return process.platform === 'win32'
96
- ? io.findInPath(EDGEDRIVER_EXE, true) : null;
113
+ ? io.findInPath(EDGEDRIVER_LEGACY_EXE, true)
114
+ : null
97
115
  }
98
116
 
99
-
100
117
  /**
101
- * Class for managing MicrosoftEdgeDriver specific options.
118
+ * Class for managing Edge specific options.
102
119
  */
103
- class Options extends Capabilities {
120
+ class Options extends chromium.Options {
104
121
  /**
105
- * @param {(Capabilities|Map<string, ?>|Object)=} other Another set of
106
- * capabilities to initialize this instance from.
122
+ * Instruct the EdgeDriver to use Edge Chromium if true.
123
+ * Otherwise, use Edge Legacy (EdgeHTML). Defaults to using Edge Legacy.
124
+ *
125
+ * @param {boolean} useEdgeChromium
126
+ * @return {!Options} A self reference.
107
127
  */
108
- constructor(other = undefined) {
109
- super(other);
110
- this.setBrowserName(Browser.EDGE);
128
+ setEdgeChromium(useEdgeChromium) {
129
+ this.set(Options.USE_EDGE_CHROMIUM, !!useEdgeChromium)
130
+ return this
111
131
  }
112
132
  }
113
133
 
134
+ Options.USE_EDGE_CHROMIUM = 'ms:edgeChromium'
135
+ Options.prototype.BROWSER_NAME_VALUE = Browser.EDGE
136
+ Options.prototype.CAPABILITY_KEY = 'ms:edgeOptions'
137
+ Options.prototype.VENDOR_CAPABILITY_PREFIX = 'ms'
138
+
139
+ /**
140
+ * @param {(Capabilities|Object<string, *>)=} o The options object
141
+ * @return {boolean}
142
+ */
143
+ function useEdgeChromium(o) {
144
+ if (o instanceof Capabilities) {
145
+ return !!o.get(Options.USE_EDGE_CHROMIUM)
146
+ }
147
+
148
+ if (o && typeof o === 'object') {
149
+ return !!o[Options.USE_EDGE_CHROMIUM]
150
+ }
151
+
152
+ return false
153
+ }
114
154
 
115
155
  /**
116
156
  * Creates {@link remote.DriverService} instances that manage a
117
- * MicrosoftEdgeDriver server in a child process.
157
+ * WebDriver server in a child process. Used for driving both
158
+ * Microsoft Edge Legacy and Chromium. A ServiceBuilder constructed
159
+ * with default parameters will launch a MicrosoftWebDriver child
160
+ * process for driving Edge Legacy. You may pass in a path to
161
+ * msedgedriver.exe to use Edge Chromium instead.
118
162
  */
119
- class ServiceBuilder extends remote.DriverService.Builder {
163
+ class ServiceBuilder extends chromium.ServiceBuilder {
120
164
  /**
121
165
  * @param {string=} opt_exe Path to the server executable to use. If omitted,
122
- * the builder will attempt to locate the MicrosoftEdgeDriver on the current
166
+ * the builder will attempt to locate MicrosoftWebDriver on the current
123
167
  * PATH.
124
168
  * @throws {Error} If provided executable does not exist, or the
125
- * MicrosoftEdgeDriver cannot be found on the PATH.
169
+ * MicrosoftWebDriver cannot be found on the PATH.
126
170
  */
127
171
  constructor(opt_exe) {
128
- let exe = opt_exe || locateSynchronously();
172
+ const exe = opt_exe || locateSynchronously()
129
173
  if (!exe) {
130
174
  throw Error(
131
- 'The ' + EDGEDRIVER_EXE + ' could not be found on the current PATH. ' +
132
- 'Please download the latest version of the MicrosoftEdgeDriver from ' +
133
- 'https://www.microsoft.com/en-us/download/details.aspx?id=48212 and ' +
134
- 'ensure it can be found on your PATH.');
175
+ 'The WebDriver for Edge could not be found on the current PATH. Please ' +
176
+ 'download the latest version of ' +
177
+ EDGEDRIVER_LEGACY_EXE +
178
+ ' from ' +
179
+ 'https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ and ' +
180
+ 'ensure it can be found on your PATH.'
181
+ )
135
182
  }
136
183
 
137
- super(exe);
138
-
139
- // Binding to the loopback address will fail if not running with
140
- // administrator privileges. Since we cannot test for that in script
141
- // (or can we?), force the DriverService to use "localhost".
142
- this.setHostname('localhost');
143
- }
144
-
145
- /**
146
- * Enables verbose logging.
147
- * @return {!ServiceBuilder} A self reference.
148
- */
149
- enableVerboseLogging() {
150
- return this.addArguments('--verbose');
184
+ super(exe)
151
185
  }
152
186
  }
153
187
 
154
-
155
188
  /** @type {remote.DriverService} */
156
- var defaultService = null;
157
-
189
+ var defaultService = null
158
190
 
159
191
  /**
160
- * Sets the default service to use for new MicrosoftEdgeDriver instances.
192
+ * Sets the default service to use for new Edge instances.
161
193
  * @param {!remote.DriverService} service The service to use.
162
194
  * @throws {Error} If the default service is currently running.
163
195
  */
@@ -165,25 +197,32 @@ function setDefaultService(service) {
165
197
  if (defaultService && defaultService.isRunning()) {
166
198
  throw Error(
167
199
  'The previously configured EdgeDriver service is still running. ' +
168
- 'You must shut it down before you may adjust its configuration.');
200
+ 'You must shut it down before you may adjust its configuration.'
201
+ )
169
202
  }
170
- defaultService = service;
203
+ defaultService = service
171
204
  }
172
205
 
173
-
174
206
  /**
175
- * Returns the default MicrosoftEdgeDriver service. If such a service has
207
+ * Returns the default Microsoft Edge driver service. If such a service has
176
208
  * not been configured, one will be constructed using the default configuration
177
- * for an MicrosoftEdgeDriver executable found on the system PATH.
178
- * @return {!remote.DriverService} The default MicrosoftEdgeDriver service.
209
+ * for a MicrosoftWebDriver executable found on the system PATH.
210
+ * @return {!remote.DriverService} The default Microsoft Edge driver service.
179
211
  */
180
212
  function getDefaultService() {
181
213
  if (!defaultService) {
182
- defaultService = new ServiceBuilder().build();
214
+ defaultService = new ServiceBuilder().build()
183
215
  }
184
- return defaultService;
216
+ return defaultService
185
217
  }
186
218
 
219
+ function createServiceFromCapabilities(options) {
220
+ let exe
221
+ if (useEdgeChromium(options)) {
222
+ exe = locateSynchronously(EDGE_CHROMIUM_BROWSER_NAME)
223
+ }
224
+ return new ServiceBuilder(exe).build()
225
+ }
187
226
 
188
227
  /**
189
228
  * Creates a new WebDriver client for Microsoft's Edge.
@@ -193,18 +232,19 @@ class Driver extends webdriver.WebDriver {
193
232
  * Creates a new browser session for Microsoft's Edge browser.
194
233
  *
195
234
  * @param {(Capabilities|Options)=} options The configuration options.
196
- * @param {remote.DriverService=} service The session to use; will use
197
- * the {@linkplain #getDefaultService default service} by default.
235
+ * @param {remote.DriverService=} opt_service The service to use; will create
236
+ * a new Legacy or Chromium service based on {@linkplain Options} by default.
198
237
  * @return {!Driver} A new driver instance.
199
238
  */
200
239
  static createSession(options, opt_service) {
201
- let service = opt_service || getDefaultService();
202
- let client = service.start().then(url => new http.HttpClient(url));
203
- let executor = new http.Executor(client);
240
+ options = options || new Options()
241
+ let service = opt_service || createServiceFromCapabilities(options)
242
+ let client = service.start().then((url) => new http.HttpClient(url))
243
+ let executor = new http.Executor(client)
204
244
 
205
- options = options || new Options();
206
- return /** @type {!Driver} */(super.createSession(
207
- executor, options, () => service.kill()));
245
+ return /** @type {!Driver} */ (super.createSession(executor, options, () =>
246
+ service.kill()
247
+ ))
208
248
  }
209
249
 
210
250
  /**
@@ -215,13 +255,11 @@ class Driver extends webdriver.WebDriver {
215
255
  setFileDetector() {}
216
256
  }
217
257
 
218
-
219
258
  // PUBLIC API
220
259
 
221
-
222
- exports.Driver = Driver;
223
- exports.Options = Options;
224
- exports.ServiceBuilder = ServiceBuilder;
225
- exports.getDefaultService = getDefaultService;
226
- exports.setDefaultService = setDefaultService;
227
- exports.locateSynchronously = locateSynchronously;
260
+ exports.Driver = Driver
261
+ exports.Options = Options
262
+ exports.ServiceBuilder = ServiceBuilder
263
+ exports.getDefaultService = getDefaultService
264
+ exports.setDefaultService = setDefaultService
265
+ exports.locateSynchronously = locateSynchronously
@@ -21,22 +21,25 @@
21
21
  * AVD).
22
22
  */
23
23
 
24
- 'use strict';
24
+ 'use strict'
25
25
 
26
- const {Builder, By, Key, until} = require('..');
27
- const {Options} = require('../chrome');
26
+ const { Builder, By, Key, until } = require('..')
27
+ const { Options } = require('../chrome')
28
28
 
29
- (async function() {
30
- let driver;
29
+ ;(async function () {
30
+ let driver
31
31
  try {
32
32
  driver = await new Builder()
33
- .forBrowser('chrome')
34
- .setChromeOptions(new Options().androidChrome())
35
- .build();
36
- await driver.get('http://www.google.com/ncr');
37
- await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
38
- await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
33
+ .forBrowser('chrome')
34
+ .setChromeOptions(new Options().androidChrome())
35
+ .build()
36
+ await driver.get('http://www.google.com/ncr')
37
+ await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
38
+ await driver.wait(until.titleIs('webdriver - Google Search'), 1000)
39
39
  } finally {
40
- await driver && driver.quit();
40
+ ;(await driver) && driver.quit()
41
41
  }
42
- })().then(_ => console.log('SUCCESS'), err => console.error('ERROR: ' + err));
42
+ })().then(
43
+ (_) => console.log('SUCCESS'),
44
+ (err) => console.error('ERROR: ' + err)
45
+ )
@@ -20,23 +20,27 @@
20
20
  * ChromeDriver.
21
21
  */
22
22
 
23
- 'use strict';
23
+ 'use strict'
24
24
 
25
- const {Builder, By, Key, until} = require('..');
26
- const {Options} = require('../chrome');
25
+ const { Builder, By, Key, until } = require('..')
26
+ const { Options } = require('../chrome')
27
27
 
28
- (async function() {
29
- let driver;
28
+ ;(async function () {
29
+ let driver
30
30
  try {
31
31
  driver = await new Builder()
32
- .forBrowser('chrome')
33
- .setChromeOptions(
34
- new Options().setMobileEmulation({deviceName: 'Nexus 5X'}))
35
- .build();
36
- await driver.get('http://www.google.com/ncr');
37
- await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
38
- await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
32
+ .forBrowser('chrome')
33
+ .setChromeOptions(
34
+ new Options().setMobileEmulation({ deviceName: 'Nexus 5X' })
35
+ )
36
+ .build()
37
+ await driver.get('http://www.google.com/ncr')
38
+ await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
39
+ await driver.wait(until.titleIs('webdriver - Google Search'), 1000)
39
40
  } finally {
40
- await driver && driver.quit();
41
+ ;(await driver) && driver.quit()
41
42
  }
42
- })().then(_ => console.log('SUCCESS'), err => console.error('ERROR: ' + err));
43
+ })().then(
44
+ (_) => console.log('SUCCESS'),
45
+ (err) => console.error('ERROR: ' + err)
46
+ )
@@ -24,20 +24,22 @@
24
24
  * - https://www.mozilla.org/en-US/firefox/channel/desktop/#nightly
25
25
  */
26
26
 
27
+ 'use strict'
27
28
 
28
- 'use strict';
29
+ const { Builder, By, Key, promise, until } = require('..')
30
+ const { Channel, Options } = require('../firefox')
29
31
 
30
- const {Builder, By, Key, promise, until} = require('..');
31
- const {Channel, Options} = require('../firefox');
32
-
33
- let i = 0;
32
+ let i = 0
34
33
  function resposition(driver) {
35
- return driver.manage().window().setRect({
36
- width: 600,
37
- height: 400,
38
- x: 300 * (i++),
39
- y: 0
40
- });
34
+ return driver
35
+ .manage()
36
+ .window()
37
+ .setRect({
38
+ width: 600,
39
+ height: 400,
40
+ x: 300 * i++,
41
+ y: 0,
42
+ })
41
43
  }
42
44
 
43
45
  async function doSearch(driver) {
@@ -45,33 +47,38 @@ async function doSearch(driver) {
45
47
  // Start on the base about page.
46
48
  await driver.get('about:')
47
49
  // Reposition so users can see the three windows.
48
- await resposition(driver);
50
+ await resposition(driver)
49
51
  // Pause so users can see the magic.
50
- await promise.delayed(750);
52
+ await promise.delayed(750)
51
53
  // Now do the rest.
52
- await driver.get('http://www.google.com/ncr');
53
- await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
54
- await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
55
- console.log('Success!');
54
+ await driver.get('http://www.google.com/ncr')
55
+ await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
56
+ await driver.wait(until.titleIs('webdriver - Google Search'), 1000)
57
+ console.log('Success!')
56
58
  } catch (ex) {
57
- console.log('An error occured! ' + ex);
59
+ console.log('An error occured! ' + ex)
58
60
  } finally {
59
- await driver.quit();
61
+ await driver.quit()
60
62
  }
61
63
  }
62
64
 
63
65
  function createDriver(channel) {
64
- let options = new Options().setBinary(channel);
65
- return new Builder().forBrowser('firefox').setFirefoxOptions(options).build();
66
+ let options = new Options().setBinary(channel)
67
+ return new Builder().forBrowser('firefox').setFirefoxOptions(options).build()
66
68
  }
67
69
 
68
70
  Promise.all([
69
71
  doSearch(createDriver(Channel.RELEASE)),
70
- doSearch(createDriver(Channel.AURORA)), // Developer Edition.
72
+ doSearch(createDriver(Channel.AURORA)), // Developer Edition.
71
73
  doSearch(createDriver(Channel.NIGHTLY)),
72
- ]).then(_ => {
73
- console.log('All done!');
74
- }, err => {
75
- console.error('An error occured! ' + err);
76
- setTimeout(() => {throw err}, 0);
77
- });
74
+ ]).then(
75
+ (_) => {
76
+ console.log('All done!')
77
+ },
78
+ (err) => {
79
+ console.error('An error occured! ' + err)
80
+ setTimeout(() => {
81
+ throw err
82
+ }, 0)
83
+ }
84
+ )
@@ -37,14 +37,14 @@
37
37
  * node selenium-webdriver/example/google_search.js
38
38
  */
39
39
 
40
- const {Builder, By, Key, until} = require('..');
40
+ const { Builder, By, Key, until } = require('..')
41
41
 
42
- var driver = new Builder()
43
- .forBrowser('firefox')
44
- .build();
42
+ var driver = new Builder().forBrowser('firefox').build()
45
43
 
46
- driver.get('http://www.google.com/ncr')
47
- .then(_ =>
48
- driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN))
49
- .then(_ => driver.wait(until.titleIs('webdriver - Google Search'), 1000))
50
- .then(_ => driver.quit());
44
+ driver
45
+ .get('http://www.google.com/ncr')
46
+ .then((_) =>
47
+ driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
48
+ )
49
+ .then((_) => driver.wait(until.titleIs('webdriver - Google Search'), 1000))
50
+ .then((_) => driver.quit())
@@ -33,27 +33,25 @@
33
33
  * mocha -t 10000 selenium-webdriver/example/google_search_test.js
34
34
  */
35
35
 
36
- const assert = require('assert');
36
+ const { Browser, By, Key, until } = require('..')
37
+ const { ignore, suite } = require('../testing')
37
38
 
38
- const {Browser, By, Key, until} = require('..');
39
- const {ignore, suite} = require('../testing');
39
+ suite(function (env) {
40
+ describe('Google Search', function () {
41
+ let driver
40
42
 
41
- suite(function(env) {
42
- describe('Google Search', function() {
43
- let driver;
44
-
45
- before(async function() {
43
+ before(async function () {
46
44
  // env.builder() returns a Builder instance preconfigured for the
47
45
  // envrionment's target browser (you may still define browser specific
48
46
  // options if necessary (i.e. firefox.Options or chrome.Options)).
49
- driver = await env.builder().build();
50
- });
47
+ driver = await env.builder().build()
48
+ })
51
49
 
52
- it('demo', async function() {
53
- await driver.get('https://www.google.com/ncr');
54
- await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
55
- await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
56
- });
50
+ it('demo', async function () {
51
+ await driver.get('https://www.google.com/ncr')
52
+ await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
53
+ await driver.wait(until.titleIs('webdriver - Google Search'), 1000)
54
+ })
57
55
 
58
56
  // The ignore function returns wrappers around describe & it that will
59
57
  // suppress tests if the provided predicate returns true. You may provide
@@ -62,11 +60,11 @@ suite(function(env) {
62
60
  // specified browsers.
63
61
  //
64
62
  // This example is always configured to skip Chrome.
65
- ignore(env.browsers(Browser.CHROME)).it('demo 2', async function() {
66
- await driver.get('https://www.google.com/ncr');
67
- await driver.wait(until.urlIs('https://www.google.com/'), 1500);
68
- });
63
+ ignore(env.browsers(Browser.CHROME)).it('demo 2', async function () {
64
+ await driver.get('https://www.google.com/ncr')
65
+ await driver.wait(until.urlIs('https://www.google.com/'), 1500)
66
+ })
69
67
 
70
- after(() => driver && driver.quit());
71
- });
72
- });
68
+ after(() => driver && driver.quit())
69
+ })
70
+ })