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.
- package/CHANGES.md +41 -1
- package/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +0 -0
- package/chrome.js +0 -0
- package/chromium.js +23 -202
- package/devtools/CDPConnection.js +16 -18
- package/edge.js +89 -130
- package/example/chrome_android.js +45 -0
- package/{lib/atoms/make-atoms-module.js → example/chrome_mobile_emulation.js} +26 -15
- package/example/firefox_channels.js +84 -0
- package/example/google_search.js +50 -0
- package/example/google_search_test.js +70 -0
- package/example/headless.js +63 -0
- package/example/logging.js +64 -0
- package/firefox.js +10 -9
- package/http/index.js +0 -0
- package/http/util.js +3 -3
- package/ie.js +0 -0
- package/index.js +2 -2
- package/io/exec.js +3 -3
- package/io/index.js +12 -13
- package/io/zip.js +5 -6
- package/lib/atoms/find-elements.js +78 -78
- package/lib/atoms/get-attribute.js +64 -68
- package/lib/atoms/is-displayed.js +27 -27
- package/lib/atoms/mutation-listener.js +55 -0
- package/lib/by.js +1 -1
- package/lib/capabilities.js +2 -3
- package/lib/command.js +2 -15
- package/lib/error.js +0 -0
- package/lib/http.js +17 -30
- package/lib/input.js +2 -286
- package/lib/logging.js +0 -0
- package/lib/promise.js +4 -16
- package/lib/proxy.js +0 -0
- package/lib/session.js +0 -0
- package/lib/symbols.js +0 -0
- package/lib/until.js +17 -15
- package/lib/webdriver.js +336 -16
- package/net/index.js +0 -0
- package/net/portprober.js +8 -8
- package/opera.js +0 -0
- package/package.json +13 -13
- package/proxy.js +0 -0
- package/remote/index.js +6 -7
- package/safari.js +0 -0
- package/testing/index.js +504 -0
- package/.eslintrc.js +0 -27
- package/.prettierrc +0 -4
- package/devtools/generator/protocol-dts-generator.js +0 -429
- package/lib/README +0 -5
- package/lib/actions.js +0 -626
package/CHANGES.md
CHANGED
|
@@ -1,3 +1,43 @@
|
|
|
1
|
+
## v4.0.0-beta.4
|
|
2
|
+
|
|
3
|
+
* Add windowTypes option support for ChromiumDriver (#7897)
|
|
4
|
+
* Allow relativeby with findElement (#9396)
|
|
5
|
+
|
|
6
|
+
## v4.0.0-beta.3
|
|
7
|
+
|
|
8
|
+
* Removed support for legacy actions.
|
|
9
|
+
This will also remove "Bride Mode" support, which was introduced to translate of action class to legacy API.
|
|
10
|
+
* Remove devtools support for v86,v87 and adding support for v89, v90, v91
|
|
11
|
+
* make isPromise() return boolean value for null and undefined cases (#6785)
|
|
12
|
+
* code cleanup (#9158)
|
|
13
|
+
* replacing asserts equal with strictEqual and deepEqual with deepStrictEqual
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## v4.0.0-beta.2
|
|
17
|
+
|
|
18
|
+
* Removed support for Edge legacy.
|
|
19
|
+
* Make the build silent for WebDriver Bidi generated code
|
|
20
|
+
* resolve file path correctly (#9223)
|
|
21
|
+
* Update example in edge.js (#9231)
|
|
22
|
+
* Use a flat namespace for selenium options for finding WebDriver Bidi endpoint
|
|
23
|
+
* Removing duplicate license text updated by update_copyright.js
|
|
24
|
+
* Updating copyright text
|
|
25
|
+
* Minor code cleanup
|
|
26
|
+
* Removing duplicate variable declaration of IE from capabilities
|
|
27
|
+
|
|
28
|
+
## v4.0.0-beta.1
|
|
29
|
+
|
|
30
|
+
* JS Binding support for WebDriver Bidi in Firefox
|
|
31
|
+
- This requires Firefox 87 and Geckodriver 0.29 to be able to work
|
|
32
|
+
* Update the supported CDP versions
|
|
33
|
+
* Update tmp package version (#9155)
|
|
34
|
+
* Adding support for /computedlabel (getAccessibleName) (#9073)
|
|
35
|
+
* Adding support for computedrole (#8990)
|
|
36
|
+
* Use subfolder for NPM package homepage (#8938)
|
|
37
|
+
* Fix typo: tracingCategories -> traceCategories (#8976)
|
|
38
|
+
* Package up mutation-listener for node. Fixes #8955
|
|
39
|
+
* Adding support for `print` endpoint (#8880)
|
|
40
|
+
|
|
1
41
|
## v4.0.0-alpha.8
|
|
2
42
|
|
|
3
43
|
* Rolling back native support for Opera Browser
|
|
@@ -7,7 +47,7 @@
|
|
|
7
47
|
- setEdgeChromium
|
|
8
48
|
- setScrollBehavior
|
|
9
49
|
- For consistent naming, deprecating `addArguments(...args)` in favor of `addBrowserCommandSwitches(...args)`
|
|
10
|
-
|
|
50
|
+
|
|
11
51
|
* Added relative locators
|
|
12
52
|
* Added Chrome DevTools Protocol (CDP) support
|
|
13
53
|
* Added support for BASIC authentication.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2021 Software Freedom Conservancy (SFC)
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
File without changes
|
package/chrome.js
CHANGED
|
File without changes
|
package/chromium.js
CHANGED
|
@@ -82,11 +82,7 @@ const command = require('./lib/command')
|
|
|
82
82
|
const error = require('./lib/error')
|
|
83
83
|
const Symbols = require('./lib/symbols')
|
|
84
84
|
const webdriver = require('./lib/webdriver')
|
|
85
|
-
const WebSocket = require('ws')
|
|
86
|
-
const cdp = require('./devtools/CDPConnection')
|
|
87
85
|
const remote = require('./remote')
|
|
88
|
-
const cdpTargets = ['page', 'browser']
|
|
89
|
-
const fs = require('fs')
|
|
90
86
|
|
|
91
87
|
/**
|
|
92
88
|
* Custom command names supported by Chromium WebDriver.
|
|
@@ -112,9 +108,9 @@ const Command = {
|
|
|
112
108
|
* @return {!command.Executor} The new command executor.
|
|
113
109
|
*/
|
|
114
110
|
function createExecutor(url, vendorPrefix) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
const agent = new http.Agent({ keepAlive: true })
|
|
112
|
+
const client = url.then((url) => new http.HttpClient(url, agent))
|
|
113
|
+
const executor = new http.Executor(client)
|
|
118
114
|
configureExecutor(executor, vendorPrefix)
|
|
119
115
|
return executor
|
|
120
116
|
}
|
|
@@ -394,7 +390,7 @@ class Options extends Capabilities {
|
|
|
394
390
|
* - `enableTimeline`: Whether or not to collect events from Timeline domain.
|
|
395
391
|
* Note: when tracing is enabled, Timeline domain is implicitly disabled,
|
|
396
392
|
* unless `enableTimeline` is explicitly set to true.
|
|
397
|
-
* - `
|
|
393
|
+
* - `traceCategories`: A comma-separated string of Chromium tracing
|
|
398
394
|
* categories for which trace events should be collected. An unspecified
|
|
399
395
|
* or empty string disables tracing.
|
|
400
396
|
* - `bufferUsageReportingInterval`: The requested number of milliseconds
|
|
@@ -405,7 +401,7 @@ class Options extends Capabilities {
|
|
|
405
401
|
* @param {{enableNetwork: boolean,
|
|
406
402
|
* enablePage: boolean,
|
|
407
403
|
* enableTimeline: boolean,
|
|
408
|
-
*
|
|
404
|
+
* traceCategories: string,
|
|
409
405
|
* bufferUsageReportingInterval: number}} prefs The performance
|
|
410
406
|
* logging preferences.
|
|
411
407
|
* @return {!Options} A self reference.
|
|
@@ -553,6 +549,22 @@ class Options extends Capabilities {
|
|
|
553
549
|
return this
|
|
554
550
|
}
|
|
555
551
|
|
|
552
|
+
/**
|
|
553
|
+
* Sets a list of the window types that will appear when getting window
|
|
554
|
+
* handles. For access to <webview> elements, include "webview" in the list.
|
|
555
|
+
* @param {...(string|!Array<string>)} args The window types that will appear
|
|
556
|
+
* when getting window handles.
|
|
557
|
+
* @return {!Options} A self reference.
|
|
558
|
+
*/
|
|
559
|
+
windowTypes(...args) {
|
|
560
|
+
let windowTypes = (this.options_.windowTypes || []).concat(...args);
|
|
561
|
+
if (windowTypes.length) {
|
|
562
|
+
this.options_.windowTypes = windowTypes;
|
|
563
|
+
}
|
|
564
|
+
return this;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
|
|
556
568
|
/**
|
|
557
569
|
* Converts this instance to its JSON wire protocol representation. Note this
|
|
558
570
|
* function is an implementation not intended for general use.
|
|
@@ -569,7 +581,7 @@ class Options extends Capabilities {
|
|
|
569
581
|
return extension.toString('base64')
|
|
570
582
|
}
|
|
571
583
|
return io
|
|
572
|
-
.read(/** @type {string} */
|
|
584
|
+
.read(/** @type {string} */(extension))
|
|
573
585
|
.then((buffer) => buffer.toString('base64'))
|
|
574
586
|
})
|
|
575
587
|
}
|
|
@@ -622,7 +634,7 @@ class Driver extends webdriver.WebDriver {
|
|
|
622
634
|
* implementation.
|
|
623
635
|
* @override
|
|
624
636
|
*/
|
|
625
|
-
setFileDetector() {}
|
|
637
|
+
setFileDetector() { }
|
|
626
638
|
|
|
627
639
|
/**
|
|
628
640
|
* Schedules a command to launch Chrome App with given ID.
|
|
@@ -709,127 +721,6 @@ class Driver extends webdriver.WebDriver {
|
|
|
709
721
|
)
|
|
710
722
|
}
|
|
711
723
|
|
|
712
|
-
/**
|
|
713
|
-
* Creates a new WebSocket connection.
|
|
714
|
-
* @return {!Promise<resolved>} A new CDP instance.
|
|
715
|
-
*/
|
|
716
|
-
async createCDPConnection(target) {
|
|
717
|
-
const caps = await this.getCapabilities()
|
|
718
|
-
const seOptions = caps['map_'].get('se:options') || new Map()
|
|
719
|
-
const vendorInfo =
|
|
720
|
-
caps['map_'].get(this.VENDOR_COMMAND_PREFIX + ':chromeOptions') ||
|
|
721
|
-
new Map()
|
|
722
|
-
const debuggerUrl = seOptions['cdp'] || vendorInfo['debuggerAddress']
|
|
723
|
-
this._wsUrl = await this.getWsUrl(debuggerUrl, target)
|
|
724
|
-
|
|
725
|
-
return new Promise((resolve, reject) => {
|
|
726
|
-
try {
|
|
727
|
-
this._wsConnection = new WebSocket(this._wsUrl)
|
|
728
|
-
} catch (err) {
|
|
729
|
-
reject(err)
|
|
730
|
-
return
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
this._wsConnection.on('open', () => {
|
|
734
|
-
this._cdpConnection = new cdp.CdpConnection(this._wsConnection)
|
|
735
|
-
resolve(this._cdpConnection)
|
|
736
|
-
})
|
|
737
|
-
|
|
738
|
-
this._wsConnection.on('error', (error) => {
|
|
739
|
-
reject(error)
|
|
740
|
-
})
|
|
741
|
-
})
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
/**
|
|
745
|
-
* Retrieves 'webSocketDebuggerUrl' by sending a http request using debugger address
|
|
746
|
-
* @param {string} debuggerAddress
|
|
747
|
-
* @param {string} target
|
|
748
|
-
* @return {string} Returns parsed webSocketDebuggerUrl obtained from the http request
|
|
749
|
-
*/
|
|
750
|
-
async getWsUrl(debuggerAddress, target) {
|
|
751
|
-
if (target && cdpTargets.indexOf(target.toLowerCase()) === -1) {
|
|
752
|
-
throw new error.InvalidArgumentError('invalid target value')
|
|
753
|
-
}
|
|
754
|
-
let path = '/json/version'
|
|
755
|
-
|
|
756
|
-
if (target === 'page') {
|
|
757
|
-
path = '/json'
|
|
758
|
-
}
|
|
759
|
-
let request = new http.Request('GET', path)
|
|
760
|
-
let client = new http.HttpClient('http://' + debuggerAddress)
|
|
761
|
-
let response = await client.send(request)
|
|
762
|
-
let url = JSON.parse(response.body)['webSocketDebuggerUrl']
|
|
763
|
-
if (target.toLowerCase() === 'page') {
|
|
764
|
-
url = JSON.parse(response.body)[0]['webSocketDebuggerUrl']
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
return url
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
/**
|
|
771
|
-
* Sets a listener for Fetch.authRequired event from CDP
|
|
772
|
-
* If event is triggered, it enter username and password
|
|
773
|
-
* and allows the test to move forward
|
|
774
|
-
* @param {string} username
|
|
775
|
-
* @param {string} password
|
|
776
|
-
* @param connection CDP Connection
|
|
777
|
-
*/
|
|
778
|
-
async register(username, password, connection) {
|
|
779
|
-
await connection.execute("Network.setCacheDisabled", this.getRandomNumber(1, 10), {
|
|
780
|
-
cacheDisabled: true,
|
|
781
|
-
}, null);
|
|
782
|
-
|
|
783
|
-
this._wsConnection.on('message', (message) => {
|
|
784
|
-
const params = JSON.parse(message)
|
|
785
|
-
|
|
786
|
-
if (params.method === 'Fetch.authRequired') {
|
|
787
|
-
const requestParams = params['params']
|
|
788
|
-
connection.execute('Fetch.continueWithAuth', this.getRandomNumber(1, 10), {
|
|
789
|
-
requestId: requestParams['requestId'],
|
|
790
|
-
authChallengeResponse: {
|
|
791
|
-
response: 'ProvideCredentials',
|
|
792
|
-
username: username,
|
|
793
|
-
password: password,
|
|
794
|
-
}})
|
|
795
|
-
} else if (params.method === 'Fetch.requestPaused') {
|
|
796
|
-
const requestPausedParams = params['params']
|
|
797
|
-
connection.execute('Fetch.continueRequest', this.getRandomNumber(1, 10), {
|
|
798
|
-
requestId: requestPausedParams['requestId'],
|
|
799
|
-
})
|
|
800
|
-
}
|
|
801
|
-
})
|
|
802
|
-
|
|
803
|
-
await connection.execute('Fetch.enable', 1, {
|
|
804
|
-
handleAuthRequests: true,
|
|
805
|
-
}, null)
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
/**
|
|
809
|
-
*
|
|
810
|
-
* @param connection
|
|
811
|
-
* @param callback
|
|
812
|
-
* @returns {Promise<void>}
|
|
813
|
-
*/
|
|
814
|
-
async onLogEvent(connection, callback) {
|
|
815
|
-
await connection.execute('Runtime.enable', this.getRandomNumber(1, 10), {}, null)
|
|
816
|
-
|
|
817
|
-
this._wsConnection.on('message', (message) => {
|
|
818
|
-
const params = JSON.parse(message)
|
|
819
|
-
|
|
820
|
-
if (params.method === 'Runtime.consoleAPICalled') {
|
|
821
|
-
const consoleEventParams = params['params']
|
|
822
|
-
let event = {
|
|
823
|
-
type: consoleEventParams['type'],
|
|
824
|
-
timestamp: new Date(consoleEventParams['timestamp']),
|
|
825
|
-
args: consoleEventParams['args']
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
callback(event)
|
|
829
|
-
}
|
|
830
|
-
})
|
|
831
|
-
}
|
|
832
|
-
|
|
833
724
|
/**
|
|
834
725
|
* Set a permission state to the given value.
|
|
835
726
|
*
|
|
@@ -848,72 +739,6 @@ class Driver extends webdriver.WebDriver {
|
|
|
848
739
|
)
|
|
849
740
|
}
|
|
850
741
|
|
|
851
|
-
/**
|
|
852
|
-
*
|
|
853
|
-
* @param connection
|
|
854
|
-
* @param callback
|
|
855
|
-
* @returns {Promise<void>}
|
|
856
|
-
*/
|
|
857
|
-
async onLogException(connection, callback) {
|
|
858
|
-
await connection.execute('Runtime.enable', this.getRandomNumber(1, 10), {}, null)
|
|
859
|
-
|
|
860
|
-
this._wsConnection.on('message', (message) => {
|
|
861
|
-
const params = JSON.parse(message)
|
|
862
|
-
|
|
863
|
-
if (params.method === 'Runtime.exceptionThrown') {
|
|
864
|
-
const exceptionEventParams = params['params']
|
|
865
|
-
let event = {
|
|
866
|
-
exceptionDetails: exceptionEventParams['exceptionDetails'],
|
|
867
|
-
timestamp: new Date(exceptionEventParams['timestamp']),
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
callback(event)
|
|
871
|
-
}
|
|
872
|
-
})
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
/**
|
|
876
|
-
* @param connection
|
|
877
|
-
* @param callback
|
|
878
|
-
* @returns {Promise<void>}
|
|
879
|
-
*/
|
|
880
|
-
async logMutationEvents(connection, callback) {
|
|
881
|
-
await connection.execute('Runtime.enable', this.getRandomNumber(1, 10), {}, null)
|
|
882
|
-
await connection.execute('Page.enable', this.getRandomNumber(1, 10), {}, null)
|
|
883
|
-
|
|
884
|
-
await connection.execute('Runtime.addBinding', this.getRandomNumber(1, 10), {
|
|
885
|
-
name: '__webdriver_attribute',
|
|
886
|
-
}, null)
|
|
887
|
-
|
|
888
|
-
const mutationListener = fs.readFileSync('../../cdp-support/mutation-listener.js', 'utf-8').toString()
|
|
889
|
-
|
|
890
|
-
this.executeScript(mutationListener)
|
|
891
|
-
|
|
892
|
-
await connection.execute('Page.addScriptToEvaluateOnNewDocument', this.getRandomNumber(1, 10), {
|
|
893
|
-
source: mutationListener,
|
|
894
|
-
}, null)
|
|
895
|
-
|
|
896
|
-
this._wsConnection.on('message', async (message) => {
|
|
897
|
-
const params = JSON.parse(message)
|
|
898
|
-
if (params.method === 'Runtime.bindingCalled') {
|
|
899
|
-
let payload = JSON.parse(params['params']['payload'])
|
|
900
|
-
let elements = await this.findElements({css: "*[data-__webdriver_id=" + payload['target']})
|
|
901
|
-
|
|
902
|
-
if (elements.length === 0) {
|
|
903
|
-
return
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
let event = {
|
|
907
|
-
element: elements[0],
|
|
908
|
-
attribute_name: payload['name'],
|
|
909
|
-
current_value: payload['value'],
|
|
910
|
-
old_value: payload['oldValue']
|
|
911
|
-
}
|
|
912
|
-
callback(event)
|
|
913
|
-
}
|
|
914
|
-
})
|
|
915
|
-
}
|
|
916
|
-
|
|
917
742
|
/**
|
|
918
743
|
* Sends a DevTools command to change the browser's download directory.
|
|
919
744
|
*
|
|
@@ -1011,10 +836,6 @@ class Driver extends webdriver.WebDriver {
|
|
|
1011
836
|
'Driver.stopCasting(' + deviceName + ')'
|
|
1012
837
|
)
|
|
1013
838
|
}
|
|
1014
|
-
|
|
1015
|
-
getRandomNumber(min, max) {
|
|
1016
|
-
return Math.floor(Math.random() * (max - min + 1) + min)
|
|
1017
|
-
}
|
|
1018
839
|
}
|
|
1019
840
|
|
|
1020
841
|
// PUBLIC API
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
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.
|
|
19
17
|
|
|
20
18
|
class CDPConnection {
|
|
21
19
|
constructor(wsConnection) {
|