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
@@ -1,18 +1,28 @@
1
1
  import intel from 'intel';
2
2
  const log = intel.getLogger('browsertime.command.set');
3
3
 
4
+ /**
5
+ * Provides functionality to set properties like innerHTML, innerText, and value on elements in a web page.
6
+ *
7
+ * @class
8
+ * @hideconstructor
9
+ */
4
10
  export class Set {
5
11
  constructor(browser) {
12
+ /**
13
+ * @private
14
+ */
6
15
  this.browser = browser;
7
16
  }
8
17
 
9
18
  /**
10
- * Set innerHtml to an element using a specific CSS selector.
11
- * @param {string} html The html string that you want to set
12
- * @param {string} selector The selector of the element
13
- * @returns {Promise} Promise object represents when the html has been
14
- * set to the element
15
- * @throws Will throw an error if the element is not found
19
+ * Sets the innerHTML of an element using a CSS selector.
20
+ *
21
+ * @async
22
+ * @param {string} html - The HTML string to set as innerHTML.
23
+ * @param {string} selector - The CSS selector of the element.
24
+ * @returns {Promise<void>} A promise that resolves when the innerHTML is set.
25
+ * @throws {Error} Throws an error if the element is not found.
16
26
  */
17
27
  async innerHtml(html, selector) {
18
28
  try {
@@ -28,12 +38,13 @@ export class Set {
28
38
  }
29
39
 
30
40
  /**
31
- * Set innerHtml to an element using a id
32
- * @param {string} html The html string that you want to set
33
- * @param {string} id The id of the element
34
- * @returns {Promise} Promise object represents when the html has been
35
- * set to the element
36
- * @throws Will throw an error if the element is not found
41
+ * Sets the innerHTML of an element using its ID.
42
+ *
43
+ * @async
44
+ * @param {string} html - The HTML string to set as innerHTML.
45
+ * @param {string} id - The ID of the element.
46
+ * @returns {Promise<void>} A promise that resolves when the innerHTML is set.
47
+ * @throws {Error} Throws an error if the element is not found.
37
48
  */
38
49
  async innerHtmlById(html, id) {
39
50
  try {
@@ -47,12 +58,13 @@ export class Set {
47
58
  }
48
59
 
49
60
  /**
50
- * Set innerText to an element using a specific CSS selector.
51
- * @param {string} html The html string that you want to set
52
- * @param {string} selector The selector of the element
53
- * @returns {Promise} Promise object represents when the text has been
54
- * set to the element
55
- * @throws Will throw an error if the element is not found
61
+ * Sets the innerText of an element using a CSS selector.
62
+ *
63
+ * @async
64
+ * @param {string} text - The text to set as innerText.
65
+ * @param {string} selector - The CSS selector of the element.
66
+ * @returns {Promise<void>} A promise that resolves when the innerText is set.
67
+ * @throws {Error} Throws an error if the element is not found.
56
68
  */
57
69
  async innerText(text, selector) {
58
70
  try {
@@ -68,12 +80,13 @@ export class Set {
68
80
  }
69
81
 
70
82
  /**
71
- * Set innerText to an element using a id.
72
- * @param {string} html The html string that you want to set
73
- * @param {string} id The id of the element
74
- * @returns {Promise} Promise object represents when the text has been
75
- * set to the element
76
- * @throws Will throw an error if the element is not found
83
+ * Sets the innerText of an element using its ID.
84
+ *
85
+ * @async
86
+ * @param {string} text - The text to set as innerText.
87
+ * @param {string} id - The ID of the element.
88
+ * @returns {Promise<void>} A promise that resolves when the innerText is set.
89
+ * @throws {Error} Throws an error if the element is not found.
77
90
  */
78
91
  async innerTextById(text, id) {
79
92
  try {
@@ -87,12 +100,13 @@ export class Set {
87
100
  }
88
101
 
89
102
  /**
90
- * Set value to an element using a specific CSS selector.
91
- * @param {string} value The value that you want to set
92
- * @param {string} selector The selector of the element
93
- * @returns {Promise} Promise object represents when the value has been
94
- * added to element
95
- * @throws Will throw an error if the element is not found
103
+ * Sets the value of an element using a CSS selector.
104
+ *
105
+ * @async
106
+ * @param {string} value - The value to set on the element.
107
+ * @param {string} selector - The CSS selector of the element.
108
+ * @returns {Promise<void>} A promise that resolves when the value is set.
109
+ * @throws {Error} Throws an error if the element is not found.
96
110
  */
97
111
  async value(value, selector) {
98
112
  try {
@@ -106,12 +120,13 @@ export class Set {
106
120
  }
107
121
 
108
122
  /**
109
- * Set value to an element using a id.
110
- * @param {string} value The value that you want to set
111
- * @param {string} selector The selector of the element
112
- * @returns {Promise} Promise object represents when the value has been
113
- * added to element
114
- * @throws Will throw an error if the element is not found
123
+ * Sets the value of an element using its ID.
124
+ *
125
+ * @async
126
+ * @param {string} value - The value to set on the element.
127
+ * @param {string} id - The ID of the element.
128
+ * @returns {Promise<void>} A promise that resolves when the value is set.
129
+ * @throws {Error} Throws an error if the element is not found.
115
130
  */
116
131
  async valueById(value, id) {
117
132
  try {
@@ -1,25 +1,40 @@
1
1
  import { performance } from 'node:perf_hooks';
2
2
  import intel from 'intel';
3
3
  const log = intel.getLogger('browsertime.command.stopwatch');
4
+
5
+ /**
6
+ * A stopwatch utility for measuring time intervals.
7
+ *
8
+ * @class
9
+ * @hideconstructor
10
+ */
4
11
  export class StopWatch {
5
12
  constructor(name, measure) {
13
+ /**
14
+ * @private
15
+ */
6
16
  this.name = name;
17
+ /**
18
+ * @private
19
+ */
7
20
  this.measure = measure;
21
+ /**
22
+ * @private
23
+ */
8
24
  this.start = performance.now();
9
25
  }
10
26
 
11
27
  /**
12
- * Start the the stop watch
28
+ * Starts the stopwatch.
13
29
  */
14
30
  start() {
15
31
  this.start = performance.now();
16
32
  }
17
33
 
18
34
  /**
19
- * Stop the watch and automatically add the time to the
20
- * last measured page. If no page has been measured you will get
21
- * an error in your log.
22
- * @returns the measured time
35
+ * Stops the stopwatch and automatically adds the measured time to the
36
+ * last measured page. Logs an error if no page has been measured.
37
+ * @returns {number} The measured time in milliseconds.
23
38
  */
24
39
  stopAndAdd() {
25
40
  this.stop = performance.now();
@@ -29,8 +44,8 @@ export class StopWatch {
29
44
  }
30
45
 
31
46
  /**
32
- * Stop the watch
33
- * @returns the measured time
47
+ * Stops the stopwatch.
48
+ * @returns {number} The measured time in milliseconds.
34
49
  */
35
50
  stop() {
36
51
  this.stop = performance.now();
@@ -39,19 +54,25 @@ export class StopWatch {
39
54
  }
40
55
 
41
56
  /**
42
- * Get the name of the watch.
43
- * @returns The name of the watch
57
+ * Gets the name of the stopwatch.
58
+ * @returns {string} The name of the stopwatch.
44
59
  */
45
60
  getName() {
46
61
  return this.name;
47
62
  }
48
63
  }
49
64
 
65
+ /**
66
+ * @private
67
+ */
50
68
  export class Watch {
51
69
  constructor(measure) {
52
70
  this.measure = measure;
53
71
  }
54
72
 
73
+ /**
74
+ * @private
75
+ */
55
76
  get(name) {
56
77
  return new StopWatch(name, this.measure);
57
78
  }
@@ -2,16 +2,34 @@ import intel from 'intel';
2
2
  import { By } from 'selenium-webdriver';
3
3
  const log = intel.getLogger('browsertime.command.switch');
4
4
 
5
+ /**
6
+ * Provides functionality to switch between frames, windows, and tabs in the browser.
7
+ *
8
+ * @class
9
+ * @hideconstructor
10
+ */
5
11
  export class Switch {
6
12
  constructor(browser, pageCompleteCheck, navigate) {
13
+ /**
14
+ * @private
15
+ */
7
16
  this.browser = browser;
17
+ /**
18
+ * @private
19
+ */
8
20
  this.pageCompleteCheck = pageCompleteCheck;
21
+ /**
22
+ * @private
23
+ */
9
24
  this.navigate = navigate;
10
25
  }
11
26
 
12
27
  /**
13
- * Switch to frame by id
14
- * @param {*} id
28
+ * Switches to a frame identified by its ID.
29
+ *
30
+ * @async
31
+ * @param {string|number} id - The ID of the frame.
32
+ * @throws {Error} Throws an error if switching to the frame fails.
15
33
  */
16
34
  async toFrame(id) {
17
35
  const driver = this.browser.getDriver();
@@ -25,8 +43,11 @@ export class Switch {
25
43
  }
26
44
 
27
45
  /**
28
- * Switch to frame by xpath
29
- * @param {*} xpath
46
+ * Switches to a frame identified by an XPath.
47
+ *
48
+ * @async
49
+ * @param {string} xpath - The XPath of the frame element.
50
+ * @throws {Error} Throws an error if the frame is not found or switching fails.
30
51
  */
31
52
  async toFrameByXpath(xpath) {
32
53
  const driver = this.browser.getDriver();
@@ -46,8 +67,11 @@ export class Switch {
46
67
  }
47
68
 
48
69
  /**
49
- * Switch to frame by xpath
50
- * @param {*} xpath
70
+ * Switches to a frame identified by a CSS selector.
71
+ *
72
+ * @async
73
+ * @param {string} selector - The CSS selector of the frame element.
74
+ * @throws {Error} Throws an error if the frame is not found or switching fails.
51
75
  */
52
76
  async toFrameBySelector(selector) {
53
77
  const driver = this.browser.getDriver();
@@ -67,8 +91,11 @@ export class Switch {
67
91
  }
68
92
 
69
93
  /**
70
- * Switch to a window by name
71
- * @param {*} name
94
+ * Switches to a window identified by its name.
95
+ *
96
+ * @async
97
+ * @param {string} name - The name of the window.
98
+ * @throws {Error} Throws an error if switching to the window fails.
72
99
  */
73
100
  async toWindow(name) {
74
101
  const driver = this.browser.getDriver();
@@ -82,7 +109,10 @@ export class Switch {
82
109
  }
83
110
 
84
111
  /**
85
- * Switch to parent frame
112
+ * Switches to the parent frame of the current frame.
113
+ *
114
+ * @async
115
+ * @throws {Error} Throws an error if switching to the parent frame fails.
86
116
  */
87
117
  async toParentFrame() {
88
118
  const driver = this.browser.getDriver();
@@ -96,7 +126,11 @@ export class Switch {
96
126
  }
97
127
 
98
128
  /**
99
- * Create a new tab and switch to it. Optionally, navigate to a given url.
129
+ * Opens a new tab and optionally navigates to a URL.
130
+ *
131
+ * @async
132
+ * @param {string} [url] - Optional URL to navigate to in the new tab.
133
+ * @throws {Error} Throws an error if opening a new tab fails.
100
134
  */
101
135
  async toNewTab(url) {
102
136
  try {
@@ -115,7 +149,11 @@ export class Switch {
115
149
  }
116
150
 
117
151
  /**
118
- * Create a new window and switch to it. Optionally, navigate to a given url.
152
+ * Opens a new window and optionally navigates to a URL.
153
+ *
154
+ * @async
155
+ * @param {string} [url] - Optional URL to navigate to in the new window.
156
+ * @throws {Error} Throws an error if opening a new window fails.
119
157
  */
120
158
  async toNewWindow(url) {
121
159
  try {
@@ -3,18 +3,32 @@ import intel from 'intel';
3
3
  const log = intel.getLogger('browsertime.command.wait');
4
4
  const delay = ms => new Promise(res => setTimeout(res, ms));
5
5
 
6
+ /**
7
+ * Provides functionality to wait for different conditions in the browser.
8
+ *
9
+ * @class
10
+ * @hideconstructor
11
+ */
6
12
  export class Wait {
7
13
  constructor(browser, pageCompleteCheck) {
14
+ /**
15
+ * @private
16
+ */
8
17
  this.browser = browser;
18
+ /**
19
+ * @private
20
+ */
9
21
  this.pageCompleteCheck = pageCompleteCheck;
10
22
  }
11
23
 
12
24
  /**
13
- * Wait for an element with id to appear for maxTime.
14
- * @param {string} id The id to wait for
15
- * @param {number} maxTime Max time to wait in ms
16
- * @returns {Promise} Promise object represents when the element is found or the time times out
17
- * @throws Will throw an error if the element is not found
25
+ * Waits for an element with a specific ID to appear within a maximum time.
26
+ *
27
+ * @async
28
+ * @param {string} id - The ID of the element to wait for.
29
+ * @param {number} maxTime - Maximum time to wait in milliseconds.
30
+ * @returns {Promise<void>} A promise that resolves when the element is found or the time times out.
31
+ * @throws {Error} Throws an error if the element is not found within the specified time.
18
32
  */
19
33
  async byId(id, maxTime) {
20
34
  const driver = this.browser.getDriver();
@@ -33,11 +47,13 @@ export class Wait {
33
47
  }
34
48
 
35
49
  /**
36
- * Wait for an element with xpath to appear for maxTime.
37
- * @param {string} xpath The xpath to wait for
38
- * @param {number} maxTime Max time to wait in ms
39
- * @returns {Promise} Promise object represents when the element is found or the time times out
40
- * @throws Will throw an error if the element is not found
50
+ * Waits for an element located by XPath to appear within a maximum time.
51
+ *
52
+ * @async
53
+ * @param {string} xpath - The XPath of the element to wait for.
54
+ * @param {number} maxTime - Maximum time to wait in milliseconds.
55
+ * @returns {Promise<void>} A promise that resolves when the element is found or the time times out.
56
+ * @throws {Error} Throws an error if the element is not found within the specified time.
41
57
  */
42
58
  async byXpath(xpath, maxTime) {
43
59
  const driver = this.browser.getDriver();
@@ -58,11 +74,13 @@ export class Wait {
58
74
  }
59
75
 
60
76
  /**
61
- * Wait for an element that you find by a selector to appear for maxTime.
62
- * @param {string} selector The selector to find the element to wait for
63
- * @param {number} maxTime Max time to wait in ms
64
- * @returns {Promise} Promise object represents when the element is found or the time times out
65
- * @throws Will throw an error if the element is not found
77
+ * Waits for an element located by a CSS selector to appear within a maximum time.
78
+ *
79
+ * @async
80
+ * @param {string} selector - The CSS selector of the element to wait for.
81
+ * @param {number} maxTime - Maximum time to wait in milliseconds.
82
+ * @returns {Promise<void>} A promise that resolves when the element is found or the time times out.
83
+ * @throws {Error} Throws an error if the element is not found within the specified time.
66
84
  */
67
85
  async bySelector(selector, maxTime) {
68
86
  const driver = this.browser.getDriver();
@@ -87,28 +105,35 @@ export class Wait {
87
105
  }
88
106
 
89
107
  /**
90
- * Wait for x ms.
91
- * @param {number} ms The tine in ms to wait.
92
- * @returns {Promise} Promise object represents when the time has timed out.
108
+ * Waits for a specified amount of time.
109
+ *
110
+ * @async
111
+ * @example async commands.wait.byTime(1000);
112
+ * @param {number} ms - The time in milliseconds to wait.
113
+ * @returns {Promise<void>} A promise that resolves when the specified time has elapsed.
93
114
  */
94
115
  async byTime(ms) {
95
116
  return delay(ms);
96
117
  }
97
118
 
98
119
  /**
99
- * Wait for the page to finish loading.
100
- * @returns {Promise} Promise object represents when the pageCompleteCheck has finished.
120
+ * Waits for the page to finish loading.
121
+ * @async
122
+ * @example async commands.wait.byPageToComplete();
123
+ * @returns {Promise<void>} A promise that resolves when the page complete check has finished.
101
124
  */
102
125
  async byPageToComplete() {
103
126
  return this.browser.extraWait(this.pageCompleteCheck);
104
127
  }
105
128
 
106
129
  /**
107
- * Wait for an condition that will eventually return a truthy-value for maxTime.
108
- * @param {string} jsExpression The js code condition to wait for
109
- * @param {number} maxTime Max time to wait in ms
110
- * @returns {Promise} Promise object represents when the expression becomes truthy or the time times out
111
- * @throws Will throw an error if the condition returned false
130
+ * Waits for a JavaScript condition to return a truthy value within a maximum time.
131
+ *
132
+ * @async
133
+ * @param {string} jsExpression - The JavaScript expression to evaluate.
134
+ * @param {number} maxTime - Maximum time to wait in milliseconds.
135
+ * @returns {Promise<void>} A promise that resolves when the condition becomes truthy or the time times out.
136
+ * @throws {Error} Throws an error if the condition is not met within the specified time.
112
137
  */
113
138
  async byCondition(jsExpression, maxTime) {
114
139
  const driver = this.browser.getDriver();