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.
- package/CHANGELOG.md +23 -0
- package/README.md +2 -2
- package/bin/browsertime.js +9 -3
- package/browserscripts/pageinfo/interactionToNextPaintInfo.js +170 -143
- package/browserscripts/timings/interactionToNextPaint.js +49 -137
- package/lib/chrome/webdriver/setupChromiumOptions.js +0 -9
- package/lib/core/engine/collector.js +11 -0
- package/lib/core/engine/command/actions.js +52 -0
- package/lib/core/engine/command/addText.js +48 -30
- package/lib/core/engine/command/android.js +43 -4
- package/lib/core/engine/command/cache.js +39 -2
- package/lib/core/engine/command/chromeDevToolsProtocol.js +51 -1
- package/lib/core/engine/command/chromeTrace.js +34 -0
- package/lib/core/engine/command/click.js +102 -52
- package/lib/core/engine/command/debug.js +19 -2
- package/lib/core/engine/command/element.js +66 -0
- package/lib/core/engine/command/geckoProfiler.js +41 -1
- package/lib/core/engine/command/javaScript.js +43 -20
- package/lib/core/engine/command/measure.js +147 -15
- package/lib/core/engine/command/meta.js +17 -0
- package/lib/core/engine/command/mouse/clickAndHold.js +56 -29
- package/lib/core/engine/command/mouse/contextClick.js +30 -11
- package/lib/core/engine/command/mouse/doubleClick.js +35 -11
- package/lib/core/engine/command/mouse/mouseMove.js +38 -16
- package/lib/core/engine/command/mouse/singleClick.js +187 -12
- package/lib/core/engine/command/navigation.js +31 -3
- package/lib/core/engine/command/screenshot.js +33 -0
- package/lib/core/engine/command/scroll.js +35 -13
- package/lib/core/engine/command/select.js +55 -36
- package/lib/core/engine/command/set.js +51 -36
- package/lib/core/engine/command/stopWatch.js +30 -9
- package/lib/core/engine/command/switch.js +49 -11
- package/lib/core/engine/command/wait.js +50 -25
- package/lib/core/engine/commands.js +267 -0
- package/lib/core/engine/context.js +81 -0
- package/lib/core/engine/iteration.js +20 -102
- package/lib/firefox/geckoProfiler.js +49 -1
- package/lib/firefox/webdriver/builder.js +4 -9
- package/lib/firefox/webdriver/firefox.js +1 -1
- package/lib/support/cli.js +7 -0
- package/lib/support/statistics.js +11 -1
- package/package.json +17 -7
- package/types/android/index.d.ts +70 -0
- package/types/android/index.d.ts.map +1 -0
- package/types/chrome/parseCpuTrace.d.ts +21 -0
- package/types/chrome/parseCpuTrace.d.ts.map +1 -0
- package/types/chrome/traceCategoriesParser.d.ts +2 -0
- package/types/chrome/traceCategoriesParser.d.ts.map +1 -0
- package/types/chrome/webdriver/traceUtilities.d.ts +8 -0
- package/types/chrome/webdriver/traceUtilities.d.ts.map +1 -0
- package/types/core/engine/command/action.d.ts +73 -0
- package/types/core/engine/command/action.d.ts.map +1 -0
- package/types/core/engine/command/actions.d.ts +38 -0
- package/types/core/engine/command/actions.d.ts.map +1 -0
- package/types/core/engine/command/addText.d.ts +68 -0
- package/types/core/engine/command/addText.d.ts.map +1 -0
- package/types/core/engine/command/android.d.ts +39 -0
- package/types/core/engine/command/android.d.ts.map +1 -0
- package/types/core/engine/command/cache.d.ts +53 -0
- package/types/core/engine/command/cache.d.ts.map +1 -0
- package/types/core/engine/command/chromeDevToolsProtocol.d.ts +61 -0
- package/types/core/engine/command/chromeDevToolsProtocol.d.ts.map +1 -0
- package/types/core/engine/command/chromeTrace.d.ts +45 -0
- package/types/core/engine/command/chromeTrace.d.ts.map +1 -0
- package/types/core/engine/command/click.d.ts +151 -0
- package/types/core/engine/command/click.d.ts.map +1 -0
- package/types/core/engine/command/debug.d.ts +28 -0
- package/types/core/engine/command/debug.d.ts.map +1 -0
- package/types/core/engine/command/element.d.ts +49 -0
- package/types/core/engine/command/element.d.ts.map +1 -0
- package/types/core/engine/command/geckoProfiler.d.ts +46 -0
- package/types/core/engine/command/geckoProfiler.d.ts.map +1 -0
- package/types/core/engine/command/javaScript.d.ts +63 -0
- package/types/core/engine/command/javaScript.d.ts.map +1 -0
- package/types/core/engine/command/measure.d.ts +194 -0
- package/types/core/engine/command/measure.d.ts.map +1 -0
- package/types/core/engine/command/meta.d.ts +23 -0
- package/types/core/engine/command/meta.d.ts.map +1 -0
- package/types/core/engine/command/mouse/clickAndHold.d.ts +82 -0
- package/types/core/engine/command/mouse/clickAndHold.d.ts.map +1 -0
- package/types/core/engine/command/mouse/contextClick.d.ts +44 -0
- package/types/core/engine/command/mouse/contextClick.d.ts.map +1 -0
- package/types/core/engine/command/mouse/doubleClick.d.ts +51 -0
- package/types/core/engine/command/mouse/doubleClick.d.ts.map +1 -0
- package/types/core/engine/command/mouse/index.d.ts +6 -0
- package/types/core/engine/command/mouse/index.d.ts.map +1 -0
- package/types/core/engine/command/mouse/mouseMove.d.ts +56 -0
- package/types/core/engine/command/mouse/mouseMove.d.ts.map +1 -0
- package/types/core/engine/command/mouse/singleClick.d.ts +115 -0
- package/types/core/engine/command/mouse/singleClick.d.ts.map +1 -0
- package/types/core/engine/command/navigation.d.ts +45 -0
- package/types/core/engine/command/navigation.d.ts.map +1 -0
- package/types/core/engine/command/screenshot.d.ts +33 -0
- package/types/core/engine/command/screenshot.d.ts.map +1 -0
- package/types/core/engine/command/scroll.d.ts +52 -0
- package/types/core/engine/command/scroll.d.ts.map +1 -0
- package/types/core/engine/command/select.d.ts +81 -0
- package/types/core/engine/command/select.d.ts.map +1 -0
- package/types/core/engine/command/set.d.ts +74 -0
- package/types/core/engine/command/set.d.ts.map +1 -0
- package/types/core/engine/command/stopWatch.d.ts +49 -0
- package/types/core/engine/command/stopWatch.d.ts.map +1 -0
- package/types/core/engine/command/switch.d.ts +77 -0
- package/types/core/engine/command/switch.d.ts.map +1 -0
- package/types/core/engine/command/util/lcpHighlightScript.d.ts +2 -0
- package/types/core/engine/command/util/lcpHighlightScript.d.ts.map +1 -0
- package/types/core/engine/command/util/lsHighlightScript.d.ts +2 -0
- package/types/core/engine/command/util/lsHighlightScript.d.ts.map +1 -0
- package/types/core/engine/command/wait.d.ts +74 -0
- package/types/core/engine/command/wait.d.ts.map +1 -0
- package/types/core/engine/commands.d.ts +161 -0
- package/types/core/engine/commands.d.ts.map +1 -0
- package/types/core/engine/context.d.ts +87 -0
- package/types/core/engine/context.d.ts.map +1 -0
- package/types/firefox/geckoProfiler.d.ts +11 -0
- package/types/firefox/geckoProfiler.d.ts.map +1 -0
- package/types/firefox/settings/geckoProfilerDefaults.d.ts +8 -0
- package/types/firefox/settings/geckoProfilerDefaults.d.ts.map +1 -0
- package/types/scripting.d.ts +2 -0
- package/types/support/engineUtils.d.ts +5 -0
- package/types/support/engineUtils.d.ts.map +1 -0
- package/types/support/errors.d.ts +15 -0
- package/types/support/errors.d.ts.map +1 -0
- package/types/support/fileUtil.d.ts +10 -0
- package/types/support/fileUtil.d.ts.map +1 -0
- package/types/support/filters.d.ts +7 -0
- package/types/support/filters.d.ts.map +1 -0
- package/types/support/getViewPort.d.ts +2 -0
- package/types/support/getViewPort.d.ts.map +1 -0
- package/types/support/pathToFolder.d.ts +2 -0
- package/types/support/pathToFolder.d.ts.map +1 -0
- package/types/support/storageManager.d.ts +17 -0
- package/types/support/storageManager.d.ts.map +1 -0
- package/types/support/tcpdump.d.ts +10 -0
- package/types/support/tcpdump.d.ts.map +1 -0
- package/types/support/userTiming.d.ts +2 -0
- package/types/support/userTiming.d.ts.map +1 -0
- package/types/support/util.d.ts +6 -0
- package/types/support/util.d.ts.map +1 -0
- package/types/video/defaults.d.ts +7 -0
- package/types/video/defaults.d.ts.map +1 -0
- package/types/video/postprocessing/finetune/addTextToVideo.d.ts +2 -0
- package/types/video/postprocessing/finetune/addTextToVideo.d.ts.map +1 -0
- package/types/video/postprocessing/finetune/convertFps.d.ts +2 -0
- package/types/video/postprocessing/finetune/convertFps.d.ts.map +1 -0
- package/types/video/postprocessing/finetune/getFont.d.ts +2 -0
- package/types/video/postprocessing/finetune/getFont.d.ts.map +1 -0
- package/types/video/postprocessing/finetune/getTimingMetrics.d.ts +2 -0
- package/types/video/postprocessing/finetune/getTimingMetrics.d.ts.map +1 -0
- package/types/video/postprocessing/finetune/index.d.ts +2 -0
- package/types/video/postprocessing/finetune/index.d.ts.map +1 -0
- package/types/video/postprocessing/finetune/removeOrange.d.ts +2 -0
- package/types/video/postprocessing/finetune/removeOrange.d.ts.map +1 -0
- package/types/video/postprocessing/visualmetrics/extraMetrics.d.ts +5 -0
- package/types/video/postprocessing/visualmetrics/extraMetrics.d.ts.map +1 -0
- package/types/video/postprocessing/visualmetrics/getVideoMetrics.d.ts +5 -0
- package/types/video/postprocessing/visualmetrics/getVideoMetrics.d.ts.map +1 -0
- package/types/video/postprocessing/visualmetrics/visualMetrics.d.ts +3 -0
- package/types/video/postprocessing/visualmetrics/visualMetrics.d.ts.map +1 -0
- package/types/video/screenRecording/android/recorder.d.ts +11 -0
- package/types/video/screenRecording/android/recorder.d.ts.map +1 -0
- package/types/video/screenRecording/desktop/convert.d.ts +2 -0
- package/types/video/screenRecording/desktop/convert.d.ts.map +1 -0
- package/types/video/screenRecording/desktop/desktopRecorder.d.ts +28 -0
- package/types/video/screenRecording/desktop/desktopRecorder.d.ts.map +1 -0
- package/types/video/screenRecording/desktop/ffmpegRecorder.d.ts +17 -0
- package/types/video/screenRecording/desktop/ffmpegRecorder.d.ts.map +1 -0
- package/types/video/screenRecording/desktop/osx/getSPDisplaysDataType.d.ts +2 -0
- package/types/video/screenRecording/desktop/osx/getSPDisplaysDataType.d.ts.map +1 -0
- package/types/video/screenRecording/desktop/osx/getScreen.d.ts +2 -0
- package/types/video/screenRecording/desktop/osx/getScreen.d.ts.map +1 -0
- package/types/video/screenRecording/firefox/firefoxWindowRecorder.d.ts +13 -0
- package/types/video/screenRecording/firefox/firefoxWindowRecorder.d.ts.map +1 -0
- package/types/video/screenRecording/ios/convertToMp4.d.ts +2 -0
- package/types/video/screenRecording/ios/convertToMp4.d.ts.map +1 -0
- package/types/video/screenRecording/ios/iosRecorder.d.ts +14 -0
- package/types/video/screenRecording/ios/iosRecorder.d.ts.map +1 -0
- package/types/video/screenRecording/iosSimulator/convertToMp4.d.ts +2 -0
- package/types/video/screenRecording/iosSimulator/convertToMp4.d.ts.map +1 -0
- package/types/video/screenRecording/iosSimulator/recorder.d.ts +9 -0
- package/types/video/screenRecording/iosSimulator/recorder.d.ts.map +1 -0
- package/types/video/screenRecording/recorder.d.ts +7 -0
- package/types/video/screenRecording/recorder.d.ts.map +1 -0
- package/types/video/screenRecording/setOrangeBackground.d.ts +2 -0
- package/types/video/screenRecording/setOrangeBackground.d.ts.map +1 -0
- package/types/video/video.d.ts +41 -0
- package/types/video/video.d.ts.map +1 -0
- package/browsersupport/firefox-profile/cert9.db +0 -0
- package/browsersupport/firefox-profile/chrome/userChrome.css +0 -4
- package/browsersupport/firefox-profile/key4.db +0 -0
- package/vendor/mac/x86/qvh +0 -0
- package/visualmetrics/__init__.py +0 -1
- package/visualmetrics/test_data/ms_000000.png +0 -0
- package/visualmetrics/test_data/ms_000920.png +0 -0
- package/visualmetrics/test_data/ms_001000.png +0 -0
- package/visualmetrics/test_data/ms_001080.png +0 -0
- package/visualmetrics/test_data/ms_001200.png +0 -0
- package/visualmetrics/test_data/ms_001240.png +0 -0
- package/visualmetrics/test_data/ms_001280.png +0 -0
- package/visualmetrics/test_data/ms_001360.png +0 -0
- package/visualmetrics/test_data/ms_001400.png +0 -0
- package/visualmetrics/test_data/ms_001520.png +0 -0
- package/visualmetrics/test_data/ms_002040.png +0 -0
- package/visualmetrics/test_data/ms_002600.png +0 -0
- package/visualmetrics/test_data/ms_003160.png +0 -0
- package/visualmetrics/test_data/ms_003720.png +0 -0
- package/visualmetrics/test_data/ms_004280.png +0 -0
- package/visualmetrics/test_data/ms_004880.png +0 -0
- package/visualmetrics/test_data/ms_005440.png +0 -0
- package/visualmetrics/test_data/ms_006000.png +0 -0
- package/visualmetrics/test_visualmetrics.py +0 -34
|
@@ -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
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @
|
|
13
|
-
* @
|
|
14
|
-
*
|
|
15
|
-
* @
|
|
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
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* @
|
|
34
|
-
* @
|
|
35
|
-
*
|
|
36
|
-
* @
|
|
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
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* @
|
|
53
|
-
* @
|
|
54
|
-
*
|
|
55
|
-
* @
|
|
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
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* @
|
|
74
|
-
* @
|
|
75
|
-
*
|
|
76
|
-
* @
|
|
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
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* @
|
|
93
|
-
* @
|
|
94
|
-
*
|
|
95
|
-
* @
|
|
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
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* @
|
|
112
|
-
* @
|
|
113
|
-
*
|
|
114
|
-
* @
|
|
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
|
-
*
|
|
28
|
+
* Starts the stopwatch.
|
|
13
29
|
*/
|
|
14
30
|
start() {
|
|
15
31
|
this.start = performance.now();
|
|
16
32
|
}
|
|
17
33
|
|
|
18
34
|
/**
|
|
19
|
-
*
|
|
20
|
-
* last measured page.
|
|
21
|
-
*
|
|
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
|
-
*
|
|
33
|
-
* @returns
|
|
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
|
-
*
|
|
43
|
-
* @returns The name of the
|
|
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
|
-
*
|
|
14
|
-
*
|
|
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
|
-
*
|
|
29
|
-
*
|
|
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
|
-
*
|
|
50
|
-
*
|
|
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
|
-
*
|
|
71
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @
|
|
16
|
-
* @
|
|
17
|
-
* @
|
|
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
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @
|
|
39
|
-
* @
|
|
40
|
-
* @
|
|
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
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* @
|
|
64
|
-
* @
|
|
65
|
-
* @
|
|
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
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* @
|
|
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
|
-
*
|
|
100
|
-
* @
|
|
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
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* @
|
|
110
|
-
* @
|
|
111
|
-
* @
|
|
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();
|