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
@@ -1,429 +0,0 @@
1
- 'use strict'
2
- var __spreadArrays =
3
- (this && this.__spreadArrays) ||
4
- function () {
5
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
6
- s += arguments[i].length
7
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
8
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
9
- r[k] = a[j]
10
- return r
11
- }
12
- exports.__esModule = true
13
- var fs = require('fs')
14
- var path = require('path')
15
- console.log(process.argv)
16
- // TODO: @noj validate this via https://github.com/andischerer/typescript-json-typesafe against protocol-schema.d.ts
17
- var jsProtocol = JSON.parse(fs.readFileSync(process.argv[3]))
18
- var browserProtocol = JSON.parse(fs.readFileSync(process.argv[2]))
19
- var protocolDomains = jsProtocol.domains.concat(browserProtocol.domains)
20
- var numIndents = 0
21
- var emitStr = ''
22
- var emit = function (str) {
23
- emitStr += str
24
- }
25
- var getIndent = function () {
26
- return ' '.repeat(numIndents)
27
- } // 4 spaced indents
28
- var emitIndent = function () {
29
- emitStr += getIndent()
30
- }
31
- var emitLine = function (str) {
32
- if (str) {
33
- emitIndent()
34
- emit(str + '\n')
35
- } else {
36
- emit('\n')
37
- }
38
- }
39
- var emitOpenBlock = function (str, openChar) {
40
- if (openChar === void 0) {
41
- openChar = ' {'
42
- }
43
- emitLine('' + str + openChar)
44
- numIndents++
45
- }
46
- var emitCloseBlock = function (closeChar) {
47
- if (closeChar === void 0) {
48
- closeChar = '}'
49
- }
50
- numIndents--
51
- emitLine(closeChar)
52
- }
53
- var emitHeaderComments = function () {
54
- emitLine(
55
- '/**********************************************************************'
56
- )
57
- emitLine(
58
- ' * Auto-generated by protocol-dts-generator.ts, do not edit manually. *'
59
- )
60
- emitLine(
61
- ' **********************************************************************/'
62
- )
63
- emitLine()
64
- }
65
- var fixCamelCase = function (name) {
66
- var prefix = ''
67
- var result = name
68
- if (name[0] === '-') {
69
- prefix = 'Negative'
70
- result = name.substring(1)
71
- }
72
- var refined = result.split('-').map(toTitleCase).join('')
73
- return (
74
- prefix +
75
- refined.replace(/HTML|XML|WML|API/i, function (match) {
76
- return match.toUpperCase()
77
- })
78
- )
79
- }
80
- var emitEnum = function (enumName, enumValues) {
81
- emitOpenBlock('export const enum ' + enumName)
82
- enumValues.forEach(function (value) {
83
- emitLine(fixCamelCase(value) + " = '" + value + "',")
84
- })
85
- emitCloseBlock()
86
- }
87
- var emitModule = function (moduleName, domains) {
88
- moduleName = toTitleCase(moduleName)
89
- emitHeaderComments()
90
- emitOpenBlock('export namespace ' + moduleName)
91
- emitGlobalTypeDefs()
92
- domains.forEach(emitDomain)
93
- emitCloseBlock()
94
- emitLine()
95
- emitLine('export default ' + moduleName + ';')
96
- }
97
- var emitGlobalTypeDefs = function () {
98
- emitLine()
99
- emitLine('export type integer = number')
100
- }
101
- var emitDomain = function (domain) {
102
- var domainName = toTitleCase(domain.domain)
103
- emitLine()
104
- emitDescription(domain.description)
105
- emitOpenBlock('export namespace ' + domainName)
106
- if (domain.types) domain.types.forEach(emitDomainType)
107
- if (domain.commands) domain.commands.forEach(emitCommand)
108
- if (domain.events) domain.events.forEach(emitEvent)
109
- emitCloseBlock()
110
- }
111
- var getCommentLines = function (description) {
112
- var lines = description.split(/\r?\n/g).map(function (line) {
113
- return ' * ' + line
114
- })
115
- return __spreadArrays(['/**'], lines, [' */'])
116
- }
117
- var emitDescription = function (description) {
118
- if (description)
119
- getCommentLines(description).map(function (l) {
120
- return emitLine(l)
121
- })
122
- }
123
- var isPropertyInlineEnum = function (prop) {
124
- if ('$ref' in prop) {
125
- return false
126
- }
127
- return (
128
- prop.type === 'string' &&
129
- prop['enum'] !== null &&
130
- prop['enum'] !== undefined
131
- )
132
- }
133
- var getPropertyDef = function (interfaceName, prop) {
134
- // Quote key if it has a . in it.
135
- var propName = prop.name.includes('.') ? "'" + prop.name + "'" : prop.name
136
- var type = getPropertyType(interfaceName, prop)
137
- return '' + propName + (prop.optional ? '?' : '') + ': ' + type
138
- }
139
- var getPropertyType = function (interfaceName, prop) {
140
- if ('$ref' in prop) return prop.$ref
141
- else if (prop.type === 'array')
142
- return getPropertyType(interfaceName, prop.items) + '[]'
143
- else if (prop.type === 'object')
144
- if (!prop.properties) {
145
- // TODO: actually 'any'? or can use generic '[key: string]: string'?
146
- return 'any'
147
- } else {
148
- // hack: access indent, \n directly
149
- var objStr = '{\n'
150
- numIndents++
151
- objStr += prop.properties
152
- .map(function (p) {
153
- return '' + getIndent() + getPropertyDef(interfaceName, p) + ';\n'
154
- })
155
- .join('')
156
- numIndents--
157
- objStr += getIndent() + '}'
158
- return objStr
159
- }
160
- else if (prop.type === 'string' && prop['enum'])
161
- return (
162
- '(' +
163
- prop['enum']
164
- .map(function (v) {
165
- return "'" + v + "'"
166
- })
167
- .join(' | ') +
168
- ')'
169
- )
170
- return prop.type
171
- }
172
- var emitProperty = function (interfaceName, prop) {
173
- var description = prop.description
174
- if (isPropertyInlineEnum(prop)) {
175
- var enumName = interfaceName + toTitleCase(prop.name)
176
- description = (description || '') + ' (' + enumName + ' enum)'
177
- }
178
- emitDescription(description)
179
- emitLine(getPropertyDef(interfaceName, prop) + ';')
180
- }
181
- var emitInlineEnumForDomainType = function (type) {
182
- if (type.type === 'object') {
183
- emitInlineEnums(type.id, type.properties)
184
- }
185
- }
186
- var emitInlineEnumsForCommands = function (command) {
187
- emitInlineEnums(toCmdRequestName(command.name), command.parameters)
188
- emitInlineEnums(toCmdResponseName(command.name), command.returns)
189
- }
190
- var emitInlineEnumsForEvents = function (event) {
191
- emitInlineEnums(toEventPayloadName(event.name), event.parameters)
192
- }
193
- var emitInlineEnums = function (prefix, propertyTypes) {
194
- if (!propertyTypes) {
195
- return
196
- }
197
- for (
198
- var _i = 0, propertyTypes_1 = propertyTypes;
199
- _i < propertyTypes_1.length;
200
- _i++
201
- ) {
202
- var type = propertyTypes_1[_i]
203
- if (isPropertyInlineEnum(type)) {
204
- emitLine()
205
- var enumName = prefix + toTitleCase(type.name)
206
- emitEnum(enumName, type['enum'] || [])
207
- }
208
- }
209
- }
210
- var emitInterface = function (interfaceName, props) {
211
- emitOpenBlock('export interface ' + interfaceName)
212
- props
213
- ? props.forEach(function (prop) {
214
- return emitProperty(interfaceName, prop)
215
- })
216
- : emitLine('[key: string]: string;')
217
- emitCloseBlock()
218
- }
219
- var emitDomainType = function (type) {
220
- emitInlineEnumForDomainType(type)
221
- emitLine()
222
- emitDescription(type.description)
223
- if (type.type === 'object') {
224
- emitInterface(type.id, type.properties)
225
- } else {
226
- emitLine(
227
- 'export type ' + type.id + ' = ' + getPropertyType(type.id, type) + ';'
228
- )
229
- }
230
- }
231
- var toTitleCase = function (str) {
232
- return str[0].toUpperCase() + str.substr(1)
233
- }
234
- var toCmdRequestName = function (commandName) {
235
- return toTitleCase(commandName) + 'Request'
236
- }
237
- var toCmdResponseName = function (commandName) {
238
- return toTitleCase(commandName) + 'Response'
239
- }
240
- var emitCommand = function (command) {
241
- emitInlineEnumsForCommands(command)
242
- // TODO(bckenny): should description be emitted for params and return types?
243
- if (command.parameters) {
244
- emitLine()
245
- emitInterface(toCmdRequestName(command.name), command.parameters)
246
- }
247
- if (command.returns) {
248
- emitLine()
249
- emitInterface(toCmdResponseName(command.name), command.returns)
250
- }
251
- }
252
- var toEventPayloadName = function (eventName) {
253
- return toTitleCase(eventName) + 'Event'
254
- }
255
- var emitEvent = function (event) {
256
- if (!event.parameters) {
257
- return
258
- }
259
- emitInlineEnumsForEvents(event)
260
- emitLine()
261
- emitDescription(event.description)
262
- emitInterface(toEventPayloadName(event.name), event.parameters)
263
- }
264
- var getEventMapping = function (event, domainName, modulePrefix) {
265
- // Use TS3.0+ tuples
266
- var payloadType = event.parameters
267
- ? '[' +
268
- modulePrefix +
269
- '.' +
270
- domainName +
271
- '.' +
272
- toEventPayloadName(event.name) +
273
- ']'
274
- : '[]'
275
- return {
276
- // domain-prefixed name since it will be used outside of the module.
277
- name: domainName + '.' + event.name,
278
- description: event.description,
279
- $ref: payloadType,
280
- }
281
- }
282
- var isWeakInterface = function (params) {
283
- return params.every(function (p) {
284
- return !!p.optional
285
- })
286
- }
287
- var getCommandMapping = function (command, domainName, modulePrefix) {
288
- var prefix = modulePrefix + '.' + domainName + '.'
289
- // Use TS3.0+ tuples for paramsType
290
- var requestType = '[]'
291
- if (command.parameters) {
292
- var optional = isWeakInterface(command.parameters) ? '?' : ''
293
- requestType = '[' + prefix + toCmdRequestName(command.name) + optional + ']'
294
- }
295
- var responseType = command.returns
296
- ? prefix + toCmdResponseName(command.name)
297
- : 'void'
298
- return {
299
- type: 'object',
300
- name: domainName + '.' + command.name,
301
- description: command.description,
302
- properties: [
303
- {
304
- name: 'paramsType',
305
- $ref: requestType,
306
- },
307
- {
308
- name: 'returnType',
309
- $ref: responseType,
310
- },
311
- ],
312
- }
313
- }
314
- var flatten = function (arr) {
315
- var _a
316
- return (_a = []).concat.apply(_a, arr)
317
- }
318
- var emitMapping = function (moduleName, protocolModuleName, domains) {
319
- moduleName = toTitleCase(moduleName)
320
- emitHeaderComments()
321
- emitLine("import Protocol from './" + protocolModuleName + "'")
322
- emitLine()
323
- emitDescription(
324
- 'Mappings from protocol event and command names to the types required for them.'
325
- )
326
- emitOpenBlock('export namespace ' + moduleName)
327
- var protocolModulePrefix = toTitleCase(protocolModuleName)
328
- var eventDefs = flatten(
329
- domains.map(function (d) {
330
- var domainName = toTitleCase(d.domain)
331
- return (d.events || []).map(function (e) {
332
- return getEventMapping(e, domainName, protocolModulePrefix)
333
- })
334
- })
335
- )
336
- emitInterface('Events', eventDefs)
337
- emitLine()
338
- var commandDefs = flatten(
339
- domains.map(function (d) {
340
- var domainName = toTitleCase(d.domain)
341
- return (d.commands || []).map(function (c) {
342
- return getCommandMapping(c, domainName, protocolModulePrefix)
343
- })
344
- })
345
- )
346
- emitInterface('Commands', commandDefs)
347
- emitCloseBlock()
348
- emitLine()
349
- emitLine('export default ' + moduleName + ';')
350
- }
351
- var emitApiCommand = function (command, domainName, modulePrefix) {
352
- var prefix = modulePrefix + '.' + domainName + '.'
353
- emitDescription(command.description)
354
- var params = command.parameters
355
- ? 'params: ' + prefix + toCmdRequestName(command.name)
356
- : ''
357
- var response = command.returns
358
- ? '' + prefix + toCmdResponseName(command.name)
359
- : 'void'
360
- emitLine(command.name + '(' + params + '): Promise<' + response + '>;')
361
- emitLine()
362
- }
363
- var emitApiEvent = function (event, domainName, modulePrefix) {
364
- var prefix = modulePrefix + '.' + domainName + '.'
365
- emitDescription(event.description)
366
- var params = event.parameters
367
- ? 'params: ' + prefix + toEventPayloadName(event.name)
368
- : ''
369
- emitLine(
370
- "on(event: '" + event.name + "', listener: (" + params + ') => void): void;'
371
- )
372
- emitLine()
373
- }
374
- var emitDomainApi = function (domain, modulePrefix) {
375
- emitLine()
376
- var domainName = toTitleCase(domain.domain)
377
- emitOpenBlock('export interface ' + domainName + 'Api')
378
- if (domain.commands)
379
- domain.commands.forEach(function (c) {
380
- return emitApiCommand(c, domainName, modulePrefix)
381
- })
382
- if (domain.events)
383
- domain.events.forEach(function (e) {
384
- return emitApiEvent(e, domainName, modulePrefix)
385
- })
386
- emitCloseBlock()
387
- }
388
- var emitApi = function (moduleName, protocolModuleName, domains) {
389
- moduleName = toTitleCase(moduleName)
390
- emitHeaderComments()
391
- emitLine("import Protocol from './" + protocolModuleName + "'")
392
- emitLine()
393
- emitDescription('API generated from Protocol commands and events.')
394
- emitOpenBlock('export namespace ' + moduleName)
395
- emitLine()
396
- emitOpenBlock('export interface ProtocolApi')
397
- domains.forEach(function (d) {
398
- emitLine(d.domain + ': ' + d.domain + 'Api;')
399
- emitLine()
400
- })
401
- emitCloseBlock()
402
- emitLine()
403
- var protocolModulePrefix = toTitleCase(protocolModuleName)
404
- domains.forEach(function (d) {
405
- return emitDomainApi(d, protocolModulePrefix)
406
- })
407
- emitCloseBlock()
408
- emitLine()
409
- emitLine('export default ' + moduleName + ';')
410
- }
411
- var flushEmitToFile = function (path) {
412
- console.log('Writing to ' + path)
413
- fs.writeFileSync(path, emitStr, { encoding: 'utf-8' })
414
- numIndents = 0
415
- emitStr = ''
416
- }
417
- // Main
418
- var destProtocolFilePath = process.argv[4]
419
- var protocolModuleName = path.basename(destProtocolFilePath, '.d.js')
420
- emitModule(protocolModuleName, protocolDomains)
421
- flushEmitToFile(destProtocolFilePath)
422
- var destMappingFilePath = process.argv[5]
423
- var mappingModuleName = 'ProtocolMapping'
424
- emitMapping(mappingModuleName, protocolModuleName, protocolDomains)
425
- flushEmitToFile(destMappingFilePath)
426
- var destApiFilePath = process.argv[6]
427
- var apiModuleName = 'ProtocolProxyApi'
428
- emitApi(apiModuleName, protocolModuleName, protocolDomains)
429
- flushEmitToFile(destApiFilePath)
package/lib/README DELETED
@@ -1,5 +0,0 @@
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.