selenium-webdriver 3.6.0 → 4.0.0-alpha.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 (97) hide show
  1. package/CHANGES.md +181 -0
  2. package/README.md +25 -27
  3. package/chrome.js +113 -127
  4. package/edge.js +42 -117
  5. package/example/chrome_android.js +8 -8
  6. package/example/chrome_mobile_emulation.js +8 -8
  7. package/example/firefox_channels.js +22 -18
  8. package/example/google_search_test.js +39 -26
  9. package/example/logging.js +39 -6
  10. package/firefox.js +769 -0
  11. package/http/index.js +41 -4
  12. package/http/util.js +11 -6
  13. package/ie.js +56 -97
  14. package/index.js +178 -114
  15. package/jasmine.json +11 -0
  16. package/lib/actions.js +68 -63
  17. package/lib/by.js +1 -1
  18. package/lib/capabilities.js +255 -192
  19. package/lib/command.js +26 -50
  20. package/lib/error.js +85 -44
  21. package/lib/http.js +133 -110
  22. package/lib/input.js +1044 -8
  23. package/lib/promise.js +222 -3323
  24. package/lib/proxy.js +134 -39
  25. package/lib/test/bootstrap_jasmine.js +28 -0
  26. package/lib/test/data/actions/click.html +24 -0
  27. package/lib/test/data/actions/drag.html +77 -0
  28. package/lib/test/data/actions/record_click.html +21 -0
  29. package/lib/test/data/chrome/download.html +2 -0
  30. package/lib/test/data/inputs.html +42 -0
  31. package/lib/test/data/selectPage.html +12 -0
  32. package/lib/test/data/simpleTest.html +5 -0
  33. package/lib/test/data/upload_invisible.html +45 -0
  34. package/lib/test/fileserver.js +23 -19
  35. package/lib/test/index.js +30 -212
  36. package/lib/test/resources.js +0 -1
  37. package/lib/webdriver.js +675 -936
  38. package/net/index.js +21 -25
  39. package/net/portprober.js +51 -68
  40. package/package.json +5 -3
  41. package/remote/index.js +5 -19
  42. package/safari.js +41 -128
  43. package/test/actions_test.js +173 -18
  44. package/test/{session_test.js → builder_test.js} +44 -37
  45. package/test/chrome/devtools_test.js +93 -0
  46. package/test/chrome/options_test.js +48 -154
  47. package/test/chrome/service_test.js +7 -7
  48. package/test/cookie_test.js +77 -63
  49. package/test/element_finding_test.js +206 -201
  50. package/test/execute_script_test.js +115 -114
  51. package/test/fingerprint_test.js +16 -15
  52. package/test/firefox_test.js +251 -0
  53. package/test/http/http_test.js +0 -1
  54. package/test/http/util_test.js +2 -2
  55. package/test/io/zip_test.js +6 -7
  56. package/test/lib/error_test.js +34 -7
  57. package/test/lib/http_test.js +8 -128
  58. package/test/lib/input_test.js +1379 -0
  59. package/test/lib/promise_test.js +473 -908
  60. package/test/lib/webdriver_test.js +296 -868
  61. package/test/logging_test.js +37 -43
  62. package/test/page_loading_test.js +71 -81
  63. package/test/proxy_test.js +64 -72
  64. package/test/rect_test.js +14 -25
  65. package/test/remote_test.js +10 -29
  66. package/test/safari_test.js +7 -71
  67. package/test/stale_element_test.js +20 -23
  68. package/test/tag_name_test.js +10 -9
  69. package/test/upload_test.js +27 -35
  70. package/test/window_test.js +72 -85
  71. package/testing/index.js +386 -314
  72. package/.npmignore +0 -2
  73. package/example/async_await_test.js +0 -69
  74. package/example/google_search_generator.js +0 -47
  75. package/example/parallel_flows.js +0 -51
  76. package/firefox/binary.js +0 -347
  77. package/firefox/extension.js +0 -224
  78. package/firefox/index.js +0 -576
  79. package/firefox/profile.js +0 -311
  80. package/lib/events.js +0 -210
  81. package/lib/test/data/firefox/jetpack-sample.xpi +0 -0
  82. package/lib/test/data/firefox/sample.xpi +0 -0
  83. package/lib/test/promise.js +0 -79
  84. package/opera.js +0 -405
  85. package/phantomjs.js +0 -282
  86. package/test/firefox/extension_test.js +0 -120
  87. package/test/firefox/firefox_test.js +0 -244
  88. package/test/firefox/profile_test.js +0 -140
  89. package/test/lib/events_test.js +0 -177
  90. package/test/lib/promise_aplus_test.js +0 -78
  91. package/test/lib/promise_error_test.js +0 -884
  92. package/test/lib/promise_flow_test.js +0 -2288
  93. package/test/lib/promise_generator_test.js +0 -310
  94. package/test/phantomjs/execute_phantomjs_test.js +0 -59
  95. package/test/testing/assert_test.js +0 -373
  96. package/test/testing/index_test.js +0 -224
  97. package/testing/assert.js +0 -378
@@ -1,224 +0,0 @@
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
- /** @fileoverview Utilities for working with Firefox extensions. */
19
-
20
- 'use strict';
21
-
22
- const fs = require('fs'),
23
- path = require('path'),
24
- xml = require('xml2js');
25
-
26
- const io = require('../io');
27
- const zip = require('../io/zip');
28
-
29
-
30
- /**
31
- * Thrown when there an add-on is malformed.
32
- */
33
- class AddonFormatError extends Error {
34
- /** @param {string} msg The error message. */
35
- constructor(msg) {
36
- super(msg);
37
- /** @override */
38
- this.name = this.constructor.name;
39
- }
40
- }
41
-
42
-
43
-
44
- /**
45
- * Installs an extension to the given directory.
46
- * @param {string} extension Path to the extension to install, as either a xpi
47
- * file or a directory.
48
- * @param {string} dir Path to the directory to install the extension in.
49
- * @return {!Promise<string>} A promise for the add-on ID once
50
- * installed.
51
- */
52
- function install(extension, dir) {
53
- return getDetails(extension).then(function(details) {
54
- var dst = path.join(dir, details.id);
55
- if (extension.slice(-4) === '.xpi') {
56
- if (!details.unpack) {
57
- return io.copy(extension, dst + '.xpi').then(() => details.id);
58
- } else {
59
- return zip.unzip(extension, dst).then(() => details.id);
60
- }
61
- } else {
62
- return io.copyDir(extension, dst).then(() => details.id);
63
- }
64
- });
65
- }
66
-
67
-
68
- /**
69
- * Describes a Firefox add-on.
70
- * @typedef {{id: string, name: string, version: string, unpack: boolean}}
71
- */
72
- var AddonDetails;
73
-
74
- /** @typedef {{$: !Object<string, string>}} */
75
- var RdfRoot;
76
-
77
-
78
- /**
79
- * Extracts the details needed to install an add-on.
80
- * @param {string} addonPath Path to the extension directory.
81
- * @return {!Promise<!AddonDetails>} A promise for the add-on details.
82
- */
83
- function getDetails(addonPath) {
84
- return io.stat(addonPath).then((stats) => {
85
- if (stats.isDirectory()) {
86
- return parseDirectory(addonPath);
87
- } else if (addonPath.slice(-4) === '.xpi') {
88
- return parseXpiFile(addonPath);
89
- } else {
90
- throw Error('Add-on path is not an xpi or a directory: ' + addonPath);
91
- }
92
- });
93
-
94
- /**
95
- * Parse an install.rdf for a Firefox add-on.
96
- * @param {string} rdf The contents of install.rdf for the add-on.
97
- * @return {!Promise<!AddonDetails>} A promise for the add-on details.
98
- */
99
- function parseInstallRdf(rdf) {
100
- return parseXml(rdf).then(function(doc) {
101
- var em = getNamespaceId(doc, 'http://www.mozilla.org/2004/em-rdf#');
102
- var rdf = getNamespaceId(
103
- doc, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
104
-
105
- var description = doc[rdf + 'RDF'][rdf + 'Description'][0];
106
- var details = {
107
- id: getNodeText(description, em + 'id'),
108
- name: getNodeText(description, em + 'name'),
109
- version: getNodeText(description, em + 'version'),
110
- unpack: getNodeText(description, em + 'unpack') || false
111
- };
112
-
113
- if (typeof details.unpack === 'string') {
114
- details.unpack = details.unpack.toLowerCase() === 'true';
115
- }
116
-
117
- if (!details.id) {
118
- throw new AddonFormatError('Could not find add-on ID for ' + addonPath);
119
- }
120
-
121
- return details;
122
- });
123
-
124
- function parseXml(text) {
125
- return new Promise((resolve, reject) => {
126
- xml.parseString(text, (err, data) => {
127
- if (err) {
128
- reject(err);
129
- } else {
130
- resolve(data);
131
- }
132
- });
133
- });
134
- }
135
-
136
- function getNodeText(node, name) {
137
- return node[name] && node[name][0] || '';
138
- }
139
-
140
- function getNamespaceId(doc, url) {
141
- var keys = Object.keys(doc);
142
- if (keys.length !== 1) {
143
- throw new AddonFormatError('Malformed manifest for add-on ' + addonPath);
144
- }
145
-
146
- var namespaces = /** @type {!RdfRoot} */(doc[keys[0]]).$;
147
- var id = '';
148
- Object.keys(namespaces).some(function(ns) {
149
- if (namespaces[ns] !== url) {
150
- return false;
151
- }
152
-
153
- if (ns.indexOf(':') != -1) {
154
- id = ns.split(':')[1] + ':';
155
- }
156
- return true;
157
- });
158
- return id;
159
- }
160
- }
161
-
162
- /**
163
- * Parse a manifest for a Firefox WebExtension.
164
- * @param {{
165
- * name: string,
166
- * version: string,
167
- * applications: {gecko:{id:string}}
168
- * }} json JSON representation of the manifest.
169
- * @return {!AddonDetails} The add-on details.
170
- */
171
- function parseManifestJson({name, version, applications}) {
172
- if (!(applications && applications.gecko && applications.gecko.id)) {
173
- throw new AddonFormatError('Could not find add-on ID for ' + addonPath);
174
- }
175
-
176
- return {id: applications.gecko.id, name, version, unpack: false};
177
- }
178
-
179
- function parseXpiFile(filePath) {
180
- return zip.load(filePath).then(archive => {
181
- if (archive.has('install.rdf')) {
182
- return archive.getFile('install.rdf')
183
- .then(buf => parseInstallRdf(buf.toString('utf8')));
184
- }
185
-
186
- if (archive.has('manifest.json')) {
187
- return archive.getFile('manifest.json')
188
- .then(buf => JSON.parse(buf.toString('utf8')))
189
- .then(parseManifestJson);
190
- }
191
-
192
- throw new AddonFormatError(
193
- `Couldn't find install.rdf or manifest.json in ${filePath}`);
194
- });
195
- }
196
-
197
- function parseDirectory(dirPath) {
198
- const rdfPath = path.join(dirPath, 'install.rdf');
199
- const jsonPath = path.join(dirPath, 'manifest.json');
200
- return io.exists(rdfPath)
201
- .then(rdfExists => {
202
- if (rdfExists) {
203
- return io.read(rdfPath)
204
- .then(buf => parseInstallRdf(buf.toString('utf8')));
205
- }
206
- return io.exists(jsonPath)
207
- .then(jsonExists => {
208
- if (jsonExists) {
209
- return io.read(jsonPath)
210
- .then(buf => JSON.parse(buf.toString('utf8')))
211
- .then(parseManifestJson);
212
- }
213
- throw new AddonFormatError(
214
- `Couldn't find install.rdf or manifest.json in ${dirPath}`);
215
- });
216
- })
217
- }
218
- }
219
-
220
-
221
- // PUBLIC API
222
-
223
-
224
- exports.install = install;