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

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 (52) hide show
  1. package/.eslintrc.js +27 -0
  2. package/.prettierrc +4 -0
  3. package/CHANGES.md +22 -1
  4. package/README.md +4 -4
  5. package/chrome.js +72 -590
  6. package/chromium.js +1024 -0
  7. package/devtools/CDPConnection.js +37 -0
  8. package/devtools/generator/protocol-dts-generator.js +429 -0
  9. package/edge.js +124 -86
  10. package/firefox.js +201 -202
  11. package/http/index.js +131 -115
  12. package/http/util.js +56 -64
  13. package/ie.js +180 -104
  14. package/index.js +246 -199
  15. package/io/exec.js +34 -39
  16. package/io/index.js +141 -151
  17. package/io/zip.js +75 -65
  18. package/lib/README +5 -0
  19. package/lib/actions.js +138 -121
  20. package/lib/atoms/find-elements.js +123 -0
  21. package/lib/atoms/get-attribute.js +79 -60
  22. package/lib/atoms/is-displayed.js +72 -73
  23. package/{example/chrome_mobile_emulation.js → lib/atoms/make-atoms-module.js} +16 -23
  24. package/lib/by.js +192 -65
  25. package/lib/capabilities.js +82 -78
  26. package/lib/command.js +18 -20
  27. package/lib/error.js +134 -168
  28. package/lib/http.js +324 -230
  29. package/lib/input.js +325 -302
  30. package/lib/logging.js +127 -138
  31. package/lib/promise.js +60 -66
  32. package/lib/proxy.js +31 -41
  33. package/lib/session.js +12 -15
  34. package/lib/symbols.js +3 -4
  35. package/lib/until.js +162 -162
  36. package/lib/webdriver.js +733 -522
  37. package/net/index.js +30 -36
  38. package/net/portprober.js +31 -144
  39. package/opera.js +406 -0
  40. package/package.json +18 -11
  41. package/proxy.js +2 -2
  42. package/remote/index.js +190 -187
  43. package/safari.js +40 -49
  44. package/LICENSE +0 -202
  45. package/NOTICE +0 -2
  46. package/example/chrome_android.js +0 -42
  47. package/example/firefox_channels.js +0 -77
  48. package/example/google_search.js +0 -50
  49. package/example/google_search_test.js +0 -72
  50. package/example/headless.js +0 -55
  51. package/example/logging.js +0 -68
  52. package/testing/index.js +0 -498
package/io/zip.js CHANGED
@@ -15,13 +15,13 @@
15
15
  // specific language governing permissions and limitations
16
16
  // under the License.
17
17
 
18
- 'use strict';
18
+ 'use strict'
19
19
 
20
- const jszip = require('jszip');
21
- const path = require('path');
20
+ const jszip = require('jszip')
21
+ const path = require('path')
22
22
 
23
- const io = require('./index');
24
- const {InvalidArgumentError} = require('../lib/error');
23
+ const io = require('./index')
24
+ const { InvalidArgumentError } = require('../lib/error')
25
25
 
26
26
  /**
27
27
  * Manages a zip archive.
@@ -29,10 +29,10 @@ const {InvalidArgumentError} = require('../lib/error');
29
29
  class Zip {
30
30
  constructor() {
31
31
  /** @private @const */
32
- this.z_ = new jszip;
32
+ this.z_ = new jszip()
33
33
 
34
34
  /** @private @const {!Set<!Promise<?>>} */
35
- this.pendingAdds_ = new Set;
35
+ this.pendingAdds_ = new Set()
36
36
  }
37
37
 
38
38
  /**
@@ -44,15 +44,22 @@ class Zip {
44
44
  * @return {!Promise<?>} a promise that will resolve when added.
45
45
  */
46
46
  addFile(filePath, zipPath = path.basename(filePath)) {
47
- let add = io.read(filePath)
48
- .then(buffer => this.z_.file(/** @type {string} */(zipPath.replace(/\\/g, '/')), buffer));
49
- this.pendingAdds_.add(add);
47
+ let add = io
48
+ .read(filePath)
49
+ .then((buffer) =>
50
+ this.z_.file(
51
+ /** @type {string} */ (zipPath.replace(/\\/g, '/')),
52
+ buffer
53
+ )
54
+ )
55
+ this.pendingAdds_.add(add)
50
56
  return add.then(
51
- () => this.pendingAdds_.delete(add),
52
- (e) => {
53
- this.pendingAdds_.delete(add);
54
- throw e;
55
- });
57
+ () => this.pendingAdds_.delete(add),
58
+ (e) => {
59
+ this.pendingAdds_.delete(add)
60
+ throw e
61
+ }
62
+ )
56
63
  }
57
64
 
58
65
  /**
@@ -65,26 +72,28 @@ class Zip {
65
72
  * the operation is complete.
66
73
  */
67
74
  addDir(dirPath, zipPath = '') {
68
- return io.walkDir(dirPath).then(entries => {
69
- let archive = this.z_;
75
+ return io.walkDir(dirPath).then((entries) => {
76
+ let archive = this.z_
70
77
  if (zipPath) {
71
- archive = archive.folder(zipPath);
78
+ archive = archive.folder(zipPath)
72
79
  }
73
80
 
74
- let files = [];
75
- entries.forEach(spec => {
81
+ let files = []
82
+ entries.forEach((spec) => {
76
83
  if (spec.dir) {
77
- archive.folder(spec.path);
84
+ archive.folder(spec.path)
78
85
  } else {
79
86
  files.push(
80
- this.addFile(
81
- path.join(dirPath, spec.path),
82
- path.join(zipPath, spec.path)));
87
+ this.addFile(
88
+ path.join(dirPath, spec.path),
89
+ path.join(zipPath, spec.path)
90
+ )
91
+ )
83
92
  }
84
- });
93
+ })
85
94
 
86
- return Promise.all(files);
87
- });
95
+ return Promise.all(files)
96
+ })
88
97
  }
89
98
 
90
99
  /**
@@ -93,7 +102,7 @@ class Zip {
93
102
  * path.
94
103
  */
95
104
  has(path) {
96
- return this.z_.file(path) !== null;
105
+ return this.z_.file(path) !== null
97
106
  }
98
107
 
99
108
  /**
@@ -107,19 +116,20 @@ class Zip {
107
116
  * contents as a buffer.
108
117
  */
109
118
  getFile(path) {
110
- let file = this.z_.file(path);
119
+ let file = this.z_.file(path)
111
120
  if (!file) {
112
121
  return Promise.reject(
113
- new InvalidArgumentError(`No such file in zip archive: ${path}`));
122
+ new InvalidArgumentError(`No such file in zip archive: ${path}`)
123
+ )
114
124
  }
115
125
 
116
126
  if (file.dir) {
117
127
  return Promise.reject(
118
- new InvalidArgumentError(
119
- `The requested file is a directory: ${path}`));
128
+ new InvalidArgumentError(`The requested file is a directory: ${path}`)
129
+ )
120
130
  }
121
131
 
122
- return Promise.resolve(file.async('nodebuffer'));
132
+ return Promise.resolve(file.async('nodebuffer'))
123
133
  }
124
134
 
125
135
  /**
@@ -135,15 +145,17 @@ class Zip {
135
145
  toBuffer(compression = 'STORE') {
136
146
  if (compression !== 'STORE' && compression !== 'DEFLATE') {
137
147
  return Promise.reject(
138
- new InvalidArgumentError(
139
- `compression must be one of {STORE, DEFLATE}, got ${compression}`));
148
+ new InvalidArgumentError(
149
+ `compression must be one of {STORE, DEFLATE}, got ${compression}`
150
+ )
151
+ )
140
152
  }
141
153
  return Promise.resolve(
142
- this.z_.generateAsync({compression, type: 'nodebuffer'}));
154
+ this.z_.generateAsync({ compression, type: 'nodebuffer' })
155
+ )
143
156
  }
144
157
  }
145
158
 
146
-
147
159
  /**
148
160
  * Asynchronously opens a zip archive.
149
161
  *
@@ -152,13 +164,12 @@ class Zip {
152
164
  * archive.
153
165
  */
154
166
  function load(path) {
155
- return io.read(path).then(data => {
156
- let zip = new Zip;
157
- return zip.z_.loadAsync(data).then(() => zip);
158
- });
167
+ return io.read(path).then((data) => {
168
+ let zip = new Zip()
169
+ return zip.z_.loadAsync(data).then(() => zip)
170
+ })
159
171
  }
160
172
 
161
-
162
173
  /**
163
174
  * Asynchronously unzips an archive file.
164
175
  *
@@ -168,47 +179,46 @@ function load(path) {
168
179
  * archive has been unzipped.
169
180
  */
170
181
  function unzip(src, dst) {
171
- return load(src).then(zip => {
172
- let promisedDirs = new Map;
173
- let promises = [];
182
+ return load(src).then((zip) => {
183
+ let promisedDirs = new Map()
184
+ let promises = []
174
185
 
175
186
  zip.z_.forEach((relPath, file) => {
176
- let p;
187
+ let p
177
188
  if (file.dir) {
178
- p = createDir(relPath);
189
+ p = createDir(relPath)
179
190
  } else {
180
- let dirname = path.dirname(relPath);
191
+ let dirname = path.dirname(relPath)
181
192
  if (dirname === '.') {
182
- p = writeFile(relPath, file);
193
+ p = writeFile(relPath, file)
183
194
  } else {
184
- p = createDir(dirname).then(() => writeFile(relPath, file));
195
+ p = createDir(dirname).then(() => writeFile(relPath, file))
185
196
  }
186
197
  }
187
- promises.push(p);
188
- });
198
+ promises.push(p)
199
+ })
189
200
 
190
- return Promise.all(promises).then(() => dst);
201
+ return Promise.all(promises).then(() => dst)
191
202
 
192
203
  function createDir(dir) {
193
- let p = promisedDirs.get(dir);
204
+ let p = promisedDirs.get(dir)
194
205
  if (!p) {
195
- p = io.mkdirp(path.join(dst, dir));
196
- promisedDirs.set(dir, p);
206
+ p = io.mkdirp(path.join(dst, dir))
207
+ promisedDirs.set(dir, p)
197
208
  }
198
- return p;
209
+ return p
199
210
  }
200
211
 
201
212
  function writeFile(relPath, file) {
202
- return file.async('nodebuffer')
203
- .then(buffer => io.write(path.join(dst, relPath), buffer));
213
+ return file
214
+ .async('nodebuffer')
215
+ .then((buffer) => io.write(path.join(dst, relPath), buffer))
204
216
  }
205
- });
217
+ })
206
218
  }
207
219
 
208
-
209
220
  // PUBLIC API
210
221
 
211
-
212
- exports.Zip = Zip;
213
- exports.load = load;
214
- exports.unzip = unzip;
222
+ exports.Zip = Zip
223
+ exports.load = load
224
+ exports.unzip = unzip
package/lib/README ADDED
@@ -0,0 +1,5 @@
1
+ This directory contains modules internal to selenium-webdriver that are not
2
+ intended for general consumption. They may change at any time.
3
+
4
+ All files in this directory and the atoms/ subdirectory may only depend on
5
+ built-in JavaScript features and other modules in this directory.