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.
Files changed (211) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +2 -2
  3. package/bin/browsertime.js +9 -3
  4. package/browserscripts/pageinfo/interactionToNextPaintInfo.js +170 -143
  5. package/browserscripts/timings/interactionToNextPaint.js +49 -137
  6. package/lib/chrome/webdriver/setupChromiumOptions.js +0 -9
  7. package/lib/core/engine/collector.js +11 -0
  8. package/lib/core/engine/command/actions.js +52 -0
  9. package/lib/core/engine/command/addText.js +48 -30
  10. package/lib/core/engine/command/android.js +43 -4
  11. package/lib/core/engine/command/cache.js +39 -2
  12. package/lib/core/engine/command/chromeDevToolsProtocol.js +51 -1
  13. package/lib/core/engine/command/chromeTrace.js +34 -0
  14. package/lib/core/engine/command/click.js +102 -52
  15. package/lib/core/engine/command/debug.js +19 -2
  16. package/lib/core/engine/command/element.js +66 -0
  17. package/lib/core/engine/command/geckoProfiler.js +41 -1
  18. package/lib/core/engine/command/javaScript.js +43 -20
  19. package/lib/core/engine/command/measure.js +147 -15
  20. package/lib/core/engine/command/meta.js +17 -0
  21. package/lib/core/engine/command/mouse/clickAndHold.js +56 -29
  22. package/lib/core/engine/command/mouse/contextClick.js +30 -11
  23. package/lib/core/engine/command/mouse/doubleClick.js +35 -11
  24. package/lib/core/engine/command/mouse/mouseMove.js +38 -16
  25. package/lib/core/engine/command/mouse/singleClick.js +187 -12
  26. package/lib/core/engine/command/navigation.js +31 -3
  27. package/lib/core/engine/command/screenshot.js +33 -0
  28. package/lib/core/engine/command/scroll.js +35 -13
  29. package/lib/core/engine/command/select.js +55 -36
  30. package/lib/core/engine/command/set.js +51 -36
  31. package/lib/core/engine/command/stopWatch.js +30 -9
  32. package/lib/core/engine/command/switch.js +49 -11
  33. package/lib/core/engine/command/wait.js +50 -25
  34. package/lib/core/engine/commands.js +267 -0
  35. package/lib/core/engine/context.js +81 -0
  36. package/lib/core/engine/iteration.js +20 -102
  37. package/lib/firefox/geckoProfiler.js +49 -1
  38. package/lib/firefox/webdriver/builder.js +4 -9
  39. package/lib/firefox/webdriver/firefox.js +1 -1
  40. package/lib/support/cli.js +7 -0
  41. package/lib/support/statistics.js +11 -1
  42. package/package.json +17 -7
  43. package/types/android/index.d.ts +70 -0
  44. package/types/android/index.d.ts.map +1 -0
  45. package/types/chrome/parseCpuTrace.d.ts +21 -0
  46. package/types/chrome/parseCpuTrace.d.ts.map +1 -0
  47. package/types/chrome/traceCategoriesParser.d.ts +2 -0
  48. package/types/chrome/traceCategoriesParser.d.ts.map +1 -0
  49. package/types/chrome/webdriver/traceUtilities.d.ts +8 -0
  50. package/types/chrome/webdriver/traceUtilities.d.ts.map +1 -0
  51. package/types/core/engine/command/action.d.ts +73 -0
  52. package/types/core/engine/command/action.d.ts.map +1 -0
  53. package/types/core/engine/command/actions.d.ts +38 -0
  54. package/types/core/engine/command/actions.d.ts.map +1 -0
  55. package/types/core/engine/command/addText.d.ts +68 -0
  56. package/types/core/engine/command/addText.d.ts.map +1 -0
  57. package/types/core/engine/command/android.d.ts +39 -0
  58. package/types/core/engine/command/android.d.ts.map +1 -0
  59. package/types/core/engine/command/cache.d.ts +53 -0
  60. package/types/core/engine/command/cache.d.ts.map +1 -0
  61. package/types/core/engine/command/chromeDevToolsProtocol.d.ts +61 -0
  62. package/types/core/engine/command/chromeDevToolsProtocol.d.ts.map +1 -0
  63. package/types/core/engine/command/chromeTrace.d.ts +45 -0
  64. package/types/core/engine/command/chromeTrace.d.ts.map +1 -0
  65. package/types/core/engine/command/click.d.ts +151 -0
  66. package/types/core/engine/command/click.d.ts.map +1 -0
  67. package/types/core/engine/command/debug.d.ts +28 -0
  68. package/types/core/engine/command/debug.d.ts.map +1 -0
  69. package/types/core/engine/command/element.d.ts +49 -0
  70. package/types/core/engine/command/element.d.ts.map +1 -0
  71. package/types/core/engine/command/geckoProfiler.d.ts +46 -0
  72. package/types/core/engine/command/geckoProfiler.d.ts.map +1 -0
  73. package/types/core/engine/command/javaScript.d.ts +63 -0
  74. package/types/core/engine/command/javaScript.d.ts.map +1 -0
  75. package/types/core/engine/command/measure.d.ts +194 -0
  76. package/types/core/engine/command/measure.d.ts.map +1 -0
  77. package/types/core/engine/command/meta.d.ts +23 -0
  78. package/types/core/engine/command/meta.d.ts.map +1 -0
  79. package/types/core/engine/command/mouse/clickAndHold.d.ts +82 -0
  80. package/types/core/engine/command/mouse/clickAndHold.d.ts.map +1 -0
  81. package/types/core/engine/command/mouse/contextClick.d.ts +44 -0
  82. package/types/core/engine/command/mouse/contextClick.d.ts.map +1 -0
  83. package/types/core/engine/command/mouse/doubleClick.d.ts +51 -0
  84. package/types/core/engine/command/mouse/doubleClick.d.ts.map +1 -0
  85. package/types/core/engine/command/mouse/index.d.ts +6 -0
  86. package/types/core/engine/command/mouse/index.d.ts.map +1 -0
  87. package/types/core/engine/command/mouse/mouseMove.d.ts +56 -0
  88. package/types/core/engine/command/mouse/mouseMove.d.ts.map +1 -0
  89. package/types/core/engine/command/mouse/singleClick.d.ts +115 -0
  90. package/types/core/engine/command/mouse/singleClick.d.ts.map +1 -0
  91. package/types/core/engine/command/navigation.d.ts +45 -0
  92. package/types/core/engine/command/navigation.d.ts.map +1 -0
  93. package/types/core/engine/command/screenshot.d.ts +33 -0
  94. package/types/core/engine/command/screenshot.d.ts.map +1 -0
  95. package/types/core/engine/command/scroll.d.ts +52 -0
  96. package/types/core/engine/command/scroll.d.ts.map +1 -0
  97. package/types/core/engine/command/select.d.ts +81 -0
  98. package/types/core/engine/command/select.d.ts.map +1 -0
  99. package/types/core/engine/command/set.d.ts +74 -0
  100. package/types/core/engine/command/set.d.ts.map +1 -0
  101. package/types/core/engine/command/stopWatch.d.ts +49 -0
  102. package/types/core/engine/command/stopWatch.d.ts.map +1 -0
  103. package/types/core/engine/command/switch.d.ts +77 -0
  104. package/types/core/engine/command/switch.d.ts.map +1 -0
  105. package/types/core/engine/command/util/lcpHighlightScript.d.ts +2 -0
  106. package/types/core/engine/command/util/lcpHighlightScript.d.ts.map +1 -0
  107. package/types/core/engine/command/util/lsHighlightScript.d.ts +2 -0
  108. package/types/core/engine/command/util/lsHighlightScript.d.ts.map +1 -0
  109. package/types/core/engine/command/wait.d.ts +74 -0
  110. package/types/core/engine/command/wait.d.ts.map +1 -0
  111. package/types/core/engine/commands.d.ts +161 -0
  112. package/types/core/engine/commands.d.ts.map +1 -0
  113. package/types/core/engine/context.d.ts +87 -0
  114. package/types/core/engine/context.d.ts.map +1 -0
  115. package/types/firefox/geckoProfiler.d.ts +11 -0
  116. package/types/firefox/geckoProfiler.d.ts.map +1 -0
  117. package/types/firefox/settings/geckoProfilerDefaults.d.ts +8 -0
  118. package/types/firefox/settings/geckoProfilerDefaults.d.ts.map +1 -0
  119. package/types/scripting.d.ts +2 -0
  120. package/types/support/engineUtils.d.ts +5 -0
  121. package/types/support/engineUtils.d.ts.map +1 -0
  122. package/types/support/errors.d.ts +15 -0
  123. package/types/support/errors.d.ts.map +1 -0
  124. package/types/support/fileUtil.d.ts +10 -0
  125. package/types/support/fileUtil.d.ts.map +1 -0
  126. package/types/support/filters.d.ts +7 -0
  127. package/types/support/filters.d.ts.map +1 -0
  128. package/types/support/getViewPort.d.ts +2 -0
  129. package/types/support/getViewPort.d.ts.map +1 -0
  130. package/types/support/pathToFolder.d.ts +2 -0
  131. package/types/support/pathToFolder.d.ts.map +1 -0
  132. package/types/support/storageManager.d.ts +17 -0
  133. package/types/support/storageManager.d.ts.map +1 -0
  134. package/types/support/tcpdump.d.ts +10 -0
  135. package/types/support/tcpdump.d.ts.map +1 -0
  136. package/types/support/userTiming.d.ts +2 -0
  137. package/types/support/userTiming.d.ts.map +1 -0
  138. package/types/support/util.d.ts +6 -0
  139. package/types/support/util.d.ts.map +1 -0
  140. package/types/video/defaults.d.ts +7 -0
  141. package/types/video/defaults.d.ts.map +1 -0
  142. package/types/video/postprocessing/finetune/addTextToVideo.d.ts +2 -0
  143. package/types/video/postprocessing/finetune/addTextToVideo.d.ts.map +1 -0
  144. package/types/video/postprocessing/finetune/convertFps.d.ts +2 -0
  145. package/types/video/postprocessing/finetune/convertFps.d.ts.map +1 -0
  146. package/types/video/postprocessing/finetune/getFont.d.ts +2 -0
  147. package/types/video/postprocessing/finetune/getFont.d.ts.map +1 -0
  148. package/types/video/postprocessing/finetune/getTimingMetrics.d.ts +2 -0
  149. package/types/video/postprocessing/finetune/getTimingMetrics.d.ts.map +1 -0
  150. package/types/video/postprocessing/finetune/index.d.ts +2 -0
  151. package/types/video/postprocessing/finetune/index.d.ts.map +1 -0
  152. package/types/video/postprocessing/finetune/removeOrange.d.ts +2 -0
  153. package/types/video/postprocessing/finetune/removeOrange.d.ts.map +1 -0
  154. package/types/video/postprocessing/visualmetrics/extraMetrics.d.ts +5 -0
  155. package/types/video/postprocessing/visualmetrics/extraMetrics.d.ts.map +1 -0
  156. package/types/video/postprocessing/visualmetrics/getVideoMetrics.d.ts +5 -0
  157. package/types/video/postprocessing/visualmetrics/getVideoMetrics.d.ts.map +1 -0
  158. package/types/video/postprocessing/visualmetrics/visualMetrics.d.ts +3 -0
  159. package/types/video/postprocessing/visualmetrics/visualMetrics.d.ts.map +1 -0
  160. package/types/video/screenRecording/android/recorder.d.ts +11 -0
  161. package/types/video/screenRecording/android/recorder.d.ts.map +1 -0
  162. package/types/video/screenRecording/desktop/convert.d.ts +2 -0
  163. package/types/video/screenRecording/desktop/convert.d.ts.map +1 -0
  164. package/types/video/screenRecording/desktop/desktopRecorder.d.ts +28 -0
  165. package/types/video/screenRecording/desktop/desktopRecorder.d.ts.map +1 -0
  166. package/types/video/screenRecording/desktop/ffmpegRecorder.d.ts +17 -0
  167. package/types/video/screenRecording/desktop/ffmpegRecorder.d.ts.map +1 -0
  168. package/types/video/screenRecording/desktop/osx/getSPDisplaysDataType.d.ts +2 -0
  169. package/types/video/screenRecording/desktop/osx/getSPDisplaysDataType.d.ts.map +1 -0
  170. package/types/video/screenRecording/desktop/osx/getScreen.d.ts +2 -0
  171. package/types/video/screenRecording/desktop/osx/getScreen.d.ts.map +1 -0
  172. package/types/video/screenRecording/firefox/firefoxWindowRecorder.d.ts +13 -0
  173. package/types/video/screenRecording/firefox/firefoxWindowRecorder.d.ts.map +1 -0
  174. package/types/video/screenRecording/ios/convertToMp4.d.ts +2 -0
  175. package/types/video/screenRecording/ios/convertToMp4.d.ts.map +1 -0
  176. package/types/video/screenRecording/ios/iosRecorder.d.ts +14 -0
  177. package/types/video/screenRecording/ios/iosRecorder.d.ts.map +1 -0
  178. package/types/video/screenRecording/iosSimulator/convertToMp4.d.ts +2 -0
  179. package/types/video/screenRecording/iosSimulator/convertToMp4.d.ts.map +1 -0
  180. package/types/video/screenRecording/iosSimulator/recorder.d.ts +9 -0
  181. package/types/video/screenRecording/iosSimulator/recorder.d.ts.map +1 -0
  182. package/types/video/screenRecording/recorder.d.ts +7 -0
  183. package/types/video/screenRecording/recorder.d.ts.map +1 -0
  184. package/types/video/screenRecording/setOrangeBackground.d.ts +2 -0
  185. package/types/video/screenRecording/setOrangeBackground.d.ts.map +1 -0
  186. package/types/video/video.d.ts +41 -0
  187. package/types/video/video.d.ts.map +1 -0
  188. package/browsersupport/firefox-profile/cert9.db +0 -0
  189. package/browsersupport/firefox-profile/chrome/userChrome.css +0 -4
  190. package/browsersupport/firefox-profile/key4.db +0 -0
  191. package/vendor/mac/x86/qvh +0 -0
  192. package/visualmetrics/__init__.py +0 -1
  193. package/visualmetrics/test_data/ms_000000.png +0 -0
  194. package/visualmetrics/test_data/ms_000920.png +0 -0
  195. package/visualmetrics/test_data/ms_001000.png +0 -0
  196. package/visualmetrics/test_data/ms_001080.png +0 -0
  197. package/visualmetrics/test_data/ms_001200.png +0 -0
  198. package/visualmetrics/test_data/ms_001240.png +0 -0
  199. package/visualmetrics/test_data/ms_001280.png +0 -0
  200. package/visualmetrics/test_data/ms_001360.png +0 -0
  201. package/visualmetrics/test_data/ms_001400.png +0 -0
  202. package/visualmetrics/test_data/ms_001520.png +0 -0
  203. package/visualmetrics/test_data/ms_002040.png +0 -0
  204. package/visualmetrics/test_data/ms_002600.png +0 -0
  205. package/visualmetrics/test_data/ms_003160.png +0 -0
  206. package/visualmetrics/test_data/ms_003720.png +0 -0
  207. package/visualmetrics/test_data/ms_004280.png +0 -0
  208. package/visualmetrics/test_data/ms_004880.png +0 -0
  209. package/visualmetrics/test_data/ms_005440.png +0 -0
  210. package/visualmetrics/test_data/ms_006000.png +0 -0
  211. 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
- // Have a consistent way of starting the video
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
- * Start collecting metrics for a URL. If you supply a URL to this method, the browser will navigate to that URL.
166
- * If you do not use an URL (start()) everything is prepared for a new page to measure except the browser do not
167
- * navigate to a new URL. You can also add an alias for the URL.
168
- * @param {string} urlOrAlias
169
- * @param {string} optionalAlias
170
- * @returns {Promise} Promise object represents when the URL has been navigated and finished loading according to the pageCompleteCheck or when everything is setup for measuring a new URL (if no URL is supplied).
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
- * Stop measuring and collect all the metrics.
262
- * @returns {Promise} Promise object represents all the metrics has been collected.
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
- * Add your own metric.
330
- * @param {string} name
331
- * @param {*} value
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
- * Add your own metrics. You can add an object witch multiple keys and they will all be collected.
345
- * @param {*} object
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
- * Click and hold an element that matches a XPath selector.
12
- * @param {string} xpath
13
- * @returns {Promise} Promise object represents when mouse is pressed.
14
- * @throws Will throw an error if the element is not found.
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
- * Click and hold an element that matches a CSS selector.
31
- * @param {string} selector
32
- * @returns {Promise} Promise object represents when mouse is pressed.
33
- * @throws Will throw an error if the element is not found.
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
- * Click and hold an element at the cursor's position.
53
- * @returns {Promise} Promise object represents when mouse is pressed.
54
- * @throws Will throw an error if action cannot be performed.
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
- * Click and hold an element at the given coordinates.
68
- * @param {integer} xPos
69
- * @param {integer} yPos
70
- * @returns {Promise} Promise object represents when mouse is pressed.
71
- * @throws Will throw an error if action cannot be performed.
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
- * Release mouse on element that matches the specified Xpath.
90
- * @param {string} xpath
91
- * @returns {Promise} Promise object represents when mouse is released.
92
- * @throws Will throw an error if action cannot be performed.
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
- * Release mouse on element that matches the specified CSS selector.
107
- * @param {string} selector
108
- * @returns {Promise} Promise object represents when mouse is released.
109
- * @throws Will throw an error if action cannot be performed.
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
- * Release mouse at specified coordinates.
124
- * @param {integer} xPos
125
- * @param {integer} yPos
126
- * @returns {Promise} Promise object represents when mouse is released.
127
- * @throws Will throw an error if action cannot be performed.
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
- * Perform ContextClick on an element that matches a XPath selector.
12
- * @param {string} xpath
13
- * @returns {Promise} Promise object represents when context click occurs.
14
- * @throws Will throw an error if the element is not found
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
- * Perform ContextClick on an element that matches a CSS selector.
29
- * @param {string} css selector
30
- * @returns {Promise} Promise object represents when context click occurs.
31
- * @throws Will throw an error if the element is not found
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
- * Perform ContextClick at the cursor's position.
48
- * @returns {Promise} Promise object represents when context click occurs.
49
- * @throws Will throw an error if context click cannot be performed.
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
- * Perform mouse double click on an element matches a XPath selector.
13
- * @param {string} xpath
14
- * @returns {Promise} Promise object represents when the element has been double clicked.
15
- * @throws Will throw an error if the element is not found.
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
- * Perform mouse double click on an element matches a CSS selector.
35
- * @param {string} selector
36
- * @returns {Promise} Promise object represents when the element has been double clicked.
37
- * @throws Will throw an error if the element is not found.
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
- * Perform mouse double click at the cursor's position.
59
- * @returns {Promise} Promise object represents when double click occurs.
60
- * @throws Will throw an error if double click cannot be performed.
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
- * Move mouse to an element that matches a XPath selector.
12
- * @param {string} xpath
13
- * @returns {Promise} Promise object represents when the mouse has moved
14
- * @throws Will throw an error if the element is not found
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
- * Move mouse to an element that matches a CSS selector.
29
- * @param {string} selector
30
- * @returns {Promise} Promise object represents when the mouse has moved
31
- * @throws Will throw an error if the element is not found
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
- * Move mouse to a position
46
- * @param {number} xPos, {number} yPos
47
- * @returns {Promise} Promise object represents when the mouse has moved
48
- * @throws Will throw an error if the element is not found
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
- * Move mouse by an offset
62
- * @param {number} xOffset, {number} yOffset
63
- * @returns {Promise} Promise object represents when the mouse has moved
64
- * @throws Will throw an error if the element is not found
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 {