selenium-webdriver 4.0.0-alpha.8 → 4.0.0-beta.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 (53) hide show
  1. package/CHANGES.md +41 -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/chromium.js +23 -202
  7. package/devtools/CDPConnection.js +16 -18
  8. package/edge.js +89 -130
  9. package/example/chrome_android.js +45 -0
  10. package/{lib/atoms/make-atoms-module.js → example/chrome_mobile_emulation.js} +26 -15
  11. package/example/firefox_channels.js +84 -0
  12. package/example/google_search.js +50 -0
  13. package/example/google_search_test.js +70 -0
  14. package/example/headless.js +63 -0
  15. package/example/logging.js +64 -0
  16. package/firefox.js +10 -9
  17. package/http/index.js +0 -0
  18. package/http/util.js +3 -3
  19. package/ie.js +0 -0
  20. package/index.js +2 -2
  21. package/io/exec.js +3 -3
  22. package/io/index.js +12 -13
  23. package/io/zip.js +5 -6
  24. package/lib/atoms/find-elements.js +78 -78
  25. package/lib/atoms/get-attribute.js +64 -68
  26. package/lib/atoms/is-displayed.js +27 -27
  27. package/lib/atoms/mutation-listener.js +55 -0
  28. package/lib/by.js +1 -1
  29. package/lib/capabilities.js +2 -3
  30. package/lib/command.js +2 -15
  31. package/lib/error.js +0 -0
  32. package/lib/http.js +17 -30
  33. package/lib/input.js +2 -286
  34. package/lib/logging.js +0 -0
  35. package/lib/promise.js +4 -16
  36. package/lib/proxy.js +0 -0
  37. package/lib/session.js +0 -0
  38. package/lib/symbols.js +0 -0
  39. package/lib/until.js +17 -15
  40. package/lib/webdriver.js +336 -16
  41. package/net/index.js +0 -0
  42. package/net/portprober.js +8 -8
  43. package/opera.js +0 -0
  44. package/package.json +13 -13
  45. package/proxy.js +0 -0
  46. package/remote/index.js +6 -7
  47. package/safari.js +0 -0
  48. package/testing/index.js +504 -0
  49. package/.eslintrc.js +0 -27
  50. package/.prettierrc +0 -4
  51. package/devtools/generator/protocol-dts-generator.js +0 -429
  52. package/lib/README +0 -5
  53. package/lib/actions.js +0 -626
@@ -0,0 +1,64 @@
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 Demonstrates how to use WebDriver's logging sysem.
20
+ */
21
+
22
+ 'use strict'
23
+
24
+ const chrome = require('../chrome')
25
+ const firefox = require('../firefox')
26
+ const edge = require('../edge')
27
+ const { Builder, By, Key, logging, until } = require('..')
28
+
29
+ logging.installConsoleHandler()
30
+ logging.getLogger('webdriver.http').setLevel(logging.Level.ALL)
31
+ ;(async function () {
32
+ let driver
33
+ try {
34
+ driver = await new Builder()
35
+ // Default to using Firefox. This can be overridden at runtime by
36
+ // setting the SELENIUM_BROWSER environment variable:
37
+ //
38
+ // SELENIUM_BROWSER=chrome node selenium-webdriver/example/logging.js
39
+ .forBrowser('firefox')
40
+ // Configure the service for each browser to enable verbose logging and
41
+ // to inherit the stdio settings from the current process. The builder
42
+ // will only start the service if needed for the selected browser.
43
+ .setChromeService(
44
+ new chrome.ServiceBuilder().enableVerboseLogging().setStdio('inherit')
45
+ )
46
+ .setEdgeService(
47
+ process.platform === 'win32'
48
+ ? new edge.ServiceBuilder().enableVerboseLogging().setStdio('inherit')
49
+ : null
50
+ )
51
+ .setFirefoxService(
52
+ new firefox.ServiceBuilder().enableVerboseLogging().setStdio('inherit')
53
+ )
54
+ .build()
55
+
56
+ await driver.get('http://www.google.com/ncr')
57
+ await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
58
+ await driver.wait(until.titleIs('webdriver - Google Search'), 1000)
59
+ } finally {
60
+ if (driver) {
61
+ await driver.quit()
62
+ }
63
+ }
64
+ })()
package/firefox.js CHANGED
@@ -124,6 +124,7 @@ const io = require('./io')
124
124
  const remote = require('./remote')
125
125
  const webdriver = require('./lib/webdriver')
126
126
  const zip = require('./io/zip')
127
+ const cdp = require('./devtools/CDPConnection')
127
128
  const { Browser, Capabilities } = require('./lib/capabilities')
128
129
  const { Zip } = require('./io/zip')
129
130
 
@@ -222,7 +223,7 @@ async function buildProfile(template, extensions) {
222
223
  dir = await io.tmpDir()
223
224
  if (template) {
224
225
  await io.copyDir(
225
- /** @type {string} */ (template),
226
+ /** @type {string} */(template),
226
227
  dir,
227
228
  /(parent\.lock|lock|\.parentlock)/
228
229
  )
@@ -432,11 +433,11 @@ function findGeckoDriver() {
432
433
  if (!exe) {
433
434
  throw Error(
434
435
  'The ' +
435
- GECKO_DRIVER_EXE +
436
- ' executable could not be found on the current ' +
437
- 'PATH. Please download the latest version from ' +
438
- 'https://github.com/mozilla/geckodriver/releases/ ' +
439
- 'and ensure it can be found on your PATH.'
436
+ GECKO_DRIVER_EXE +
437
+ ' executable could not be found on the current ' +
438
+ 'PATH. Please download the latest version from ' +
439
+ 'https://github.com/mozilla/geckodriver/releases/ ' +
440
+ 'and ensure it can be found on your PATH.'
440
441
  )
441
442
  }
442
443
  return exe
@@ -457,8 +458,8 @@ function findInProgramFiles(file) {
457
458
  return exists
458
459
  ? files[0]
459
460
  : io.exists(files[1]).then(function (exists) {
460
- return exists ? files[1] : null
461
- })
461
+ return exists ? files[1] : null
462
+ })
462
463
  })
463
464
  }
464
465
 
@@ -592,7 +593,7 @@ class Driver extends webdriver.WebDriver {
592
593
  * implementation.
593
594
  * @override
594
595
  */
595
- setFileDetector() {}
596
+ setFileDetector() { }
596
597
 
597
598
  /**
598
599
  * Get the context that is currently in effect.
package/http/index.js CHANGED
File without changes
package/http/util.js CHANGED
@@ -35,9 +35,9 @@ const Executor = require('./index').Executor,
35
35
  * a hash of the server status.
36
36
  */
37
37
  function getStatus(url) {
38
- var client = new HttpClient(url)
39
- var executor = new Executor(client)
40
- var command = new Command(CommandName.GET_SERVER_STATUS)
38
+ const client = new HttpClient(url)
39
+ const executor = new Executor(client)
40
+ const command = new Command(CommandName.GET_SERVER_STATUS)
41
41
  return executor.execute(command)
42
42
  }
43
43
 
package/ie.js CHANGED
File without changes
package/index.js CHANGED
@@ -598,9 +598,9 @@ class Builder {
598
598
  build() {
599
599
  // Create a copy for any changes we may need to make based on the current
600
600
  // environment.
601
- var capabilities = new Capabilities(this.capabilities_)
601
+ const capabilities = new Capabilities(this.capabilities_)
602
602
 
603
- var browser
603
+ let browser
604
604
  if (!this.ignoreEnv_ && process.env.SELENIUM_BROWSER) {
605
605
  this.log_.fine(`SELENIUM_BROWSER=${process.env.SELENIUM_BROWSER}`)
606
606
  browser = process.env.SELENIUM_BROWSER.split(/:/, 3)
package/io/exec.js CHANGED
@@ -121,9 +121,9 @@ class Command {
121
121
  * @return {!Command} The launched command.
122
122
  */
123
123
  module.exports = function exec(command, opt_options) {
124
- var options = opt_options || {}
124
+ const options = opt_options || {}
125
125
 
126
- var proc = childProcess.spawn(command, options.args || [], {
126
+ let proc = childProcess.spawn(command, options.args || [], {
127
127
  env: options.env || process.env,
128
128
  stdio: options.stdio || 'ignore',
129
129
  })
@@ -133,7 +133,7 @@ module.exports = function exec(command, opt_options) {
133
133
  proc.unref()
134
134
  process.once('exit', onProcessExit)
135
135
 
136
- let result = new Promise((resolve) => {
136
+ const result = new Promise((resolve) => {
137
137
  proc.once('exit', (code, signal) => {
138
138
  proc = null
139
139
  process.removeListener('exit', onProcessExit)
package/io/index.js CHANGED
@@ -17,10 +17,10 @@
17
17
 
18
18
  'use strict'
19
19
 
20
- var fs = require('fs'),
21
- path = require('path'),
22
- rimraf = require('rimraf'),
23
- tmp = require('tmp')
20
+ const fs = require('fs')
21
+ const path = require('path')
22
+ const rimraf = require('rimraf')
23
+ const tmp = require('tmp')
24
24
 
25
25
  /**
26
26
  * @param {!Function} fn .
@@ -204,13 +204,12 @@ exports.tmpDir = function () {
204
204
  */
205
205
  exports.tmpFile = function (opt_options) {
206
206
  return checkedCall((callback) => {
207
- // |tmp.file| checks arguments length to detect options rather than doing a
208
- // truthy check, so we must only pass options if there are some to pass.
209
- if (opt_options) {
210
- tmp.file(opt_options, callback)
211
- } else {
212
- tmp.file(callback)
213
- }
207
+ /** check fixed in v > 0.2.1 if
208
+ * (typeof options === 'function') {
209
+ * return [{}, options];
210
+ * }
211
+ */
212
+ tmp.file(opt_options, callback)
214
213
  })
215
214
  }
216
215
 
@@ -224,7 +223,7 @@ exports.tmpFile = function (opt_options) {
224
223
  * not be found.
225
224
  */
226
225
  exports.findInPath = function (file, opt_checkCwd) {
227
- let dirs = []
226
+ const dirs = []
228
227
  if (opt_checkCwd) {
229
228
  dirs.push(process.cwd())
230
229
  }
@@ -329,7 +328,7 @@ exports.mkdirp = function mkdirp(dir) {
329
328
  * will be relative to `rootPath`.
330
329
  */
331
330
  exports.walkDir = function (rootPath) {
332
- let seen = []
331
+ const seen = []
333
332
  return (function walk(dir) {
334
333
  return checkedCall((callback) => fs.readdir(dir, callback)).then((files) =>
335
334
  Promise.all(
package/io/zip.js CHANGED
@@ -180,8 +180,8 @@ function load(path) {
180
180
  */
181
181
  function unzip(src, dst) {
182
182
  return load(src).then((zip) => {
183
- let promisedDirs = new Map()
184
- let promises = []
183
+ const promisedDirs = new Map()
184
+ const promises = []
185
185
 
186
186
  zip.z_.forEach((relPath, file) => {
187
187
  let p
@@ -218,7 +218,6 @@ function unzip(src, dst) {
218
218
  }
219
219
 
220
220
  // PUBLIC API
221
-
222
- exports.Zip = Zip
223
- exports.load = load
224
- exports.unzip = unzip
221
+ module.exports.Zip = Zip
222
+ module.exports.load = load
223
+ module.exports.unzip = unzip