browsertime 20.0.0 → 21.0.0
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/CHANGELOG.md +23 -0
- package/README.md +2 -2
- package/bin/browsertime.js +9 -3
- package/browserscripts/pageinfo/interactionToNextPaintInfo.js +170 -143
- package/browserscripts/timings/interactionToNextPaint.js +49 -137
- package/lib/chrome/webdriver/setupChromiumOptions.js +0 -9
- package/lib/core/engine/collector.js +11 -0
- package/lib/core/engine/command/actions.js +52 -0
- package/lib/core/engine/command/addText.js +48 -30
- package/lib/core/engine/command/android.js +43 -4
- package/lib/core/engine/command/cache.js +39 -2
- package/lib/core/engine/command/chromeDevToolsProtocol.js +51 -1
- package/lib/core/engine/command/chromeTrace.js +34 -0
- package/lib/core/engine/command/click.js +102 -52
- package/lib/core/engine/command/debug.js +19 -2
- package/lib/core/engine/command/element.js +66 -0
- package/lib/core/engine/command/geckoProfiler.js +41 -1
- package/lib/core/engine/command/javaScript.js +43 -20
- package/lib/core/engine/command/measure.js +147 -15
- package/lib/core/engine/command/meta.js +17 -0
- package/lib/core/engine/command/mouse/clickAndHold.js +56 -29
- package/lib/core/engine/command/mouse/contextClick.js +30 -11
- package/lib/core/engine/command/mouse/doubleClick.js +35 -11
- package/lib/core/engine/command/mouse/mouseMove.js +38 -16
- package/lib/core/engine/command/mouse/singleClick.js +187 -12
- package/lib/core/engine/command/navigation.js +31 -3
- package/lib/core/engine/command/screenshot.js +33 -0
- package/lib/core/engine/command/scroll.js +35 -13
- package/lib/core/engine/command/select.js +55 -36
- package/lib/core/engine/command/set.js +51 -36
- package/lib/core/engine/command/stopWatch.js +30 -9
- package/lib/core/engine/command/switch.js +49 -11
- package/lib/core/engine/command/wait.js +50 -25
- package/lib/core/engine/commands.js +267 -0
- package/lib/core/engine/context.js +81 -0
- package/lib/core/engine/iteration.js +20 -102
- package/lib/firefox/geckoProfiler.js +49 -1
- package/lib/firefox/webdriver/builder.js +4 -9
- package/lib/firefox/webdriver/firefox.js +1 -1
- package/lib/support/cli.js +7 -0
- package/lib/support/statistics.js +11 -1
- package/package.json +17 -7
- package/types/android/index.d.ts +70 -0
- package/types/android/index.d.ts.map +1 -0
- package/types/chrome/parseCpuTrace.d.ts +21 -0
- package/types/chrome/parseCpuTrace.d.ts.map +1 -0
- package/types/chrome/traceCategoriesParser.d.ts +2 -0
- package/types/chrome/traceCategoriesParser.d.ts.map +1 -0
- package/types/chrome/webdriver/traceUtilities.d.ts +8 -0
- package/types/chrome/webdriver/traceUtilities.d.ts.map +1 -0
- package/types/core/engine/command/action.d.ts +73 -0
- package/types/core/engine/command/action.d.ts.map +1 -0
- package/types/core/engine/command/actions.d.ts +38 -0
- package/types/core/engine/command/actions.d.ts.map +1 -0
- package/types/core/engine/command/addText.d.ts +68 -0
- package/types/core/engine/command/addText.d.ts.map +1 -0
- package/types/core/engine/command/android.d.ts +39 -0
- package/types/core/engine/command/android.d.ts.map +1 -0
- package/types/core/engine/command/cache.d.ts +53 -0
- package/types/core/engine/command/cache.d.ts.map +1 -0
- package/types/core/engine/command/chromeDevToolsProtocol.d.ts +61 -0
- package/types/core/engine/command/chromeDevToolsProtocol.d.ts.map +1 -0
- package/types/core/engine/command/chromeTrace.d.ts +45 -0
- package/types/core/engine/command/chromeTrace.d.ts.map +1 -0
- package/types/core/engine/command/click.d.ts +151 -0
- package/types/core/engine/command/click.d.ts.map +1 -0
- package/types/core/engine/command/debug.d.ts +28 -0
- package/types/core/engine/command/debug.d.ts.map +1 -0
- package/types/core/engine/command/element.d.ts +49 -0
- package/types/core/engine/command/element.d.ts.map +1 -0
- package/types/core/engine/command/geckoProfiler.d.ts +46 -0
- package/types/core/engine/command/geckoProfiler.d.ts.map +1 -0
- package/types/core/engine/command/javaScript.d.ts +63 -0
- package/types/core/engine/command/javaScript.d.ts.map +1 -0
- package/types/core/engine/command/measure.d.ts +194 -0
- package/types/core/engine/command/measure.d.ts.map +1 -0
- package/types/core/engine/command/meta.d.ts +23 -0
- package/types/core/engine/command/meta.d.ts.map +1 -0
- package/types/core/engine/command/mouse/clickAndHold.d.ts +82 -0
- package/types/core/engine/command/mouse/clickAndHold.d.ts.map +1 -0
- package/types/core/engine/command/mouse/contextClick.d.ts +44 -0
- package/types/core/engine/command/mouse/contextClick.d.ts.map +1 -0
- package/types/core/engine/command/mouse/doubleClick.d.ts +51 -0
- package/types/core/engine/command/mouse/doubleClick.d.ts.map +1 -0
- package/types/core/engine/command/mouse/index.d.ts +6 -0
- package/types/core/engine/command/mouse/index.d.ts.map +1 -0
- package/types/core/engine/command/mouse/mouseMove.d.ts +56 -0
- package/types/core/engine/command/mouse/mouseMove.d.ts.map +1 -0
- package/types/core/engine/command/mouse/singleClick.d.ts +115 -0
- package/types/core/engine/command/mouse/singleClick.d.ts.map +1 -0
- package/types/core/engine/command/navigation.d.ts +45 -0
- package/types/core/engine/command/navigation.d.ts.map +1 -0
- package/types/core/engine/command/screenshot.d.ts +33 -0
- package/types/core/engine/command/screenshot.d.ts.map +1 -0
- package/types/core/engine/command/scroll.d.ts +52 -0
- package/types/core/engine/command/scroll.d.ts.map +1 -0
- package/types/core/engine/command/select.d.ts +81 -0
- package/types/core/engine/command/select.d.ts.map +1 -0
- package/types/core/engine/command/set.d.ts +74 -0
- package/types/core/engine/command/set.d.ts.map +1 -0
- package/types/core/engine/command/stopWatch.d.ts +49 -0
- package/types/core/engine/command/stopWatch.d.ts.map +1 -0
- package/types/core/engine/command/switch.d.ts +77 -0
- package/types/core/engine/command/switch.d.ts.map +1 -0
- package/types/core/engine/command/util/lcpHighlightScript.d.ts +2 -0
- package/types/core/engine/command/util/lcpHighlightScript.d.ts.map +1 -0
- package/types/core/engine/command/util/lsHighlightScript.d.ts +2 -0
- package/types/core/engine/command/util/lsHighlightScript.d.ts.map +1 -0
- package/types/core/engine/command/wait.d.ts +74 -0
- package/types/core/engine/command/wait.d.ts.map +1 -0
- package/types/core/engine/commands.d.ts +161 -0
- package/types/core/engine/commands.d.ts.map +1 -0
- package/types/core/engine/context.d.ts +87 -0
- package/types/core/engine/context.d.ts.map +1 -0
- package/types/firefox/geckoProfiler.d.ts +11 -0
- package/types/firefox/geckoProfiler.d.ts.map +1 -0
- package/types/firefox/settings/geckoProfilerDefaults.d.ts +8 -0
- package/types/firefox/settings/geckoProfilerDefaults.d.ts.map +1 -0
- package/types/scripting.d.ts +2 -0
- package/types/support/engineUtils.d.ts +5 -0
- package/types/support/engineUtils.d.ts.map +1 -0
- package/types/support/errors.d.ts +15 -0
- package/types/support/errors.d.ts.map +1 -0
- package/types/support/fileUtil.d.ts +10 -0
- package/types/support/fileUtil.d.ts.map +1 -0
- package/types/support/filters.d.ts +7 -0
- package/types/support/filters.d.ts.map +1 -0
- package/types/support/getViewPort.d.ts +2 -0
- package/types/support/getViewPort.d.ts.map +1 -0
- package/types/support/pathToFolder.d.ts +2 -0
- package/types/support/pathToFolder.d.ts.map +1 -0
- package/types/support/storageManager.d.ts +17 -0
- package/types/support/storageManager.d.ts.map +1 -0
- package/types/support/tcpdump.d.ts +10 -0
- package/types/support/tcpdump.d.ts.map +1 -0
- package/types/support/userTiming.d.ts +2 -0
- package/types/support/userTiming.d.ts.map +1 -0
- package/types/support/util.d.ts +6 -0
- package/types/support/util.d.ts.map +1 -0
- package/types/video/defaults.d.ts +7 -0
- package/types/video/defaults.d.ts.map +1 -0
- package/types/video/postprocessing/finetune/addTextToVideo.d.ts +2 -0
- package/types/video/postprocessing/finetune/addTextToVideo.d.ts.map +1 -0
- package/types/video/postprocessing/finetune/convertFps.d.ts +2 -0
- package/types/video/postprocessing/finetune/convertFps.d.ts.map +1 -0
- package/types/video/postprocessing/finetune/getFont.d.ts +2 -0
- package/types/video/postprocessing/finetune/getFont.d.ts.map +1 -0
- package/types/video/postprocessing/finetune/getTimingMetrics.d.ts +2 -0
- package/types/video/postprocessing/finetune/getTimingMetrics.d.ts.map +1 -0
- package/types/video/postprocessing/finetune/index.d.ts +2 -0
- package/types/video/postprocessing/finetune/index.d.ts.map +1 -0
- package/types/video/postprocessing/finetune/removeOrange.d.ts +2 -0
- package/types/video/postprocessing/finetune/removeOrange.d.ts.map +1 -0
- package/types/video/postprocessing/visualmetrics/extraMetrics.d.ts +5 -0
- package/types/video/postprocessing/visualmetrics/extraMetrics.d.ts.map +1 -0
- package/types/video/postprocessing/visualmetrics/getVideoMetrics.d.ts +5 -0
- package/types/video/postprocessing/visualmetrics/getVideoMetrics.d.ts.map +1 -0
- package/types/video/postprocessing/visualmetrics/visualMetrics.d.ts +3 -0
- package/types/video/postprocessing/visualmetrics/visualMetrics.d.ts.map +1 -0
- package/types/video/screenRecording/android/recorder.d.ts +11 -0
- package/types/video/screenRecording/android/recorder.d.ts.map +1 -0
- package/types/video/screenRecording/desktop/convert.d.ts +2 -0
- package/types/video/screenRecording/desktop/convert.d.ts.map +1 -0
- package/types/video/screenRecording/desktop/desktopRecorder.d.ts +28 -0
- package/types/video/screenRecording/desktop/desktopRecorder.d.ts.map +1 -0
- package/types/video/screenRecording/desktop/ffmpegRecorder.d.ts +17 -0
- package/types/video/screenRecording/desktop/ffmpegRecorder.d.ts.map +1 -0
- package/types/video/screenRecording/desktop/osx/getSPDisplaysDataType.d.ts +2 -0
- package/types/video/screenRecording/desktop/osx/getSPDisplaysDataType.d.ts.map +1 -0
- package/types/video/screenRecording/desktop/osx/getScreen.d.ts +2 -0
- package/types/video/screenRecording/desktop/osx/getScreen.d.ts.map +1 -0
- package/types/video/screenRecording/firefox/firefoxWindowRecorder.d.ts +13 -0
- package/types/video/screenRecording/firefox/firefoxWindowRecorder.d.ts.map +1 -0
- package/types/video/screenRecording/ios/convertToMp4.d.ts +2 -0
- package/types/video/screenRecording/ios/convertToMp4.d.ts.map +1 -0
- package/types/video/screenRecording/ios/iosRecorder.d.ts +14 -0
- package/types/video/screenRecording/ios/iosRecorder.d.ts.map +1 -0
- package/types/video/screenRecording/iosSimulator/convertToMp4.d.ts +2 -0
- package/types/video/screenRecording/iosSimulator/convertToMp4.d.ts.map +1 -0
- package/types/video/screenRecording/iosSimulator/recorder.d.ts +9 -0
- package/types/video/screenRecording/iosSimulator/recorder.d.ts.map +1 -0
- package/types/video/screenRecording/recorder.d.ts +7 -0
- package/types/video/screenRecording/recorder.d.ts.map +1 -0
- package/types/video/screenRecording/setOrangeBackground.d.ts +2 -0
- package/types/video/screenRecording/setOrangeBackground.d.ts.map +1 -0
- package/types/video/video.d.ts +41 -0
- package/types/video/video.d.ts.map +1 -0
- package/browsersupport/firefox-profile/cert9.db +0 -0
- package/browsersupport/firefox-profile/chrome/userChrome.css +0 -4
- package/browsersupport/firefox-profile/key4.db +0 -0
- package/vendor/mac/x86/qvh +0 -0
- package/visualmetrics/__init__.py +0 -1
- package/visualmetrics/test_data/ms_000000.png +0 -0
- package/visualmetrics/test_data/ms_000920.png +0 -0
- package/visualmetrics/test_data/ms_001000.png +0 -0
- package/visualmetrics/test_data/ms_001080.png +0 -0
- package/visualmetrics/test_data/ms_001200.png +0 -0
- package/visualmetrics/test_data/ms_001240.png +0 -0
- package/visualmetrics/test_data/ms_001280.png +0 -0
- package/visualmetrics/test_data/ms_001360.png +0 -0
- package/visualmetrics/test_data/ms_001400.png +0 -0
- package/visualmetrics/test_data/ms_001520.png +0 -0
- package/visualmetrics/test_data/ms_002040.png +0 -0
- package/visualmetrics/test_data/ms_002600.png +0 -0
- package/visualmetrics/test_data/ms_003160.png +0 -0
- package/visualmetrics/test_data/ms_003720.png +0 -0
- package/visualmetrics/test_data/ms_004280.png +0 -0
- package/visualmetrics/test_data/ms_004880.png +0 -0
- package/visualmetrics/test_data/ms_005440.png +0 -0
- package/visualmetrics/test_data/ms_006000.png +0 -0
- package/visualmetrics/test_visualmetrics.py +0 -34
|
@@ -10,19 +10,31 @@ function addClick(js) {
|
|
|
10
10
|
return script;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Provides functionality to perform click actions on elements in a web page using various selectors.
|
|
15
|
+
*
|
|
16
|
+
* @class
|
|
17
|
+
* @hideconstructor
|
|
18
|
+
*/
|
|
13
19
|
export class Click {
|
|
14
20
|
constructor(browser, pageCompleteCheck) {
|
|
21
|
+
/**
|
|
22
|
+
* @private
|
|
23
|
+
*/
|
|
15
24
|
this.browser = browser;
|
|
25
|
+
/**
|
|
26
|
+
* @private
|
|
27
|
+
*/
|
|
16
28
|
this.pageCompleteCheck = pageCompleteCheck;
|
|
17
29
|
}
|
|
18
30
|
|
|
19
31
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @param {string} className
|
|
24
|
-
* @returns {Promise}
|
|
25
|
-
* @throws
|
|
32
|
+
* Clicks on an element identified by its class name.
|
|
33
|
+
*
|
|
34
|
+
* @async
|
|
35
|
+
* @param {string} className - The class name of the element to click.
|
|
36
|
+
* @returns {Promise<void>} A promise that resolves when the click action is performed.
|
|
37
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
26
38
|
*/
|
|
27
39
|
async byClassName(className) {
|
|
28
40
|
try {
|
|
@@ -36,10 +48,12 @@ export class Click {
|
|
|
36
48
|
}
|
|
37
49
|
|
|
38
50
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* @
|
|
42
|
-
* @
|
|
51
|
+
* Clicks on an element identified by its class name and waits for the page complete check to finish.
|
|
52
|
+
*
|
|
53
|
+
* @async
|
|
54
|
+
* @param {string} className - The class name of the element to click.
|
|
55
|
+
* @returns {Promise<void>} A promise that resolves when the click action and page complete check are finished.
|
|
56
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
43
57
|
*/
|
|
44
58
|
async byClassNameAndWait(className) {
|
|
45
59
|
try {
|
|
@@ -54,10 +68,12 @@ export class Click {
|
|
|
54
68
|
}
|
|
55
69
|
|
|
56
70
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* @
|
|
60
|
-
* @
|
|
71
|
+
* Clicks on a link whose visible text matches the given string.
|
|
72
|
+
*
|
|
73
|
+
* @async
|
|
74
|
+
* @param {string} text - The visible text of the link to click.
|
|
75
|
+
* @returns {Promise<void>} A promise that resolves when the click action is performed.
|
|
76
|
+
* @throws {Error} Throws an error if the link is not found.
|
|
61
77
|
*/
|
|
62
78
|
async byLinkText(text) {
|
|
63
79
|
try {
|
|
@@ -71,10 +87,12 @@ export class Click {
|
|
|
71
87
|
}
|
|
72
88
|
|
|
73
89
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* @
|
|
77
|
-
* @
|
|
90
|
+
* Clicks on a link whose visible text matches the given string and waits for the page complete check to finish.
|
|
91
|
+
*
|
|
92
|
+
* @async
|
|
93
|
+
* @param {string} text - The visible text of the link to click.
|
|
94
|
+
* @returns {Promise<void>} A promise that resolves when the click action and page complete check are finished.
|
|
95
|
+
* @throws {Error} Throws an error if the link is not found.
|
|
78
96
|
*/
|
|
79
97
|
async byLinkTextAndWait(text) {
|
|
80
98
|
try {
|
|
@@ -88,10 +106,12 @@ export class Click {
|
|
|
88
106
|
}
|
|
89
107
|
|
|
90
108
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* @
|
|
94
|
-
* @
|
|
109
|
+
* Clicks on a link whose visible text contains the given substring.
|
|
110
|
+
*
|
|
111
|
+
* @async
|
|
112
|
+
* @param {string} text - The substring of the visible text of the link to click.
|
|
113
|
+
* @returns {Promise<void>} A promise that resolves when the click action is performed.
|
|
114
|
+
* @throws {Error} Throws an error if the link is not found.
|
|
95
115
|
*/
|
|
96
116
|
async byPartialLinkText(text) {
|
|
97
117
|
try {
|
|
@@ -105,10 +125,12 @@ export class Click {
|
|
|
105
125
|
}
|
|
106
126
|
|
|
107
127
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* @
|
|
111
|
-
* @
|
|
128
|
+
* Clicks on a link whose visible text contains the given substring and waits for the page complete check to finish.
|
|
129
|
+
*
|
|
130
|
+
* @async
|
|
131
|
+
* @param {string} text - The substring of the visible text of the link to click.
|
|
132
|
+
* @returns {Promise<void>} A promise that resolves when the click action and page complete check are finished.
|
|
133
|
+
* @throws {Error} Throws an error if the link is not found.
|
|
112
134
|
*/
|
|
113
135
|
async byPartialLinkTextAndWait(text) {
|
|
114
136
|
try {
|
|
@@ -120,11 +142,14 @@ export class Click {
|
|
|
120
142
|
throw new Error('Could not find link by partial text ' + text);
|
|
121
143
|
}
|
|
122
144
|
}
|
|
145
|
+
|
|
123
146
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* @
|
|
127
|
-
* @
|
|
147
|
+
* Clicks on an element that matches a given XPath selector.
|
|
148
|
+
*
|
|
149
|
+
* @async
|
|
150
|
+
* @param {string} xpath - The XPath selector of the element to click.
|
|
151
|
+
* @returns {Promise<void>} A promise that resolves when the click action is performed.
|
|
152
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
128
153
|
*/
|
|
129
154
|
async byXpath(xpath) {
|
|
130
155
|
try {
|
|
@@ -138,12 +163,13 @@ export class Click {
|
|
|
138
163
|
throw new Error('Could not find element by xpath ' + xpath);
|
|
139
164
|
}
|
|
140
165
|
}
|
|
141
|
-
|
|
142
|
-
*
|
|
166
|
+
/**
|
|
167
|
+
* Clicks on an element that matches a given XPath selector and waits for the page complete check to finish.
|
|
143
168
|
*
|
|
144
|
-
* @
|
|
145
|
-
* @
|
|
146
|
-
* @
|
|
169
|
+
* @async
|
|
170
|
+
* @param {string} xpath - The XPath selector of the element to click.
|
|
171
|
+
* @returns {Promise<void>} A promise that resolves when the click action and page complete check are finished.
|
|
172
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
147
173
|
*/
|
|
148
174
|
async byXpathAndWait(xpath) {
|
|
149
175
|
try {
|
|
@@ -160,10 +186,12 @@ export class Click {
|
|
|
160
186
|
}
|
|
161
187
|
|
|
162
188
|
/**
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
* @
|
|
166
|
-
* @
|
|
189
|
+
* Clicks on an element located by evaluating a JavaScript expression.
|
|
190
|
+
*
|
|
191
|
+
* @async
|
|
192
|
+
* @param {string} js - The JavaScript expression that evaluates to an element or list of elements.
|
|
193
|
+
* @returns {Promise<void>} A promise that resolves when the click action is performed.
|
|
194
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
167
195
|
*/
|
|
168
196
|
async byJs(js) {
|
|
169
197
|
try {
|
|
@@ -177,10 +205,12 @@ export class Click {
|
|
|
177
205
|
}
|
|
178
206
|
|
|
179
207
|
/**
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* @
|
|
183
|
-
* @
|
|
208
|
+
* Clicks on an element located by evaluating a JavaScript expression and waits for the page complete check to finish.
|
|
209
|
+
*
|
|
210
|
+
* @async
|
|
211
|
+
* @param {string} js - The JavaScript expression that evaluates to an element or list of elements.
|
|
212
|
+
* @returns {Promise<void>} A promise that resolves when the click action and page complete check are finished.
|
|
213
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
184
214
|
*/
|
|
185
215
|
async byJsAndWait(js) {
|
|
186
216
|
try {
|
|
@@ -195,10 +225,12 @@ export class Click {
|
|
|
195
225
|
}
|
|
196
226
|
|
|
197
227
|
/**
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
* @
|
|
201
|
-
* @
|
|
228
|
+
* Clicks on an element located by its ID.
|
|
229
|
+
*
|
|
230
|
+
* @async
|
|
231
|
+
* @param {string} id - The ID of the element to click.
|
|
232
|
+
* @returns {Promise<void>} A promise that resolves when the click action is performed.
|
|
233
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
202
234
|
*/
|
|
203
235
|
async byId(id) {
|
|
204
236
|
try {
|
|
@@ -212,10 +244,12 @@ export class Click {
|
|
|
212
244
|
}
|
|
213
245
|
|
|
214
246
|
/**
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
* @
|
|
218
|
-
* @
|
|
247
|
+
* Clicks on an element located by its name attribute.
|
|
248
|
+
*
|
|
249
|
+
* @async
|
|
250
|
+
* @param {string} name - The name attribute of the element to click.
|
|
251
|
+
* @returns {Promise<void>} A promise that resolves when the click action is performed.
|
|
252
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
219
253
|
*/
|
|
220
254
|
async byName(name) {
|
|
221
255
|
try {
|
|
@@ -231,7 +265,7 @@ export class Click {
|
|
|
231
265
|
/**
|
|
232
266
|
* Click on link located by the ID attribute. Uses document.getElementById() to find the element. And wait for page complete check to finish.
|
|
233
267
|
* @param {string} id
|
|
234
|
-
* @returns {Promise} Promise object represents when the element has been clicked and the pageCompleteCheck has finished.
|
|
268
|
+
* @returns {Promise<void>} Promise object represents when the element has been clicked and the pageCompleteCheck has finished.
|
|
235
269
|
* @throws Will throw an error if the element is not found
|
|
236
270
|
*/
|
|
237
271
|
async byIdAndWait(id) {
|
|
@@ -246,6 +280,14 @@ export class Click {
|
|
|
246
280
|
}
|
|
247
281
|
}
|
|
248
282
|
|
|
283
|
+
/**
|
|
284
|
+
* Clicks on an element located by its CSS selector.
|
|
285
|
+
*
|
|
286
|
+
* @async
|
|
287
|
+
* @param {string} selector - The CSS selector of the element to click.
|
|
288
|
+
* @returns {Promise<void>} A promise that resolves when the click action is performed.
|
|
289
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
290
|
+
*/
|
|
249
291
|
async bySelector(selector) {
|
|
250
292
|
try {
|
|
251
293
|
const script = `document.querySelector('${selector}').click();`;
|
|
@@ -257,6 +299,14 @@ export class Click {
|
|
|
257
299
|
}
|
|
258
300
|
}
|
|
259
301
|
|
|
302
|
+
/**
|
|
303
|
+
* Clicks on an element located by its CSS selector and waits for the page complete check to finish.
|
|
304
|
+
*
|
|
305
|
+
* @async
|
|
306
|
+
* @param {string} selector - The CSS selector of the element to click.
|
|
307
|
+
* @returns {Promise<void>} A promise that resolves when the click action and page complete check are finished.
|
|
308
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
309
|
+
*/
|
|
260
310
|
async bySelectorAndWait(selector) {
|
|
261
311
|
try {
|
|
262
312
|
const script = `document.querySelector('${selector}').click();`;
|
|
@@ -2,15 +2,32 @@ import intel from 'intel';
|
|
|
2
2
|
const log = intel.getLogger('browsertime.command.debug');
|
|
3
3
|
const delay = ms => new Promise(res => setTimeout(res, ms));
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Provides debugging capabilities within a browser automation script.
|
|
7
|
+
* It allows setting breakpoints to pause script execution and inspect the current state.
|
|
8
|
+
*
|
|
9
|
+
* @class
|
|
10
|
+
* @hideconstructor
|
|
11
|
+
*/
|
|
5
12
|
export class Debug {
|
|
6
13
|
constructor(browser, options) {
|
|
14
|
+
/**
|
|
15
|
+
* @private
|
|
16
|
+
*/
|
|
7
17
|
this.browser = browser;
|
|
18
|
+
/**
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
8
21
|
this.options = options;
|
|
9
22
|
}
|
|
10
23
|
|
|
11
24
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
25
|
+
* Adds a breakpoint to the script. The browser will pause at the breakpoint, waiting for user input to continue.
|
|
26
|
+
* This is useful for debugging and inspecting the browser state at a specific point in the script.
|
|
27
|
+
*
|
|
28
|
+
* @async
|
|
29
|
+
* @param {string} [name] - An optional name for the breakpoint for logging purposes.
|
|
30
|
+
* @returns {Promise<void>} A promise that resolves when the user chooses to continue from the breakpoint.
|
|
14
31
|
*/
|
|
15
32
|
async breakpoint(name) {
|
|
16
33
|
if (this.options.debug) {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// We disable these because they are needed for code completion
|
|
2
|
+
/* eslint no-unused-vars: "off" */
|
|
3
|
+
import { By, WebElement } from 'selenium-webdriver';
|
|
4
|
+
/**
|
|
5
|
+
* This class provides a way to get hokld of Seleniums WebElements.
|
|
6
|
+
* @class
|
|
7
|
+
* @hideconstructor
|
|
8
|
+
*/
|
|
9
|
+
export class Element {
|
|
10
|
+
constructor(browser) {
|
|
11
|
+
/**
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
this.driver = browser.getDriver();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Finds an element by its CSS selector.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} name - The CSS selector of the element.
|
|
21
|
+
* @returns {Promise<WebElement>} A promise that resolves to the WebElement found.
|
|
22
|
+
*/
|
|
23
|
+
async getByCss(name) {
|
|
24
|
+
return this.driver.findElement(By.css(name));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Finds an element by its ID.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} id - The ID of the element.
|
|
31
|
+
* @returns {Promise<WebElement>} A promise that resolves to the WebElement found.
|
|
32
|
+
*/
|
|
33
|
+
async getById(id) {
|
|
34
|
+
return this.driver.findElement(By.id(id));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Finds an element by its XPath.
|
|
39
|
+
*
|
|
40
|
+
* @param {string} xpath - The XPath query of the element.
|
|
41
|
+
* @returns {Promise<WebElement>} A promise that resolves to the WebElement found.
|
|
42
|
+
*/
|
|
43
|
+
async getByXpath(xpath) {
|
|
44
|
+
return this.driver.findElement(By.xpath(xpath));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Finds an element by its class name.
|
|
49
|
+
*
|
|
50
|
+
* @param {string} className - The class name of the element.
|
|
51
|
+
* @returns {Promise<WebElement>} A promise that resolves to the WebElement found.
|
|
52
|
+
*/
|
|
53
|
+
async getByClassName(className) {
|
|
54
|
+
return this.driver.findElement(By.className(className));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Finds an element by its name attribute.
|
|
59
|
+
*
|
|
60
|
+
* @param {string} name - The name attribute of the element.
|
|
61
|
+
* @returns {Promise<WebElement>} A promise that resolves to the WebElement found.
|
|
62
|
+
*/
|
|
63
|
+
async getByName(name) {
|
|
64
|
+
return this.driver.findElement(By.name(name));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -1,14 +1,43 @@
|
|
|
1
1
|
import intel from 'intel';
|
|
2
2
|
const log = intel.getLogger('browsertime.command.geckoprofiler');
|
|
3
|
+
/**
|
|
4
|
+
* Manages the Gecko Profiler for profiling Firefox performance.
|
|
5
|
+
*
|
|
6
|
+
* @class
|
|
7
|
+
* @hideconstructor
|
|
8
|
+
*/
|
|
9
|
+
|
|
3
10
|
export class GeckoProfiler {
|
|
4
11
|
constructor(GeckoProfiler, browser, index, options, result) {
|
|
12
|
+
/**
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
5
15
|
this.GeckoProfiler = GeckoProfiler;
|
|
16
|
+
/**
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
6
19
|
this.browser = browser;
|
|
20
|
+
/**
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
7
23
|
this.index = index;
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
8
27
|
this.options = options;
|
|
28
|
+
/**
|
|
29
|
+
* @private
|
|
30
|
+
*/
|
|
9
31
|
this.result = result;
|
|
10
32
|
}
|
|
11
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Starts the Gecko Profiler.
|
|
36
|
+
*
|
|
37
|
+
* @async
|
|
38
|
+
* @returns {Promise<void>} A promise that resolves when the profiler is started.
|
|
39
|
+
* @throws {Error} Throws an error if not running Firefox or if the configuration is not set for custom profiling.
|
|
40
|
+
*/
|
|
12
41
|
async start() {
|
|
13
42
|
if (this.options.browser === 'firefox') {
|
|
14
43
|
if (this.options.firefox.geckoProfilerRecordingType === 'custom') {
|
|
@@ -23,10 +52,21 @@ export class GeckoProfiler {
|
|
|
23
52
|
}
|
|
24
53
|
}
|
|
25
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Stops the Gecko Profiler and processes the collected data.
|
|
57
|
+
*
|
|
58
|
+
* @async
|
|
59
|
+
* @returns {Promise<void>} A promise that resolves when the profiler is stopped and the data is processed.
|
|
60
|
+
* @throws {Error} Throws an error if not running Firefox or if custom profiling was not started.
|
|
61
|
+
*/
|
|
26
62
|
async stop() {
|
|
27
63
|
if (this.options.browser === 'firefox') {
|
|
28
64
|
if (this.options.firefox.geckoProfilerRecordingType === 'custom') {
|
|
29
|
-
return this.GeckoProfiler.stop(
|
|
65
|
+
return this.GeckoProfiler.stop(
|
|
66
|
+
this.index,
|
|
67
|
+
this.result[0].url,
|
|
68
|
+
this.result
|
|
69
|
+
);
|
|
30
70
|
}
|
|
31
71
|
} else {
|
|
32
72
|
throw new Error('Geckoprofiler only works in Firefox');
|
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
import intel from 'intel';
|
|
2
2
|
const log = intel.getLogger('browsertime.command.javascript');
|
|
3
|
+
/**
|
|
4
|
+
* Provides functionality to execute JavaScript code in the context of the current page.
|
|
5
|
+
*
|
|
6
|
+
* @class
|
|
7
|
+
* @hideconstructor
|
|
8
|
+
*/
|
|
9
|
+
|
|
3
10
|
export class JavaScript {
|
|
4
11
|
constructor(browser, pageCompleteCheck) {
|
|
12
|
+
/**
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
5
15
|
this.browser = browser;
|
|
16
|
+
/**
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
6
19
|
this.pageCompleteCheck = pageCompleteCheck;
|
|
7
20
|
}
|
|
8
21
|
|
|
9
22
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @
|
|
13
|
-
* @
|
|
23
|
+
* Executes a JavaScript script.
|
|
24
|
+
*
|
|
25
|
+
* @async
|
|
26
|
+
* @param {string} js - The JavaScript code to execute.
|
|
27
|
+
* @returns {Promise<*>} A promise that resolves with the result of the executed script.
|
|
28
|
+
* @throws {Error} Throws an error if the JavaScript cannot be executed.
|
|
14
29
|
*/
|
|
15
30
|
async run(js) {
|
|
16
31
|
try {
|
|
@@ -24,10 +39,12 @@ export class JavaScript {
|
|
|
24
39
|
}
|
|
25
40
|
|
|
26
41
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @
|
|
30
|
-
* @
|
|
42
|
+
* Executes a JavaScript script and waits for the page complete check to finish.
|
|
43
|
+
*
|
|
44
|
+
* @async
|
|
45
|
+
* @param {string} js - The JavaScript code to execute.
|
|
46
|
+
* @returns {Promise<*>} A promise that resolves with the result of the executed script and the completion of the page load.
|
|
47
|
+
* @throws {Error} Throws an error if the JavaScript cannot be executed.
|
|
31
48
|
*/
|
|
32
49
|
async runAndWait(js) {
|
|
33
50
|
try {
|
|
@@ -41,10 +58,12 @@ export class JavaScript {
|
|
|
41
58
|
}
|
|
42
59
|
|
|
43
60
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* @
|
|
47
|
-
* @
|
|
61
|
+
* Executes synchronous privileged JavaScript.
|
|
62
|
+
*
|
|
63
|
+
* @async
|
|
64
|
+
* @param {string} js - The privileged JavaScript code to execute.
|
|
65
|
+
* @returns {Promise<*>} A promise that resolves with the result of the executed privileged script.
|
|
66
|
+
* @throws {Error} Throws an error if the privileged JavaScript cannot be executed.
|
|
48
67
|
*/
|
|
49
68
|
async runPrivileged(js) {
|
|
50
69
|
try {
|
|
@@ -61,10 +80,12 @@ export class JavaScript {
|
|
|
61
80
|
}
|
|
62
81
|
|
|
63
82
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* @
|
|
67
|
-
* @
|
|
83
|
+
* Executes synchronous privileged JavaScript and waits for the page complete check to finish.
|
|
84
|
+
*
|
|
85
|
+
* @async
|
|
86
|
+
* @param {string} js - The privileged JavaScript code to execute.
|
|
87
|
+
* @returns {Promise<*>} A promise that resolves with the result of the executed privileged script and the completion of the page load.
|
|
88
|
+
* @throws {Error} Throws an error if the privileged JavaScript cannot be executed.
|
|
68
89
|
*/
|
|
69
90
|
async runPrivilegedAndWait(js) {
|
|
70
91
|
try {
|
|
@@ -78,10 +99,12 @@ export class JavaScript {
|
|
|
78
99
|
}
|
|
79
100
|
|
|
80
101
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* @
|
|
84
|
-
* @
|
|
102
|
+
* Executes asynchronous privileged JavaScript.
|
|
103
|
+
*
|
|
104
|
+
* @async
|
|
105
|
+
* @param {string} js - The asynchronous privileged JavaScript code to execute.
|
|
106
|
+
* @returns {Promise<*>} A promise that resolves with the result of the executed asynchronous privileged script.
|
|
107
|
+
* @throws {Error} Throws an error if the asynchronous privileged JavaScript cannot be executed.
|
|
85
108
|
*/
|
|
86
109
|
async runPrivilegedAsync(js) {
|
|
87
110
|
try {
|