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