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.
- package/CHANGELOG.md +36 -0
- package/README.md +9 -8
- 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 +151 -19
- 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/index.js +6 -2
- package/lib/core/engine/iteration.js +20 -102
- package/lib/firefox/geckoProfiler.js +49 -1
- package/lib/firefox/webdriver/builder.js +35 -12
- package/lib/firefox/webdriver/firefox.js +1 -1
- package/lib/support/cli.js +35 -15
- package/lib/support/engineUtils.js +13 -1
- package/lib/support/statistics.js +11 -1
- package/lib/support/userTiming.js +2 -2
- package/package.json +17 -8
- 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/CONTRIBUTING.md +0 -24
- 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/docs/examples/README.md +0 -9
- package/docs/examples/advance.md +0 -12
- package/docs/examples/android.md +0 -54
- package/docs/examples/basic.md +0 -36
- package/docs/examples/chrome.md +0 -28
- package/docs/examples/firefox.md +0 -10
- package/docs/issues.md +0 -18
- package/docs/new-style-script-objects.md +0 -38
- package/docs/sequence-diagrams/loadAndWait.wsd +0 -24
- package/docs/sequence-diagrams/run.wsd +0 -24
- 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,17 +1,31 @@
|
|
|
1
1
|
import intel from 'intel';
|
|
2
2
|
import { By, Origin } from 'selenium-webdriver';
|
|
3
3
|
const log = intel.getLogger('browsertime.command.mouse');
|
|
4
|
+
/**
|
|
5
|
+
* Provides functionality to move the mouse cursor to elements or specific positions on a web page.
|
|
6
|
+
*
|
|
7
|
+
* @class
|
|
8
|
+
* @hideconstructor
|
|
9
|
+
*/
|
|
4
10
|
export class MouseMove {
|
|
5
11
|
constructor(browser) {
|
|
12
|
+
/**
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
6
15
|
this.driver = browser.getDriver();
|
|
16
|
+
/**
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
7
19
|
this.actions = this.driver.actions({ async: true });
|
|
8
20
|
}
|
|
9
21
|
|
|
10
22
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @
|
|
14
|
-
* @
|
|
23
|
+
* Moves the mouse cursor to an element that matches a given XPath selector.
|
|
24
|
+
*
|
|
25
|
+
* @async
|
|
26
|
+
* @param {string} xpath - The XPath selector of the element to move to.
|
|
27
|
+
* @returns {Promise<void>} A promise that resolves when the mouse has moved to the element.
|
|
28
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
15
29
|
*/
|
|
16
30
|
async byXpath(xpath) {
|
|
17
31
|
try {
|
|
@@ -25,10 +39,12 @@ export class MouseMove {
|
|
|
25
39
|
}
|
|
26
40
|
|
|
27
41
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* @
|
|
31
|
-
* @
|
|
42
|
+
* Moves the mouse cursor to an element that matches a given CSS selector.
|
|
43
|
+
*
|
|
44
|
+
* @async
|
|
45
|
+
* @param {string} selector - The CSS selector of the element to move to.
|
|
46
|
+
* @returns {Promise<void>} A promise that resolves when the mouse has moved to the element.
|
|
47
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
32
48
|
*/
|
|
33
49
|
async bySelector(selector) {
|
|
34
50
|
try {
|
|
@@ -42,10 +58,13 @@ export class MouseMove {
|
|
|
42
58
|
}
|
|
43
59
|
|
|
44
60
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* @
|
|
48
|
-
* @
|
|
61
|
+
* Moves the mouse cursor to a specific position on the screen.
|
|
62
|
+
*
|
|
63
|
+
* @async
|
|
64
|
+
* @param {number} xPos - The x-coordinate on the screen to move to.
|
|
65
|
+
* @param {number} yPos - The y-coordinate on the screen to move to.
|
|
66
|
+
* @returns {Promise<void>} A promise that resolves when the mouse has moved to the specified position.
|
|
67
|
+
* @throws {Error} Throws an error if the action cannot be performed.
|
|
49
68
|
*/
|
|
50
69
|
async toPosition(xPos, yPos) {
|
|
51
70
|
try {
|
|
@@ -58,10 +77,13 @@ export class MouseMove {
|
|
|
58
77
|
}
|
|
59
78
|
|
|
60
79
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* @
|
|
64
|
-
* @
|
|
80
|
+
* Moves the mouse cursor by an offset from its current position.
|
|
81
|
+
*
|
|
82
|
+
* @async
|
|
83
|
+
* @param {number} xOffset - The x offset to move by.
|
|
84
|
+
* @param {number} yOffset - The y offset to move by.
|
|
85
|
+
* @returns {Promise<void>} A promise that resolves when the mouse has moved by the specified offset.
|
|
86
|
+
* @throws {Error} Throws an error if the action cannot be performed.
|
|
65
87
|
*/
|
|
66
88
|
async byOffset(xOffset, yOffset) {
|
|
67
89
|
try {
|
|
@@ -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
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* @
|
|
15
|
-
* @
|
|
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
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* @
|
|
37
|
-
* @
|
|
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
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* @
|
|
61
|
-
* @
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @
|
|
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
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @
|
|
24
|
-
* @
|
|
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
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* @
|
|
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
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* @
|
|
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
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @
|
|
13
|
-
* @
|
|
14
|
-
*
|
|
15
|
-
* @
|
|
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
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* @
|
|
32
|
-
* @
|
|
33
|
-
*
|
|
34
|
-
* @
|
|
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
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* @
|
|
53
|
-
* @
|
|
54
|
-
*
|
|
55
|
-
* @
|
|
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
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* @
|
|
76
|
-
* @
|
|
77
|
-
*
|
|
78
|
-
* @
|
|
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
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* @
|
|
99
|
-
* @
|
|
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
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* @
|
|
117
|
-
* @
|
|
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
|
-
*
|
|
140
|
-
*
|
|
141
|
-
* @
|
|
142
|
-
* @
|
|
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 {
|