selenium-webdriver 3.3.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 (117) hide show
  1. package/CHANGES.md +273 -0
  2. package/NOTICE +1 -1
  3. package/README.md +28 -36
  4. package/chrome.js +221 -146
  5. package/edge.js +43 -118
  6. package/example/chrome_android.js +8 -9
  7. package/example/chrome_mobile_emulation.js +9 -10
  8. package/example/firefox_channels.js +23 -19
  9. package/example/google_search.js +3 -3
  10. package/example/google_search_test.js +39 -27
  11. package/example/headless.js +55 -0
  12. package/example/logging.js +40 -7
  13. package/firefox.js +769 -0
  14. package/http/index.js +41 -4
  15. package/http/util.js +11 -6
  16. package/ie.js +57 -98
  17. package/index.js +182 -115
  18. package/io/index.js +59 -0
  19. package/io/zip.js +214 -0
  20. package/jasmine.json +11 -0
  21. package/lib/actions.js +68 -63
  22. package/lib/atoms/get-attribute.js +9 -0
  23. package/lib/atoms/is-displayed.js +73 -78
  24. package/lib/by.js +9 -1
  25. package/lib/capabilities.js +303 -201
  26. package/lib/command.js +28 -50
  27. package/lib/error.js +113 -42
  28. package/lib/http.js +167 -135
  29. package/lib/input.js +1044 -8
  30. package/lib/promise.js +222 -3331
  31. package/lib/proxy.js +134 -39
  32. package/lib/test/bootstrap_jasmine.js +28 -0
  33. package/lib/test/data/actions/click.html +24 -0
  34. package/lib/test/data/actions/drag.html +77 -0
  35. package/lib/test/data/actions/record_click.html +21 -0
  36. package/lib/test/data/chrome/download.html +2 -0
  37. package/lib/test/data/click_tests/disabled_element.html +12 -0
  38. package/lib/test/data/content-editable.html +10 -0
  39. package/lib/test/data/firefox/webextension.xpi +0 -0
  40. package/lib/test/data/inputs.html +42 -0
  41. package/lib/test/data/key_logger.html +34 -0
  42. package/lib/test/data/nestedElements.html +10 -1
  43. package/lib/test/data/scrolling_tests/page_with_partially_hidden_element.html +14 -0
  44. package/lib/test/data/selectPage.html +12 -0
  45. package/lib/test/data/simpleTest.html +5 -0
  46. package/lib/test/data/single_text_input.html +12 -0
  47. package/lib/test/data/upload_invisible.html +45 -0
  48. package/lib/test/fileserver.js +23 -19
  49. package/lib/test/index.js +30 -244
  50. package/lib/test/resources.js +0 -1
  51. package/lib/webdriver.js +770 -939
  52. package/net/index.js +21 -25
  53. package/net/portprober.js +51 -68
  54. package/package.json +6 -4
  55. package/remote/index.js +18 -30
  56. package/safari.js +42 -129
  57. package/test/actions_test.js +173 -18
  58. package/test/builder_test.js +106 -0
  59. package/test/chrome/devtools_test.js +93 -0
  60. package/test/chrome/options_test.js +48 -154
  61. package/test/chrome/service_test.js +7 -7
  62. package/test/cookie_test.js +77 -63
  63. package/test/element_finding_test.js +206 -201
  64. package/test/execute_script_test.js +115 -114
  65. package/test/fingerprint_test.js +16 -15
  66. package/test/firefox_test.js +251 -0
  67. package/test/http/http_test.js +18 -1
  68. package/test/http/util_test.js +2 -2
  69. package/test/{io_test.js → io/io_test.js} +40 -1
  70. package/test/io/zip_test.js +127 -0
  71. package/test/lib/by_test.js +21 -0
  72. package/test/lib/error_test.js +55 -8
  73. package/test/lib/http_test.js +18 -130
  74. package/test/lib/input_test.js +1379 -0
  75. package/test/lib/promise_test.js +473 -908
  76. package/test/lib/webdriver_test.js +357 -825
  77. package/test/logging_test.js +37 -43
  78. package/test/page_loading_test.js +70 -86
  79. package/test/proxy_test.js +64 -72
  80. package/test/rect_test.js +14 -25
  81. package/test/remote_test.js +13 -32
  82. package/test/safari_test.js +7 -71
  83. package/test/stale_element_test.js +20 -23
  84. package/test/tag_name_test.js +10 -9
  85. package/test/upload_test.js +27 -35
  86. package/test/window_test.js +72 -85
  87. package/testing/index.js +386 -315
  88. package/.npmignore +0 -2
  89. package/example/async_await_test.js +0 -68
  90. package/example/google_search_generator.js +0 -50
  91. package/example/parallel_flows.js +0 -54
  92. package/firefox/binary.js +0 -344
  93. package/firefox/extension.js +0 -187
  94. package/firefox/index.js +0 -722
  95. package/firefox/profile.js +0 -430
  96. package/lib/atoms/getAttribute.js +0 -12
  97. package/lib/events.js +0 -210
  98. package/lib/firefox/webdriver.json +0 -70
  99. package/lib/firefox/webdriver.xpi +0 -0
  100. package/lib/test/data/firefox/jetpack-sample.xpi +0 -0
  101. package/lib/test/data/firefox/sample.xpi +0 -0
  102. package/lib/test/promise.js +0 -79
  103. package/opera.js +0 -405
  104. package/phantomjs.js +0 -282
  105. package/test/firefox/extension_test.js +0 -96
  106. package/test/firefox/firefox_test.js +0 -226
  107. package/test/firefox/profile_test.js +0 -185
  108. package/test/lib/events_test.js +0 -177
  109. package/test/lib/promise_aplus_test.js +0 -78
  110. package/test/lib/promise_error_test.js +0 -884
  111. package/test/lib/promise_flow_test.js +0 -2288
  112. package/test/lib/promise_generator_test.js +0 -310
  113. package/test/phantomjs/execute_phantomjs_test.js +0 -59
  114. package/test/session_test.js +0 -54
  115. package/test/testing/assert_test.js +0 -373
  116. package/test/testing/index_test.js +0 -224
  117. package/testing/assert.js +0 -378
@@ -1,187 +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 AdmZip = require('adm-zip'),
23
- fs = require('fs'),
24
- path = require('path'),
25
- xml = require('xml2js');
26
-
27
- const io = require('../io');
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 Promise.resolve().then(function() {
60
- // TODO: find an async library for inflating a zip archive.
61
- new AdmZip(extension).extractAllTo(dst, true);
62
- return details.id;
63
- });
64
- }
65
- } else {
66
- return io.copyDir(extension, dst).then(() => details.id);
67
- }
68
- });
69
- }
70
-
71
-
72
- /**
73
- * Describes a Firefox add-on.
74
- * @typedef {{id: string, name: string, version: string, unpack: boolean}}
75
- */
76
- var AddonDetails;
77
-
78
- /** @typedef {{$: !Object<string, string>}} */
79
- var RdfRoot;
80
-
81
-
82
-
83
- /**
84
- * Extracts the details needed to install an add-on.
85
- * @param {string} addonPath Path to the extension directory.
86
- * @return {!Promise<!AddonDetails>} A promise for the add-on details.
87
- */
88
- function getDetails(addonPath) {
89
- return readManifest(addonPath).then(function(doc) {
90
- var em = getNamespaceId(doc, 'http://www.mozilla.org/2004/em-rdf#');
91
- var rdf = getNamespaceId(
92
- doc, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
93
-
94
- var description = doc[rdf + 'RDF'][rdf + 'Description'][0];
95
- var details = {
96
- id: getNodeText(description, em + 'id'),
97
- name: getNodeText(description, em + 'name'),
98
- version: getNodeText(description, em + 'version'),
99
- unpack: getNodeText(description, em + 'unpack') || false
100
- };
101
-
102
- if (typeof details.unpack === 'string') {
103
- details.unpack = details.unpack.toLowerCase() === 'true';
104
- }
105
-
106
- if (!details.id) {
107
- throw new AddonFormatError('Could not find add-on ID for ' + addonPath);
108
- }
109
-
110
- return details;
111
- });
112
-
113
- function getNodeText(node, name) {
114
- return node[name] && node[name][0] || '';
115
- }
116
-
117
- function getNamespaceId(doc, url) {
118
- var keys = Object.keys(doc);
119
- if (keys.length !== 1) {
120
- throw new AddonFormatError('Malformed manifest for add-on ' + addonPath);
121
- }
122
-
123
- var namespaces = /** @type {!RdfRoot} */(doc[keys[0]]).$;
124
- var id = '';
125
- Object.keys(namespaces).some(function(ns) {
126
- if (namespaces[ns] !== url) {
127
- return false;
128
- }
129
-
130
- if (ns.indexOf(':') != -1) {
131
- id = ns.split(':')[1] + ':';
132
- }
133
- return true;
134
- });
135
- return id;
136
- }
137
- }
138
-
139
-
140
- /**
141
- * Reads the manifest for a Firefox add-on.
142
- * @param {string} addonPath Path to a Firefox add-on as a xpi or an extension.
143
- * @return {!Promise<!Object>} A promise for the parsed manifest.
144
- */
145
- function readManifest(addonPath) {
146
- var manifest;
147
-
148
- if (addonPath.slice(-4) === '.xpi') {
149
- manifest = new Promise((resolve, reject) => {
150
- let zip = new AdmZip(addonPath);
151
-
152
- if (!zip.getEntry('install.rdf')) {
153
- reject(new AddonFormatError(
154
- 'Could not find install.rdf in ' + addonPath));
155
- return;
156
- }
157
-
158
- zip.readAsTextAsync('install.rdf', resolve);
159
- });
160
- } else {
161
- manifest = io.stat(addonPath).then(function(stats) {
162
- if (!stats.isDirectory()) {
163
- throw Error(
164
- 'Add-on path is neither a xpi nor a directory: ' + addonPath);
165
- }
166
- return io.read(path.join(addonPath, 'install.rdf'));
167
- });
168
- }
169
-
170
- return manifest.then(function(content) {
171
- return new Promise((resolve, reject) => {
172
- xml.parseString(content, (err, data) => {
173
- if (err) {
174
- reject(err);
175
- } else {
176
- resolve(data);
177
- }
178
- });
179
- });
180
- });
181
- }
182
-
183
-
184
- // PUBLIC API
185
-
186
-
187
- exports.install = install;