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.
Files changed (212) hide show
  1. package/CHANGELOG.md +30 -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/getViewPort.js +6 -1
  42. package/lib/support/statistics.js +11 -1
  43. package/package.json +22 -12
  44. package/types/android/index.d.ts +70 -0
  45. package/types/android/index.d.ts.map +1 -0
  46. package/types/chrome/parseCpuTrace.d.ts +21 -0
  47. package/types/chrome/parseCpuTrace.d.ts.map +1 -0
  48. package/types/chrome/traceCategoriesParser.d.ts +2 -0
  49. package/types/chrome/traceCategoriesParser.d.ts.map +1 -0
  50. package/types/chrome/webdriver/traceUtilities.d.ts +8 -0
  51. package/types/chrome/webdriver/traceUtilities.d.ts.map +1 -0
  52. package/types/core/engine/command/action.d.ts +73 -0
  53. package/types/core/engine/command/action.d.ts.map +1 -0
  54. package/types/core/engine/command/actions.d.ts +38 -0
  55. package/types/core/engine/command/actions.d.ts.map +1 -0
  56. package/types/core/engine/command/addText.d.ts +68 -0
  57. package/types/core/engine/command/addText.d.ts.map +1 -0
  58. package/types/core/engine/command/android.d.ts +39 -0
  59. package/types/core/engine/command/android.d.ts.map +1 -0
  60. package/types/core/engine/command/cache.d.ts +53 -0
  61. package/types/core/engine/command/cache.d.ts.map +1 -0
  62. package/types/core/engine/command/chromeDevToolsProtocol.d.ts +61 -0
  63. package/types/core/engine/command/chromeDevToolsProtocol.d.ts.map +1 -0
  64. package/types/core/engine/command/chromeTrace.d.ts +45 -0
  65. package/types/core/engine/command/chromeTrace.d.ts.map +1 -0
  66. package/types/core/engine/command/click.d.ts +151 -0
  67. package/types/core/engine/command/click.d.ts.map +1 -0
  68. package/types/core/engine/command/debug.d.ts +28 -0
  69. package/types/core/engine/command/debug.d.ts.map +1 -0
  70. package/types/core/engine/command/element.d.ts +49 -0
  71. package/types/core/engine/command/element.d.ts.map +1 -0
  72. package/types/core/engine/command/geckoProfiler.d.ts +46 -0
  73. package/types/core/engine/command/geckoProfiler.d.ts.map +1 -0
  74. package/types/core/engine/command/javaScript.d.ts +63 -0
  75. package/types/core/engine/command/javaScript.d.ts.map +1 -0
  76. package/types/core/engine/command/measure.d.ts +194 -0
  77. package/types/core/engine/command/measure.d.ts.map +1 -0
  78. package/types/core/engine/command/meta.d.ts +23 -0
  79. package/types/core/engine/command/meta.d.ts.map +1 -0
  80. package/types/core/engine/command/mouse/clickAndHold.d.ts +82 -0
  81. package/types/core/engine/command/mouse/clickAndHold.d.ts.map +1 -0
  82. package/types/core/engine/command/mouse/contextClick.d.ts +44 -0
  83. package/types/core/engine/command/mouse/contextClick.d.ts.map +1 -0
  84. package/types/core/engine/command/mouse/doubleClick.d.ts +51 -0
  85. package/types/core/engine/command/mouse/doubleClick.d.ts.map +1 -0
  86. package/types/core/engine/command/mouse/index.d.ts +6 -0
  87. package/types/core/engine/command/mouse/index.d.ts.map +1 -0
  88. package/types/core/engine/command/mouse/mouseMove.d.ts +56 -0
  89. package/types/core/engine/command/mouse/mouseMove.d.ts.map +1 -0
  90. package/types/core/engine/command/mouse/singleClick.d.ts +115 -0
  91. package/types/core/engine/command/mouse/singleClick.d.ts.map +1 -0
  92. package/types/core/engine/command/navigation.d.ts +45 -0
  93. package/types/core/engine/command/navigation.d.ts.map +1 -0
  94. package/types/core/engine/command/screenshot.d.ts +33 -0
  95. package/types/core/engine/command/screenshot.d.ts.map +1 -0
  96. package/types/core/engine/command/scroll.d.ts +52 -0
  97. package/types/core/engine/command/scroll.d.ts.map +1 -0
  98. package/types/core/engine/command/select.d.ts +81 -0
  99. package/types/core/engine/command/select.d.ts.map +1 -0
  100. package/types/core/engine/command/set.d.ts +74 -0
  101. package/types/core/engine/command/set.d.ts.map +1 -0
  102. package/types/core/engine/command/stopWatch.d.ts +49 -0
  103. package/types/core/engine/command/stopWatch.d.ts.map +1 -0
  104. package/types/core/engine/command/switch.d.ts +77 -0
  105. package/types/core/engine/command/switch.d.ts.map +1 -0
  106. package/types/core/engine/command/util/lcpHighlightScript.d.ts +2 -0
  107. package/types/core/engine/command/util/lcpHighlightScript.d.ts.map +1 -0
  108. package/types/core/engine/command/util/lsHighlightScript.d.ts +2 -0
  109. package/types/core/engine/command/util/lsHighlightScript.d.ts.map +1 -0
  110. package/types/core/engine/command/wait.d.ts +74 -0
  111. package/types/core/engine/command/wait.d.ts.map +1 -0
  112. package/types/core/engine/commands.d.ts +161 -0
  113. package/types/core/engine/commands.d.ts.map +1 -0
  114. package/types/core/engine/context.d.ts +87 -0
  115. package/types/core/engine/context.d.ts.map +1 -0
  116. package/types/firefox/geckoProfiler.d.ts +11 -0
  117. package/types/firefox/geckoProfiler.d.ts.map +1 -0
  118. package/types/firefox/settings/geckoProfilerDefaults.d.ts +8 -0
  119. package/types/firefox/settings/geckoProfilerDefaults.d.ts.map +1 -0
  120. package/types/scripting.d.ts +2 -0
  121. package/types/support/engineUtils.d.ts +5 -0
  122. package/types/support/engineUtils.d.ts.map +1 -0
  123. package/types/support/errors.d.ts +15 -0
  124. package/types/support/errors.d.ts.map +1 -0
  125. package/types/support/fileUtil.d.ts +10 -0
  126. package/types/support/fileUtil.d.ts.map +1 -0
  127. package/types/support/filters.d.ts +7 -0
  128. package/types/support/filters.d.ts.map +1 -0
  129. package/types/support/getViewPort.d.ts +2 -0
  130. package/types/support/getViewPort.d.ts.map +1 -0
  131. package/types/support/pathToFolder.d.ts +2 -0
  132. package/types/support/pathToFolder.d.ts.map +1 -0
  133. package/types/support/storageManager.d.ts +17 -0
  134. package/types/support/storageManager.d.ts.map +1 -0
  135. package/types/support/tcpdump.d.ts +10 -0
  136. package/types/support/tcpdump.d.ts.map +1 -0
  137. package/types/support/userTiming.d.ts +2 -0
  138. package/types/support/userTiming.d.ts.map +1 -0
  139. package/types/support/util.d.ts +6 -0
  140. package/types/support/util.d.ts.map +1 -0
  141. package/types/video/defaults.d.ts +7 -0
  142. package/types/video/defaults.d.ts.map +1 -0
  143. package/types/video/postprocessing/finetune/addTextToVideo.d.ts +2 -0
  144. package/types/video/postprocessing/finetune/addTextToVideo.d.ts.map +1 -0
  145. package/types/video/postprocessing/finetune/convertFps.d.ts +2 -0
  146. package/types/video/postprocessing/finetune/convertFps.d.ts.map +1 -0
  147. package/types/video/postprocessing/finetune/getFont.d.ts +2 -0
  148. package/types/video/postprocessing/finetune/getFont.d.ts.map +1 -0
  149. package/types/video/postprocessing/finetune/getTimingMetrics.d.ts +2 -0
  150. package/types/video/postprocessing/finetune/getTimingMetrics.d.ts.map +1 -0
  151. package/types/video/postprocessing/finetune/index.d.ts +2 -0
  152. package/types/video/postprocessing/finetune/index.d.ts.map +1 -0
  153. package/types/video/postprocessing/finetune/removeOrange.d.ts +2 -0
  154. package/types/video/postprocessing/finetune/removeOrange.d.ts.map +1 -0
  155. package/types/video/postprocessing/visualmetrics/extraMetrics.d.ts +5 -0
  156. package/types/video/postprocessing/visualmetrics/extraMetrics.d.ts.map +1 -0
  157. package/types/video/postprocessing/visualmetrics/getVideoMetrics.d.ts +5 -0
  158. package/types/video/postprocessing/visualmetrics/getVideoMetrics.d.ts.map +1 -0
  159. package/types/video/postprocessing/visualmetrics/visualMetrics.d.ts +3 -0
  160. package/types/video/postprocessing/visualmetrics/visualMetrics.d.ts.map +1 -0
  161. package/types/video/screenRecording/android/recorder.d.ts +11 -0
  162. package/types/video/screenRecording/android/recorder.d.ts.map +1 -0
  163. package/types/video/screenRecording/desktop/convert.d.ts +2 -0
  164. package/types/video/screenRecording/desktop/convert.d.ts.map +1 -0
  165. package/types/video/screenRecording/desktop/desktopRecorder.d.ts +28 -0
  166. package/types/video/screenRecording/desktop/desktopRecorder.d.ts.map +1 -0
  167. package/types/video/screenRecording/desktop/ffmpegRecorder.d.ts +17 -0
  168. package/types/video/screenRecording/desktop/ffmpegRecorder.d.ts.map +1 -0
  169. package/types/video/screenRecording/desktop/osx/getSPDisplaysDataType.d.ts +2 -0
  170. package/types/video/screenRecording/desktop/osx/getSPDisplaysDataType.d.ts.map +1 -0
  171. package/types/video/screenRecording/desktop/osx/getScreen.d.ts +2 -0
  172. package/types/video/screenRecording/desktop/osx/getScreen.d.ts.map +1 -0
  173. package/types/video/screenRecording/firefox/firefoxWindowRecorder.d.ts +13 -0
  174. package/types/video/screenRecording/firefox/firefoxWindowRecorder.d.ts.map +1 -0
  175. package/types/video/screenRecording/ios/convertToMp4.d.ts +2 -0
  176. package/types/video/screenRecording/ios/convertToMp4.d.ts.map +1 -0
  177. package/types/video/screenRecording/ios/iosRecorder.d.ts +14 -0
  178. package/types/video/screenRecording/ios/iosRecorder.d.ts.map +1 -0
  179. package/types/video/screenRecording/iosSimulator/convertToMp4.d.ts +2 -0
  180. package/types/video/screenRecording/iosSimulator/convertToMp4.d.ts.map +1 -0
  181. package/types/video/screenRecording/iosSimulator/recorder.d.ts +9 -0
  182. package/types/video/screenRecording/iosSimulator/recorder.d.ts.map +1 -0
  183. package/types/video/screenRecording/recorder.d.ts +7 -0
  184. package/types/video/screenRecording/recorder.d.ts.map +1 -0
  185. package/types/video/screenRecording/setOrangeBackground.d.ts +2 -0
  186. package/types/video/screenRecording/setOrangeBackground.d.ts.map +1 -0
  187. package/types/video/video.d.ts +41 -0
  188. package/types/video/video.d.ts.map +1 -0
  189. package/browsersupport/firefox-profile/cert9.db +0 -0
  190. package/browsersupport/firefox-profile/chrome/userChrome.css +0 -4
  191. package/browsersupport/firefox-profile/key4.db +0 -0
  192. package/vendor/mac/x86/qvh +0 -0
  193. package/visualmetrics/__init__.py +0 -1
  194. package/visualmetrics/test_data/ms_000000.png +0 -0
  195. package/visualmetrics/test_data/ms_000920.png +0 -0
  196. package/visualmetrics/test_data/ms_001000.png +0 -0
  197. package/visualmetrics/test_data/ms_001080.png +0 -0
  198. package/visualmetrics/test_data/ms_001200.png +0 -0
  199. package/visualmetrics/test_data/ms_001240.png +0 -0
  200. package/visualmetrics/test_data/ms_001280.png +0 -0
  201. package/visualmetrics/test_data/ms_001360.png +0 -0
  202. package/visualmetrics/test_data/ms_001400.png +0 -0
  203. package/visualmetrics/test_data/ms_001520.png +0 -0
  204. package/visualmetrics/test_data/ms_002040.png +0 -0
  205. package/visualmetrics/test_data/ms_002600.png +0 -0
  206. package/visualmetrics/test_data/ms_003160.png +0 -0
  207. package/visualmetrics/test_data/ms_003720.png +0 -0
  208. package/visualmetrics/test_data/ms_004280.png +0 -0
  209. package/visualmetrics/test_data/ms_004880.png +0 -0
  210. package/visualmetrics/test_data/ms_005440.png +0 -0
  211. package/visualmetrics/test_data/ms_006000.png +0 -0
  212. package/visualmetrics/test_visualmetrics.py +0 -34
@@ -1,18 +1,37 @@
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 single click action on elements or at specific positions in a web page. Uses Seleniums Action API.
7
+ *
8
+ * @hideconstructor
9
+ * @class
10
+ */
4
11
  export class SingleClick {
5
12
  constructor(browser, pageCompleteCheck) {
13
+ /**
14
+ * @private
15
+ */
6
16
  this.browser = browser;
17
+ /**
18
+ * @private
19
+ */
7
20
  this.actions = this.browser.getDriver().actions({ async: true });
21
+ /**
22
+ * @private
23
+ */
8
24
  this.pageCompleteCheck = pageCompleteCheck;
9
25
  }
10
26
 
11
27
  /**
12
- * Perform mouse single click on an element matches a XPath selector.
13
- * @param {string} xpath
14
- * @returns {Promise} Promise object represents when the element has been clicked.
15
- * @throws Will throw an error if the element is not found.
28
+ * Performs a single mouse click on an element matching a given XPath selector.
29
+ *
30
+ * @async
31
+ * @param {string} xpath - The XPath selector of the element to click.
32
+ * @param {Object} [options] - Additional options for the click action.
33
+ * @returns {Promise<void>} A promise that resolves when the single click action is performed.
34
+ * @throws {Error} Throws an error if the element is not found.
16
35
  */
17
36
  async byXpath(xpath, options) {
18
37
  try {
@@ -21,6 +40,9 @@ export class SingleClick {
21
40
  .findElement(By.xpath(xpath));
22
41
  await this.actions.click(element).perform();
23
42
  if (options && 'wait' in options && options.wait === true) {
43
+ log.warn(
44
+ 'Please use the byXpathAndWait method instead. We want to deprecate and remove the options from this method so we follow the same pattern everywhere.'
45
+ );
24
46
  return this.browser.extraWait(this.pageCompleteCheck);
25
47
  }
26
48
  } catch (error) {
@@ -31,10 +53,35 @@ export class SingleClick {
31
53
  }
32
54
 
33
55
  /**
34
- * Perform mouse single click on an element matches a CSS selector.
35
- * @param {string} selector
36
- * @returns {Promise} Promise object represents when the element has been clicked.
37
- * @throws Will throw an error if the element is not found.
56
+ * Performs a single mouse click on an element matching a given XPath selector and wait for page complete check.
57
+ *
58
+ * @async
59
+ * @param {string} xpath - The XPath selector of the element to click.
60
+ * @returns {Promise<void>} A promise that resolves when the single click action is performed.
61
+ * @throws {Error} Throws an error if the element is not found.
62
+ */
63
+ async byXpathAndWait(xpath) {
64
+ try {
65
+ const element = await this.browser
66
+ .getDriver()
67
+ .findElement(By.xpath(xpath));
68
+ await this.actions.click(element).perform();
69
+ return this.browser.extraWait(this.pageCompleteCheck);
70
+ } catch (error) {
71
+ log.error('Could not single click on element with xpath %s', xpath);
72
+ log.verbose(error);
73
+ throw new Error('Could not single click on element with xpath ' + xpath);
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Performs a single mouse click on an element matching a given CSS selector.
79
+ *
80
+ * @async
81
+ * @param {string} selector - The CSS selector of the element to click.
82
+ * @param {Object} [options] - Additional options for the click action.
83
+ * @returns {Promise<void>} A promise that resolves when the single click action is performed.
84
+ * @throws {Error} Throws an error if the element is not found.
38
85
  */
39
86
  async bySelector(selector, options) {
40
87
  try {
@@ -43,6 +90,9 @@ export class SingleClick {
43
90
  .findElement(By.css(selector));
44
91
  await this.actions.click(element).perform();
45
92
  if (options && 'wait' in options && options.wait === true) {
93
+ log.warn(
94
+ 'Please use the bySelectorAndWait method instead. We want to deprecate and remove the options from this method so we follow the same pattern everywhere.'
95
+ );
46
96
  return this.browser.extraWait(this.pageCompleteCheck);
47
97
  }
48
98
  } catch (error) {
@@ -55,15 +105,44 @@ export class SingleClick {
55
105
  }
56
106
 
57
107
  /**
58
- * Perform mouse single click at the cursor's position.
59
- * @param {string} xpath
60
- * @returns {Promise} Promise object represents when double click occurs.
61
- * @throws Will throw an error if double click cannot be performed.
108
+ * Performs a single mouse click on an element matching a given CSS selector and waits on the page complete check.
109
+ *
110
+ * @async
111
+ * @param {string} selector - The CSS selector of the element to click.
112
+ * @returns {Promise<void>} A promise that resolves when the single click action is performed.
113
+ * @throws {Error} Throws an error if the element is not found.
114
+ */
115
+ async bySelectorAndWait(selector) {
116
+ try {
117
+ const element = await this.browser
118
+ .getDriver()
119
+ .findElement(By.css(selector));
120
+ await this.actions.click(element).perform();
121
+ return this.browser.extraWait(this.pageCompleteCheck);
122
+ } catch (error) {
123
+ log.error('Could not single click on element with selector %s', selector);
124
+ log.verbose(error);
125
+ throw new Error(
126
+ 'Could not single click on element with selector ' + selector
127
+ );
128
+ }
129
+ }
130
+
131
+ /**
132
+ * Performs a single mouse click at the current cursor position.
133
+ *
134
+ * @async
135
+ * @param {Object} [options] - Additional options for the click action.
136
+ * @returns {Promise<void>} A promise that resolves when the single click occurs.
137
+ * @throws {Error} Throws an error if the single click action cannot be performed.
62
138
  */
63
139
  async atCursor(options) {
64
140
  try {
65
141
  await this.actions.click().perform();
66
142
  if (options && 'wait' in options && options.wait === true) {
143
+ log.warn(
144
+ 'Please use the atCursorAndWait method instead.We want to deprecate and remove the options from this method so we follow the same pattern everywhere.'
145
+ );
67
146
  return this.browser.extraWait(this.pageCompleteCheck);
68
147
  }
69
148
  } catch (error) {
@@ -72,4 +151,100 @@ export class SingleClick {
72
151
  throw new Error('Could not perform single click');
73
152
  }
74
153
  }
154
+
155
+ /**
156
+ * Performs a single mouse click at the current cursor position and waits on the
157
+ * page complete check.
158
+ *
159
+ * @async
160
+ * @returns {Promise<void>} A promise that resolves when the single click occurs.
161
+ * @throws {Error} Throws an error if the single click action cannot be performed.
162
+ */
163
+ async atCursorAndWait() {
164
+ try {
165
+ await this.actions.click().perform();
166
+ return this.browser.extraWait(this.pageCompleteCheck);
167
+ } catch (error) {
168
+ log.error('Could not perform single click');
169
+ log.verbose(error);
170
+ throw new Error('Could not perform single click');
171
+ }
172
+ }
173
+
174
+ /**
175
+ * Clicks on a link whose visible text matches the given string.
176
+ *
177
+ * @async
178
+ * @param {string} text - The visible text of the link to click.
179
+ * @returns {Promise<void>} A promise that resolves when the click action is performed.
180
+ * @throws {Error} Throws an error if the link is not found.
181
+ */
182
+ async byLinkText(text) {
183
+ try {
184
+ const xpath = `//a[text()='${text}']`;
185
+ return this.byXpath(xpath);
186
+ } catch (error) {
187
+ log.error('Could not find link by text %s', text);
188
+ log.verbose(error);
189
+ throw new Error('Could not find link by text ' + text);
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Clicks on a link whose visible text matches the given string and waits on the opage complete check.
195
+ *
196
+ * @async
197
+ * @param {string} text - The visible text of the link to click.
198
+ * @returns {Promise<void>} A promise that resolves when the click action is performed.
199
+ * @throws {Error} Throws an error if the link is not found.
200
+ */
201
+ async byLinkTextAndWait(text) {
202
+ try {
203
+ const xpath = `//a[text()='${text}']`;
204
+ return this.byXpathAndWait(xpath);
205
+ } catch (error) {
206
+ log.error('Could not find link by text %s', text);
207
+ log.verbose(error);
208
+ throw new Error('Could not find link by text ' + text);
209
+ }
210
+ }
211
+
212
+ /**
213
+ * Clicks on a link whose visible text contains the given substring.
214
+ *
215
+ * @async
216
+ * @param {string} text - The substring of the visible text of the link to click.
217
+ * @returns {Promise<void>} A promise that resolves when the click action is performed.
218
+ * @throws {Error} Throws an error if the link is not found.
219
+ */
220
+ async byPartialLinkText(text) {
221
+ try {
222
+ const xpath = `//a[contains(text(),'${text}')]`;
223
+ return this.byXpath(xpath);
224
+ } catch (error) {
225
+ log.error('Could not find link by partial text %s', text);
226
+ log.verbose(error);
227
+ throw new Error('Could not find link by partial text ' + text);
228
+ }
229
+ }
230
+
231
+ /**
232
+ * Clicks on a link whose visible text contains the given substring and waits on the
233
+ * page complete checl.
234
+ *
235
+ * @async
236
+ * @param {string} text - The substring of the visible text of the link to click.
237
+ * @returns {Promise<void>} A promise that resolves when the click action is performed.
238
+ * @throws {Error} Throws an error if the link is not found.
239
+ */
240
+ async byPartialLinkTextAndWait(text) {
241
+ try {
242
+ const xpath = `//a[contains(text(),'${text}')]`;
243
+ return this.byXpathAndWait(xpath);
244
+ } catch (error) {
245
+ log.error('Could not find link by partial text %s', text);
246
+ log.verbose(error);
247
+ throw new Error('Could not find link by partial text ' + text);
248
+ }
249
+ }
75
250
  }
@@ -1,14 +1,32 @@
1
1
  import intel from 'intel';
2
2
  const log = intel.getLogger('browsertime.command.navigation');
3
3
 
4
+ /**
5
+ * Provides functionality to control browser navigation such as back, forward, and refresh actions.
6
+ *
7
+ * @class
8
+ * @hideconstructor
9
+ */
10
+
4
11
  export class Navigation {
5
12
  constructor(browser, pageCompleteCheck) {
13
+ /**
14
+ * @private
15
+ */
6
16
  this.browser = browser;
17
+ /**
18
+ * @private
19
+ */
7
20
  this.pageCompleteCheck = pageCompleteCheck;
8
21
  }
9
22
 
10
23
  /**
11
- * Navigate backward in history
24
+ * Navigates backward in the browser's history.
25
+ *
26
+ * @async
27
+ * @param {Object} [options] - Additional options for navigation. Set {wait:true} to wait for the page complete check to run.
28
+ * @returns {Promise<void>} A promise that resolves when the navigation action is completed.
29
+ * @throws {Error} Throws an error if navigation fails.
12
30
  */
13
31
  async back(options) {
14
32
  const driver = this.browser.getDriver();
@@ -25,7 +43,12 @@ export class Navigation {
25
43
  }
26
44
 
27
45
  /**
28
- * Navigate forward in history
46
+ * Navigates forward in the browser's history.
47
+ *
48
+ * @async
49
+ * @param {Object} [options] - Additional options for navigation. Set {wait:true} to wait for the page complete check to run.
50
+ * @returns {Promise<void>} A promise that resolves when the navigation action is completed.
51
+ * @throws {Error} Throws an error if navigation fails.
29
52
  */
30
53
  async forward(options) {
31
54
  const driver = this.browser.getDriver();
@@ -42,7 +65,12 @@ export class Navigation {
42
65
  }
43
66
 
44
67
  /**
45
- * Refresh page
68
+ * Refreshes the current page.
69
+ *
70
+ * @async
71
+ * @param {Object} [options] - Additional options for refresh action. Set {wait:true} to wait for the page complete check to run.
72
+ * @returns {Promise<void>} A promise that resolves when the page has been refreshed.
73
+ * @throws {Error} Throws an error if refreshing the page fails.
46
74
  */
47
75
  async refresh(options) {
48
76
  const driver = this.browser.getDriver();
@@ -1,11 +1,44 @@
1
+ import intel from 'intel';
2
+ const log = intel.getLogger('browsertime.command.screenshot');
3
+
4
+ /**
5
+ * Take a screenshot. The screenshot will be stored to disk,
6
+ * named by the name provided to the take function.
7
+ *
8
+ * @class
9
+ * @hideconstructor
10
+ */
1
11
  export class Screenshot {
2
12
  constructor(screenshotManager, browser, index) {
13
+ /**
14
+ * @private
15
+ */
3
16
  this.screenshotManager = screenshotManager;
17
+ /**
18
+ * @private
19
+ */
4
20
  this.browser = browser;
21
+ /**
22
+ * @private
23
+ */
5
24
  this.index = index;
6
25
  }
7
26
 
27
+ /**
28
+ * Takes a screenshot and saves it using the screenshot manager.
29
+ *
30
+ * @async
31
+ * @example async commands.screenshot.take('my_startpage');
32
+ * @param {string} name The name to assign to the screenshot file.
33
+ * @throws {Error} Throws an error if the name parameter is not provided.
34
+ * @returns {Promise<Object>} A promise that resolves with the screenshot details.
35
+ */
36
+
8
37
  async take(name) {
38
+ if (!name) {
39
+ log.error('Missing name for the screenshot');
40
+ throw new Error(`Could not store screenshot for missing name`);
41
+ }
9
42
  const url = await this.browser
10
43
  .getDriver()
11
44
  .executeScript('return document.documentURI;');
@@ -1,16 +1,32 @@
1
1
  import intel from 'intel';
2
2
  const log = intel.getLogger('browsertime.command.scroll');
3
3
  const delay = ms => new Promise(res => setTimeout(res, ms));
4
+
5
+ /**
6
+ * Provides functionality to control page scrolling in the browser.
7
+ *
8
+ * @class
9
+ * @hideconstructor
10
+ */
4
11
  export class Scroll {
5
12
  constructor(browser, options) {
13
+ /**
14
+ * @private
15
+ */
6
16
  this.browser = browser;
17
+ /**
18
+ * @private
19
+ */
7
20
  this.options = options;
8
21
  }
9
22
 
10
23
  /**
11
- * Scroll the page by the specified pixels.
12
- * @param {number} X pixels and Y pixels
13
- * @returns {Promise} Promise object represents when scrolling the page has been
24
+ * Scrolls the page by the specified number of pixels.
25
+ *
26
+ * @async
27
+ * @param {number} Xpixels - The number of pixels to scroll horizontally.
28
+ * @param {number} Ypixels - The number of pixels to scroll vertically.
29
+ * @returns {Promise<void>} A promise that resolves when the scrolling action is completed.
14
30
  */
15
31
  async byPixels(Xpixels, Ypixels) {
16
32
  const script = `window.scrollBy(${Xpixels}, ${Ypixels});`;
@@ -18,10 +34,12 @@ export class Scroll {
18
34
  }
19
35
 
20
36
  /**
21
- * Scroll the page by the specified lines. Only supported by Firefox.
22
- * @param {number} Lines
23
- * @returns {Promise} Promise object represents when scrolling the page has been finished.
24
- * @throws Will throw an error if window.scrollByLines generates an error.
37
+ * Scrolls the page by the specified number of lines. This method is only supported in Firefox.
38
+ *
39
+ * @async
40
+ * @param {number} lines - The number of lines to scroll.
41
+ * @returns {Promise<void>} A promise that resolves when the scrolling action is completed.
42
+ * @throws {Error} Throws an error if not used in Firefox.
25
43
  */
26
44
  async byLines(lines) {
27
45
  if (this.options.browser !== 'firefox') {
@@ -38,9 +56,11 @@ export class Scroll {
38
56
  }
39
57
 
40
58
  /**
41
- * Scroll the page by the specified pages.
42
- * @param {number} Pages
43
- * @returns {Promise} Promise object represents when scrolling the page has been finished.
59
+ * Scrolls the page by the specified number of pages.
60
+ *
61
+ * @async
62
+ * @param {number} pages - The number of pages to scroll.
63
+ * @returns {Promise<void>} A promise that resolves when the scrolling action is completed.
44
64
  */
45
65
  async byPages(pages) {
46
66
  if (this.options.browser === 'firefox') {
@@ -55,9 +75,11 @@ export class Scroll {
55
75
  }
56
76
 
57
77
  /**
58
- * Scroll to the bottom of the page. Will scroll page by page and wait the delayTime between each scroll. Default delay time is 250 ms
59
- * @param {number} delayTime
60
- * @returns {Promise} Promise object represents when scrolling the page has been finished.
78
+ * Scrolls to the bottom of the page, scrolling page by page with a delay between each scroll.
79
+ *
80
+ * @async
81
+ * @param {number} [delayTime=250] - The delay time in milliseconds between each scroll.
82
+ * @returns {Promise<void>} A promise that resolves when the scrolling to the bottom is completed.
61
83
  */
62
84
  async toBottom(delayTime = 250) {
63
85
  const pages = await this.browser.runScript(
@@ -1,18 +1,28 @@
1
1
  import intel from 'intel';
2
2
  const log = intel.getLogger('browsertime.command.select');
3
3
 
4
+ /**
5
+ * Provides functionality to interact with `<select>` elements on a web page.
6
+ *
7
+ * @class
8
+ * @hideconstructor
9
+ */
4
10
  export class Select {
5
11
  constructor(browser) {
12
+ /**
13
+ * @private
14
+ */
6
15
  this.browser = browser;
7
16
  }
8
17
 
9
18
  /**
10
- * Select value of a select by the selects id
11
- * @param {string} selectId The id of the select
12
- * @param {string} value The value of the option you want to set
13
- * @returns {Promise} Promise object represents when the option has been
14
- * set to the element
15
- * @throws Will throw an error if the select is not found
19
+ * Selects an option in a `<select>` element by its ID and the value of the option.
20
+ *
21
+ * @async
22
+ * @param {string} selectId - The ID of the `<select>` element.
23
+ * @param {string} value - The value of the option to select.
24
+ * @returns {Promise<void>} A promise that resolves when the option is selected.
25
+ * @throws {Error} Throws an error if the `<select>` element is not found.
16
26
  */
17
27
  async selectByIdAndValue(selectId, value) {
18
28
  try {
@@ -26,12 +36,13 @@ export class Select {
26
36
  }
27
37
 
28
38
  /**
29
- * Select value of a select by the selects name
30
- * @param {string} selectName The name of the select
31
- * @param {string} value The value of the option you want to set
32
- * @returns {Promise} Promise object represents when the option has been
33
- * set to the element
34
- * @throws Will throw an error if the select is not found
39
+ * Selects an option in a `<select>` element by its name and the value of the option.
40
+ *
41
+ * @async
42
+ * @param {string} selectName - The name of the `<select>` element.
43
+ * @param {string} value - The value of the option to select.
44
+ * @returns {Promise<void>} A promise that resolves when the option is selected.
45
+ * @throws {Error} Throws an error if the `<select>` element is not found.
35
46
  */
36
47
  async selectByNameAndValue(selectName, value) {
37
48
  try {
@@ -47,12 +58,13 @@ export class Select {
47
58
  }
48
59
 
49
60
  /**
50
- * Select value of a select index and by the selects id
51
- * @param {string} selectId The id of the select
52
- * @param {number} index the index of the option you want to set
53
- * @returns {Promise} Promise object represents when the option has been
54
- * set to the element
55
- * @throws Will throw an error if the select is not found
61
+ * Selects an option in a `<select>` element by its ID and the index of the option.
62
+ *
63
+ * @async
64
+ * @param {string} selectId - The ID of the `<select>` element.
65
+ * @param {number} index - The index of the option to select.
66
+ * @returns {Promise<void>} A promise that resolves when the option is selected.
67
+ * @throws {Error} Throws an error if the `<select>` element is not found.
56
68
  */
57
69
  async selectByIdAndIndex(selectId, index) {
58
70
  try {
@@ -70,12 +82,13 @@ export class Select {
70
82
  }
71
83
 
72
84
  /**
73
- * Select value of a select index and by the selects name
74
- * @param {string} selectName - the name of the select
75
- * @param {number} index - the index of the option you want to set
76
- * @returns {Promise} Promise object represents when the option has been
77
- * set to the element
78
- * @throws Will throw an error if the select is not found
85
+ * Selects an option in a `<select>` element by its name and the index of the option.
86
+ *
87
+ * @async
88
+ * @param {string} selectName - The name of the `<select>` element.
89
+ * @param {number} index - The index of the option to select.
90
+ * @returns {Promise<void>} A promise that resolves when the option is selected.
91
+ * @throws {Error} Throws an error if the `<select>` element is not found.
79
92
  */
80
93
  async selectByNameAndIndex(selectName, index) {
81
94
  try {
@@ -93,10 +106,12 @@ export class Select {
93
106
  }
94
107
 
95
108
  /**
96
- * Deselect all options in a select.
97
- * @param {string} selectId
98
- * @returns {Promise} Promise object represents when options been deselected
99
- * @throws Will throw an error if the select is not found
109
+ * Deselects all options in a `<select>` element by its ID.
110
+ *
111
+ * @async
112
+ * @param {string} selectId - The ID of the `<select>` element.
113
+ * @returns {Promise<void>} A promise that resolves when all options are deselected.
114
+ * @throws {Error} Throws an error if the `<select>` element is not found.
100
115
  */
101
116
  async deselectById(selectId) {
102
117
  try {
@@ -111,10 +126,12 @@ export class Select {
111
126
  }
112
127
 
113
128
  /**
114
- * Get all option values in a select.
115
- * @param {string} selectId - the id of the select.
116
- * @returns {Promise} Promise object tha will return an array with the values of the select
117
- * @throws Will throw an error if the select is not found
129
+ * Retrieves all option values in a `<select>` element by its ID.
130
+ *
131
+ * @async
132
+ * @param {string} selectId - The ID of the `<select>` element.
133
+ * @returns {Promise<string[]>} A promise that resolves with an array of the values of the options.
134
+ * @throws {Error} Throws an error if the `<select>` element is not found.
118
135
  */
119
136
  async getValuesById(selectId) {
120
137
  const script = `const select = document.getElementById('${selectId}');
@@ -136,10 +153,12 @@ export class Select {
136
153
  }
137
154
 
138
155
  /**
139
- * Get the selected option value in a select.
140
- * @param {select} selectId the id of the select.
141
- * @returns {Promise} Promise object tha will return the value of the selected option.
142
- * @throws Will throw an error if the select is not found.
156
+ * Retrieves the value of the selected option in a `<select>` element by its ID.
157
+ *
158
+ * @async
159
+ * @param {string} selectId - The ID of the `<select>` element.
160
+ * @returns {Promise<string>} A promise that resolves with the value of the selected option.
161
+ * @throws {Error} Throws an error if the `<select>` element is not found.
143
162
  */
144
163
  async getSelectedValueById(selectId) {
145
164
  try {