browsertime 20.0.0 → 21.1.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 +30 -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/getViewPort.js +6 -1
- package/lib/support/statistics.js +11 -1
- package/package.json +22 -12
- 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
|
@@ -27,6 +27,13 @@ function getNewResult() {
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* A measurement tool for browser-based metrics, handling various aspects
|
|
32
|
+
* of metric collection including navigation, video recording, and data collection.
|
|
33
|
+
*
|
|
34
|
+
* @class
|
|
35
|
+
* @hideconstructor
|
|
36
|
+
*/
|
|
30
37
|
export class Measure {
|
|
31
38
|
constructor(
|
|
32
39
|
browser,
|
|
@@ -44,33 +51,104 @@ export class Measure {
|
|
|
44
51
|
screenshotManager,
|
|
45
52
|
options
|
|
46
53
|
) {
|
|
54
|
+
/**
|
|
55
|
+
* @private
|
|
56
|
+
*/
|
|
47
57
|
this.browser = browser;
|
|
58
|
+
/**
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
48
61
|
this.pageCompleteCheck = pageCompleteCheck;
|
|
62
|
+
/**
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
49
65
|
this.index = index;
|
|
66
|
+
/**
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
50
69
|
this.result = result;
|
|
70
|
+
/**
|
|
71
|
+
* @private
|
|
72
|
+
*/
|
|
51
73
|
this.engineDelegate = engineDelegate;
|
|
74
|
+
/**
|
|
75
|
+
* @private
|
|
76
|
+
*/
|
|
52
77
|
this.options = options;
|
|
78
|
+
/**
|
|
79
|
+
* @private
|
|
80
|
+
*/
|
|
53
81
|
this.screenshotManager = screenshotManager;
|
|
82
|
+
/**
|
|
83
|
+
* @private
|
|
84
|
+
*/
|
|
54
85
|
this.storageManager = storageManager;
|
|
86
|
+
/**
|
|
87
|
+
* @private
|
|
88
|
+
*/
|
|
55
89
|
this.recordVideo = options.visualMetrics || options.video;
|
|
90
|
+
/**
|
|
91
|
+
* @private
|
|
92
|
+
*/
|
|
56
93
|
this.extensionServer = extensionServer;
|
|
94
|
+
/**
|
|
95
|
+
* @private
|
|
96
|
+
*/
|
|
57
97
|
this.videos = videos;
|
|
98
|
+
/**
|
|
99
|
+
* @private
|
|
100
|
+
*/
|
|
58
101
|
this.scriptsByCategory = scriptsByCategory;
|
|
102
|
+
/**
|
|
103
|
+
* @private
|
|
104
|
+
*/
|
|
59
105
|
this.asyncScriptsByCategory = asyncScriptsByCategory;
|
|
106
|
+
/**
|
|
107
|
+
* @private
|
|
108
|
+
*/
|
|
60
109
|
this.postURLScripts = postURLScripts;
|
|
110
|
+
/**
|
|
111
|
+
* @private
|
|
112
|
+
*/
|
|
61
113
|
this.context = context;
|
|
114
|
+
/**
|
|
115
|
+
* @private
|
|
116
|
+
*/
|
|
62
117
|
this.numberOfMeasuredPages = 0;
|
|
118
|
+
/**
|
|
119
|
+
* @private
|
|
120
|
+
*/
|
|
63
121
|
this.numberOfVisitedPages = 0;
|
|
122
|
+
/**
|
|
123
|
+
* @private
|
|
124
|
+
*/
|
|
64
125
|
this.areWeMeasuring = false;
|
|
126
|
+
/**
|
|
127
|
+
* @private
|
|
128
|
+
*/
|
|
65
129
|
this.testedURLs = {};
|
|
130
|
+
/**
|
|
131
|
+
* @private
|
|
132
|
+
*/
|
|
66
133
|
this.tcpDump = new TCPDump(storageManager.directory, options);
|
|
67
|
-
|
|
134
|
+
/**
|
|
135
|
+
* @private
|
|
136
|
+
*/
|
|
68
137
|
this.ANDROID_DELAY_TIME = get(options, 'orangeAndroidDelayTime', 2000);
|
|
138
|
+
/**
|
|
139
|
+
* @private
|
|
140
|
+
*/
|
|
69
141
|
this.IOS_DELAY_TIME = get(options, 'orangeIosDelayTime', 1000);
|
|
142
|
+
/**
|
|
143
|
+
* @private
|
|
144
|
+
*/
|
|
70
145
|
this.DESKTOP_DELAY_TIME = get(options, 'orangeDesktopDelayTime', 800);
|
|
71
146
|
}
|
|
72
147
|
|
|
73
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Have a consistent way of starting the video
|
|
150
|
+
* @private
|
|
151
|
+
*/
|
|
74
152
|
async _startVideo(numberOfMeasuredPages, index) {
|
|
75
153
|
this.video = new Video(this.storageManager, this.options, this.browser);
|
|
76
154
|
|
|
@@ -95,6 +173,10 @@ export class Measure {
|
|
|
95
173
|
}
|
|
96
174
|
}
|
|
97
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Have a consistent way of starting stopping the video
|
|
178
|
+
* @private
|
|
179
|
+
*/
|
|
98
180
|
async _stopVideo(url) {
|
|
99
181
|
if (this.recordVideo && !this.options.videoParams.debug) {
|
|
100
182
|
await this.video.stop(url);
|
|
@@ -102,6 +184,10 @@ export class Measure {
|
|
|
102
184
|
}
|
|
103
185
|
}
|
|
104
186
|
|
|
187
|
+
/**
|
|
188
|
+
* Have a consistent way of adding an error
|
|
189
|
+
* @private
|
|
190
|
+
*/
|
|
105
191
|
_error(message) {
|
|
106
192
|
// If we already are measuring a page, associate the error woth that page
|
|
107
193
|
if (this.areWeMeasuring === true) {
|
|
@@ -126,6 +212,10 @@ export class Measure {
|
|
|
126
212
|
}
|
|
127
213
|
}
|
|
128
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Have a consistent way of adding an failure
|
|
217
|
+
* @private
|
|
218
|
+
*/
|
|
129
219
|
_failure(message) {
|
|
130
220
|
log.debug('Mark run as failure with message %s', message);
|
|
131
221
|
this.result.markedAsFailure = 1;
|
|
@@ -136,6 +226,19 @@ export class Measure {
|
|
|
136
226
|
}
|
|
137
227
|
}
|
|
138
228
|
|
|
229
|
+
/**
|
|
230
|
+
* Navigates to a specified URL and handles additional setup for the first page visit.
|
|
231
|
+
*
|
|
232
|
+
* This function is responsible for setting up the browser with necessary configurations and
|
|
233
|
+
* navigating to the URL. It also waits for the page
|
|
234
|
+
* to load completely based on configured page completion check.
|
|
235
|
+
*
|
|
236
|
+
* @async
|
|
237
|
+
* @private
|
|
238
|
+
* @param {string} url - The URL to navigate to.
|
|
239
|
+
* @throws {Error} Throws an error if navigation or setup fails.
|
|
240
|
+
* @returns {Promise<void>} A promise that resolves when the navigation and setup are complete.
|
|
241
|
+
*/
|
|
139
242
|
async _navigate(url) {
|
|
140
243
|
log.info('Navigating to url %s iteration %s', url, this.index);
|
|
141
244
|
if (this.numberOfVisitedPages === 0) {
|
|
@@ -162,12 +265,24 @@ export class Measure {
|
|
|
162
265
|
}
|
|
163
266
|
|
|
164
267
|
/**
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
268
|
+
* Starts the measurement process for a given URL or an alias.
|
|
269
|
+
*
|
|
270
|
+
* It supports starting measurements by either directly providing a URL or using an alias.
|
|
271
|
+
* If a URL is provided, it navigates to that URL and performs the measurement.
|
|
272
|
+
* If an alias is provided, or no URL is available, it sets up the environment for a user-driven navigation.
|
|
273
|
+
*
|
|
274
|
+
* @async
|
|
275
|
+
* @example
|
|
276
|
+
* await commands.measure.start('https://www.example.org');
|
|
277
|
+
* // Or start the measurement and click on a link
|
|
278
|
+
* await commands.measure.start();
|
|
279
|
+
* await commands.click.byLinkTextAndWait('Documentation');
|
|
280
|
+
* // Remember to stop the measurements if you do not provide a URL
|
|
281
|
+
* await commands.measure.stop();
|
|
282
|
+
* @param {string} urlOrAlias - The URL to navigate to, or an alias representing the test.
|
|
283
|
+
* @param {string} [optionalAlias] - An optional alias that can be used if the first parameter is a URL.
|
|
284
|
+
* @throws {Error} Throws an error if navigation fails or if there are issues in the setup process.
|
|
285
|
+
* @returns {Promise<void>} A promise that resolves when the start process is complete, or rejects if there are errors.
|
|
171
286
|
*/
|
|
172
287
|
async start(urlOrAlias, optionalAlias) {
|
|
173
288
|
let url, alias;
|
|
@@ -258,8 +373,14 @@ export class Measure {
|
|
|
258
373
|
}
|
|
259
374
|
|
|
260
375
|
/**
|
|
261
|
-
*
|
|
262
|
-
*
|
|
376
|
+
* Stops the measurement process, collects metrics, and handles any post-measurement tasks.
|
|
377
|
+
* It finalizes the URL being tested, manages any URL-specific metadata, stops any ongoing video recordings,
|
|
378
|
+
* and initiates the data collection process.
|
|
379
|
+
*
|
|
380
|
+
* @async
|
|
381
|
+
* @param {string} testedStartUrl - The URL that was initially tested. If not provided, it will be obtained from the browser.
|
|
382
|
+
* @throws {Error} Throws an error if there are issues in stopping the measurement or collecting data.
|
|
383
|
+
* @returns {Promise} A promise that resolves with the collected metrics data.
|
|
263
384
|
*/
|
|
264
385
|
async stop(testedStartUrl) {
|
|
265
386
|
log.debug('Stop measuring');
|
|
@@ -326,9 +447,12 @@ export class Measure {
|
|
|
326
447
|
}
|
|
327
448
|
|
|
328
449
|
/**
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
450
|
+
* Adds a custom metric to the current measurement result.
|
|
451
|
+
* This method should be called after a measurement has started and before it has stopped.
|
|
452
|
+
*
|
|
453
|
+
* @param {string} name - The name of the metric.
|
|
454
|
+
* @param {*} value - The value of the metric.
|
|
455
|
+
* @throws {Error} Throws an error if called before a measurement cycle has started.
|
|
332
456
|
*/
|
|
333
457
|
add(name, value) {
|
|
334
458
|
if (this.result[this.numberOfMeasuredPages - 1]) {
|
|
@@ -341,8 +465,12 @@ export class Measure {
|
|
|
341
465
|
}
|
|
342
466
|
|
|
343
467
|
/**
|
|
344
|
-
*
|
|
345
|
-
*
|
|
468
|
+
* Adds multiple custom metrics to the current measurement result.
|
|
469
|
+
* This method accepts an object containing multiple key-value pairs representing different metrics.
|
|
470
|
+
* Similar to `add`, it should be used within an active measurement cycle.
|
|
471
|
+
*
|
|
472
|
+
* @param {Object} object - An object containing key-value pairs of metrics to add.
|
|
473
|
+
* @throws {Error} Throws an error if called before a measurement cycle has started.
|
|
346
474
|
*/
|
|
347
475
|
addObject(object) {
|
|
348
476
|
if (this.result[this.numberOfMeasuredPages - 1]) {
|
|
@@ -353,6 +481,10 @@ export class Measure {
|
|
|
353
481
|
);
|
|
354
482
|
}
|
|
355
483
|
|
|
484
|
+
/**
|
|
485
|
+
*
|
|
486
|
+
* @private
|
|
487
|
+
*/
|
|
356
488
|
async collect(url) {
|
|
357
489
|
if (this.options.tcpdump) {
|
|
358
490
|
await this.tcpDump.stop();
|
|
@@ -1,9 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add meta data to your user journey.
|
|
3
|
+
*
|
|
4
|
+
* @class
|
|
5
|
+
* @hideconstructor
|
|
6
|
+
*/
|
|
1
7
|
export class Meta {
|
|
2
8
|
constructor() {}
|
|
3
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Sets the description for the user journey.
|
|
12
|
+
* @example commands.meta.setDescription('My test');
|
|
13
|
+
* @param {string} text - The text to set as the description.
|
|
14
|
+
*/
|
|
4
15
|
setDescription(text) {
|
|
5
16
|
this.description = text;
|
|
6
17
|
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Sets the title for the user journey.
|
|
21
|
+
* @example commands.meta.setTitle('Test title');
|
|
22
|
+
* @param {string} text - The text to set as the title.
|
|
23
|
+
*/
|
|
7
24
|
setTitle(text) {
|
|
8
25
|
this.title = text;
|
|
9
26
|
}
|
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
import intel from 'intel';
|
|
2
2
|
import { By, Origin } from 'selenium-webdriver';
|
|
3
3
|
const log = intel.getLogger('browsertime.command.mouse');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Provides functionality to click and hold elements on a web page using different strategies.
|
|
7
|
+
*
|
|
8
|
+
* @class
|
|
9
|
+
* @hideconstructor
|
|
10
|
+
*/
|
|
4
11
|
export class ClickAndHold {
|
|
5
12
|
constructor(browser) {
|
|
13
|
+
/**
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
6
16
|
this.driver = browser.getDriver();
|
|
17
|
+
/**
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
7
20
|
this.actions = this.driver.actions({ async: true });
|
|
8
21
|
}
|
|
9
22
|
|
|
10
23
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @
|
|
14
|
-
* @
|
|
24
|
+
* Clicks and holds on an element that matches a given XPath selector.
|
|
25
|
+
*
|
|
26
|
+
* @async
|
|
27
|
+
* @param {string} xpath - The XPath selector of the element to interact with.
|
|
28
|
+
* @returns {Promise<void>} A promise that resolves when the action is performed.
|
|
29
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
15
30
|
*/
|
|
16
31
|
async byXpath(xpath) {
|
|
17
32
|
try {
|
|
@@ -27,10 +42,12 @@ export class ClickAndHold {
|
|
|
27
42
|
}
|
|
28
43
|
|
|
29
44
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @
|
|
33
|
-
* @
|
|
45
|
+
* Clicks and holds on an element that matches a given CSS selector.
|
|
46
|
+
*
|
|
47
|
+
* @async
|
|
48
|
+
* @param {string} selector - The CSS selector of the element to interact with.
|
|
49
|
+
* @returns {Promise<void>} A promise that resolves when the action is performed.
|
|
50
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
34
51
|
*/
|
|
35
52
|
async bySelector(selector) {
|
|
36
53
|
try {
|
|
@@ -49,9 +66,11 @@ export class ClickAndHold {
|
|
|
49
66
|
}
|
|
50
67
|
|
|
51
68
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* @
|
|
69
|
+
* Clicks and holds at the current cursor position.
|
|
70
|
+
*
|
|
71
|
+
* @async
|
|
72
|
+
* @returns {Promise<void>} A promise that resolves when the action is performed.
|
|
73
|
+
* @throws {Error} Throws an error if the action cannot be performed.
|
|
55
74
|
*/
|
|
56
75
|
async atCursor() {
|
|
57
76
|
try {
|
|
@@ -64,11 +83,13 @@ export class ClickAndHold {
|
|
|
64
83
|
}
|
|
65
84
|
|
|
66
85
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* @
|
|
70
|
-
* @
|
|
71
|
-
* @
|
|
86
|
+
* Clicks and holds at the specified screen coordinates.
|
|
87
|
+
*
|
|
88
|
+
* @async
|
|
89
|
+
* @param {number} xPos - The x-coordinate on the screen.
|
|
90
|
+
* @param {number} yPos - The y-coordinate on the screen.
|
|
91
|
+
* @returns {Promise<void>} A promise that resolves when the action is performed.
|
|
92
|
+
* @throws {Error} Throws an error if the action cannot be performed.
|
|
72
93
|
*/
|
|
73
94
|
async atPosition(xPos, yPos) {
|
|
74
95
|
try {
|
|
@@ -86,10 +107,12 @@ export class ClickAndHold {
|
|
|
86
107
|
}
|
|
87
108
|
|
|
88
109
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* @
|
|
92
|
-
* @
|
|
110
|
+
* Releases the mouse button on an element matching the specified XPath.
|
|
111
|
+
*
|
|
112
|
+
* @async
|
|
113
|
+
* @param {string} xpath - The XPath selector of the element to release the mouse on.
|
|
114
|
+
* @returns {Promise<void>} A promise that resolves when the action is performed.
|
|
115
|
+
* @throws {Error} Throws an error if the action cannot be performed.
|
|
93
116
|
*/
|
|
94
117
|
async releaseAtXpath(xpath) {
|
|
95
118
|
try {
|
|
@@ -103,10 +126,12 @@ export class ClickAndHold {
|
|
|
103
126
|
}
|
|
104
127
|
|
|
105
128
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* @
|
|
109
|
-
* @
|
|
129
|
+
* Releases the mouse button on an element matching the specified CSS selector.
|
|
130
|
+
*
|
|
131
|
+
* @async
|
|
132
|
+
* @param {string} selector - The CSS selector of the element to release the mouse on.
|
|
133
|
+
* @returns {Promise<void>} A promise that resolves when the action is performed.
|
|
134
|
+
* @throws {Error} Throws an error if the action cannot be performed.
|
|
110
135
|
*/
|
|
111
136
|
async releaseAtSelector(selector) {
|
|
112
137
|
try {
|
|
@@ -120,11 +145,13 @@ export class ClickAndHold {
|
|
|
120
145
|
}
|
|
121
146
|
|
|
122
147
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* @
|
|
126
|
-
* @
|
|
127
|
-
* @
|
|
148
|
+
* Releases the mouse button at the specified screen coordinates.
|
|
149
|
+
*
|
|
150
|
+
* @async
|
|
151
|
+
* @param {number} xPos - The x-coordinate on the screen.
|
|
152
|
+
* @param {number} yPos - The y-coordinate on the screen.
|
|
153
|
+
* @returns {Promise<void>} A promise that resolves when the action is performed.
|
|
154
|
+
* @throws {Error} Throws an error if the action cannot be performed.
|
|
128
155
|
*/
|
|
129
156
|
async releaseAtPosition(xPos, yPos) {
|
|
130
157
|
try {
|
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
import intel from 'intel';
|
|
2
2
|
import { By } from 'selenium-webdriver';
|
|
3
3
|
const log = intel.getLogger('browsertime.command.mouse');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Provides functionality to perform a context click (right-click) on elements in a web page.
|
|
7
|
+
*
|
|
8
|
+
* @class
|
|
9
|
+
* @hideconstructor
|
|
10
|
+
*/
|
|
4
11
|
export class ContextClick {
|
|
5
12
|
constructor(browser) {
|
|
13
|
+
/**
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
6
16
|
this.driver = browser.getDriver();
|
|
17
|
+
/**
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
7
20
|
this.actions = this.driver.actions({ async: true });
|
|
8
21
|
}
|
|
9
22
|
|
|
10
23
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @
|
|
14
|
-
* @
|
|
24
|
+
* Performs a context click (right-click) on an element that matches a given XPath selector.
|
|
25
|
+
*
|
|
26
|
+
* @async
|
|
27
|
+
* @param {string} xpath - The XPath selector of the element to context click.
|
|
28
|
+
* @returns {Promise<void>} A promise that resolves when the context click action is performed.
|
|
29
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
15
30
|
*/
|
|
16
31
|
async byXpath(xpath) {
|
|
17
32
|
try {
|
|
@@ -25,10 +40,12 @@ export class ContextClick {
|
|
|
25
40
|
}
|
|
26
41
|
|
|
27
42
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* @
|
|
31
|
-
* @
|
|
43
|
+
* Performs a context click (right-click) on an element that matches a given CSS selector.
|
|
44
|
+
*
|
|
45
|
+
* @async
|
|
46
|
+
* @param {string} selector - The CSS selector of the element to context click.
|
|
47
|
+
* @returns {Promise<void>} A promise that resolves when the context click action is performed.
|
|
48
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
32
49
|
*/
|
|
33
50
|
async bySelector(selector) {
|
|
34
51
|
try {
|
|
@@ -44,9 +61,11 @@ export class ContextClick {
|
|
|
44
61
|
}
|
|
45
62
|
|
|
46
63
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* @
|
|
64
|
+
* Performs a context click (right-click) at the current cursor position.
|
|
65
|
+
*
|
|
66
|
+
* @async
|
|
67
|
+
* @returns {Promise<void>} A promise that resolves when the context click action is performed.
|
|
68
|
+
* @throws {Error} Throws an error if the context click action cannot be performed.
|
|
50
69
|
*/
|
|
51
70
|
async atCursor() {
|
|
52
71
|
try {
|
|
@@ -1,18 +1,36 @@
|
|
|
1
1
|
import intel from 'intel';
|
|
2
2
|
import { By } from 'selenium-webdriver';
|
|
3
3
|
const log = intel.getLogger('browsertime.command.mouse');
|
|
4
|
+
/**
|
|
5
|
+
* Provides functionality to perform a double-click action on elements in a web page.
|
|
6
|
+
*
|
|
7
|
+
* @class
|
|
8
|
+
* @hideconstructor
|
|
9
|
+
*/
|
|
4
10
|
export class DoubleClick {
|
|
5
11
|
constructor(browser, pageCompleteCheck) {
|
|
12
|
+
/**
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
6
15
|
this.browser = browser;
|
|
16
|
+
/**
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
7
19
|
this.actions = this.browser.getDriver().actions({ async: true });
|
|
20
|
+
/**
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
8
23
|
this.pageCompleteCheck = pageCompleteCheck;
|
|
9
24
|
}
|
|
10
25
|
|
|
11
26
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* @
|
|
15
|
-
* @
|
|
27
|
+
* Performs a mouse double-click on an element matching a given XPath selector.
|
|
28
|
+
*
|
|
29
|
+
* @async
|
|
30
|
+
* @param {string} xpath - The XPath selector of the element to double-click.
|
|
31
|
+
* @param {Object} [options] - Additional options for the double-click action.
|
|
32
|
+
* @returns {Promise<void>} A promise that resolves when the double-click action is performed.
|
|
33
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
16
34
|
*/
|
|
17
35
|
async byXpath(xpath, options) {
|
|
18
36
|
try {
|
|
@@ -31,10 +49,13 @@ export class DoubleClick {
|
|
|
31
49
|
}
|
|
32
50
|
|
|
33
51
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* @
|
|
37
|
-
* @
|
|
52
|
+
* Performs a mouse double-click on an element matching a given CSS selector.
|
|
53
|
+
*
|
|
54
|
+
* @async
|
|
55
|
+
* @param {string} selector - The CSS selector of the element to double-click.
|
|
56
|
+
* @param {Object} [options] - Additional options for the double-click action.
|
|
57
|
+
* @returns {Promise<void>} A promise that resolves when the double-click action is performed.
|
|
58
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
38
59
|
*/
|
|
39
60
|
async bySelector(selector, options) {
|
|
40
61
|
try {
|
|
@@ -55,9 +76,12 @@ export class DoubleClick {
|
|
|
55
76
|
}
|
|
56
77
|
|
|
57
78
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* @
|
|
79
|
+
* Performs a mouse double-click at the current cursor position.
|
|
80
|
+
*
|
|
81
|
+
* @async
|
|
82
|
+
* @param {Object} [options] - Additional options for the double-click action.
|
|
83
|
+
* @returns {Promise<void>} A promise that resolves when the double-click occurs.
|
|
84
|
+
* @throws {Error} Throws an error if the double-click action cannot be performed.
|
|
61
85
|
*/
|
|
62
86
|
async atCursor(options) {
|
|
63
87
|
try {
|
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
import intel from 'intel';
|
|
2
2
|
import { By, Origin } from 'selenium-webdriver';
|
|
3
3
|
const log = intel.getLogger('browsertime.command.mouse');
|
|
4
|
+
/**
|
|
5
|
+
* Provides functionality to move the mouse cursor to elements or specific positions on a web page.
|
|
6
|
+
*
|
|
7
|
+
* @class
|
|
8
|
+
* @hideconstructor
|
|
9
|
+
*/
|
|
4
10
|
export class MouseMove {
|
|
5
11
|
constructor(browser) {
|
|
12
|
+
/**
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
6
15
|
this.driver = browser.getDriver();
|
|
16
|
+
/**
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
7
19
|
this.actions = this.driver.actions({ async: true });
|
|
8
20
|
}
|
|
9
21
|
|
|
10
22
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @
|
|
14
|
-
* @
|
|
23
|
+
* Moves the mouse cursor to an element that matches a given XPath selector.
|
|
24
|
+
*
|
|
25
|
+
* @async
|
|
26
|
+
* @param {string} xpath - The XPath selector of the element to move to.
|
|
27
|
+
* @returns {Promise<void>} A promise that resolves when the mouse has moved to the element.
|
|
28
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
15
29
|
*/
|
|
16
30
|
async byXpath(xpath) {
|
|
17
31
|
try {
|
|
@@ -25,10 +39,12 @@ export class MouseMove {
|
|
|
25
39
|
}
|
|
26
40
|
|
|
27
41
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* @
|
|
31
|
-
* @
|
|
42
|
+
* Moves the mouse cursor to an element that matches a given CSS selector.
|
|
43
|
+
*
|
|
44
|
+
* @async
|
|
45
|
+
* @param {string} selector - The CSS selector of the element to move to.
|
|
46
|
+
* @returns {Promise<void>} A promise that resolves when the mouse has moved to the element.
|
|
47
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
32
48
|
*/
|
|
33
49
|
async bySelector(selector) {
|
|
34
50
|
try {
|
|
@@ -42,10 +58,13 @@ export class MouseMove {
|
|
|
42
58
|
}
|
|
43
59
|
|
|
44
60
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* @
|
|
48
|
-
* @
|
|
61
|
+
* Moves the mouse cursor to a specific position on the screen.
|
|
62
|
+
*
|
|
63
|
+
* @async
|
|
64
|
+
* @param {number} xPos - The x-coordinate on the screen to move to.
|
|
65
|
+
* @param {number} yPos - The y-coordinate on the screen to move to.
|
|
66
|
+
* @returns {Promise<void>} A promise that resolves when the mouse has moved to the specified position.
|
|
67
|
+
* @throws {Error} Throws an error if the action cannot be performed.
|
|
49
68
|
*/
|
|
50
69
|
async toPosition(xPos, yPos) {
|
|
51
70
|
try {
|
|
@@ -58,10 +77,13 @@ export class MouseMove {
|
|
|
58
77
|
}
|
|
59
78
|
|
|
60
79
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* @
|
|
64
|
-
* @
|
|
80
|
+
* Moves the mouse cursor by an offset from its current position.
|
|
81
|
+
*
|
|
82
|
+
* @async
|
|
83
|
+
* @param {number} xOffset - The x offset to move by.
|
|
84
|
+
* @param {number} yOffset - The y offset to move by.
|
|
85
|
+
* @returns {Promise<void>} A promise that resolves when the mouse has moved by the specified offset.
|
|
86
|
+
* @throws {Error} Throws an error if the action cannot be performed.
|
|
65
87
|
*/
|
|
66
88
|
async byOffset(xOffset, yOffset) {
|
|
67
89
|
try {
|