browsertime 16.17.0 → 17.0.0-beta.1
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 +44 -0
- package/bin/browsertime.js +43 -43
- package/bin/browsertimeWebPageReplay.js +10 -9
- package/browserscripts/pageinfo/generator.js +1 -1
- package/index.js +14 -13
- package/lib/android/gnirehtet.js +14 -15
- package/lib/android/index.js +92 -89
- package/lib/android/root.js +6 -9
- package/lib/chrome/chromeDevtoolsProtocol.js +46 -45
- package/lib/chrome/har.js +12 -13
- package/lib/chrome/longTaskMetrics.js +3 -5
- package/lib/chrome/parseCpuTrace.js +13 -10
- package/lib/chrome/settings/chromeAndroidOptions.js +1 -3
- package/lib/chrome/settings/chromeDesktopOptions.js +1 -3
- package/lib/chrome/settings/traceCategories.js +1 -3
- package/lib/chrome/traceCategoriesParser.js +35 -36
- package/lib/chrome/webdriver/builder.js +18 -26
- package/lib/chrome/webdriver/chromium.js +56 -46
- package/lib/chrome/webdriver/setupChromiumOptions.js +32 -27
- package/lib/connectivity/humble.js +13 -14
- package/lib/connectivity/index.js +74 -77
- package/lib/connectivity/trafficShapeParser.js +31 -35
- package/lib/core/engine/collector.js +22 -22
- package/lib/core/engine/command/addText.js +24 -27
- package/lib/core/engine/command/android.js +7 -11
- package/lib/core/engine/command/cache.js +3 -4
- package/lib/core/engine/command/chromeDevToolsProtocol.js +20 -20
- package/lib/core/engine/command/click.js +48 -49
- package/lib/core/engine/command/debug.js +3 -4
- package/lib/core/engine/command/javaScript.js +18 -19
- package/lib/core/engine/command/measure.js +31 -37
- package/lib/core/engine/command/meta.js +1 -4
- package/lib/core/engine/command/mouse/clickAndHold.js +36 -39
- package/lib/core/engine/command/mouse/contextClick.js +17 -18
- package/lib/core/engine/command/mouse/doubleClick.js +17 -19
- package/lib/core/engine/command/mouse/index.js +5 -9
- package/lib/core/engine/command/mouse/mouseMove.js +19 -23
- package/lib/core/engine/command/mouse/singleClick.js +15 -19
- package/lib/core/engine/command/navigation.js +12 -14
- package/lib/core/engine/command/screenshot.js +1 -4
- package/lib/core/engine/command/scroll.js +4 -7
- package/lib/core/engine/command/select.js +26 -26
- package/lib/core/engine/command/set.js +25 -23
- package/lib/core/engine/command/stopWatch.js +5 -8
- package/lib/core/engine/command/switch.js +18 -20
- package/lib/core/engine/command/util/lcpHighlightScript.js +1 -2
- package/lib/core/engine/command/util/lsHighlightScript.js +1 -2
- package/lib/core/engine/command/wait.js +18 -18
- package/lib/core/engine/index.js +82 -72
- package/lib/core/engine/iteration.js +83 -79
- package/lib/core/engine/run.js +5 -9
- package/lib/core/pageCompleteChecks/defaultPageCompleteCheck.js +1 -2
- package/lib/core/pageCompleteChecks/pageCompleteCheckByInactivity.js +1 -3
- package/lib/core/pageCompleteChecks/spaInactivity.js +1 -3
- package/lib/core/seleniumRunner.js +92 -100
- package/lib/core/webdriver/index.js +24 -21
- package/lib/edge/webdriver/builder.js +21 -26
- package/lib/extensionserver/httpServer.js +17 -21
- package/lib/extensionserver/index.js +8 -12
- package/lib/extensionserver/setup.js +12 -12
- package/lib/firefox/geckoProfiler.js +27 -21
- package/lib/firefox/getHAR.js +7 -8
- package/lib/firefox/memoryReport.js +9 -11
- package/lib/firefox/perfStats.js +5 -7
- package/lib/firefox/settings/disableSafeBrowsingPreferences.js +1 -3
- package/lib/firefox/settings/disableTrackingProtectionPreferences.js +1 -3
- package/lib/firefox/settings/firefoxPreferences.js +2 -4
- package/lib/firefox/settings/geckoProfilerDefaults.js +5 -9
- package/lib/firefox/webdriver/builder.js +66 -63
- package/lib/firefox/webdriver/firefox.js +44 -49
- package/lib/safari/webdriver/builder.js +4 -5
- package/lib/safari/webdriver/safari.js +4 -8
- package/lib/screenshot/defaults.js +1 -3
- package/lib/screenshot/index.js +24 -21
- package/lib/support/browserScript.js +65 -56
- package/lib/support/cli.js +120 -87
- package/lib/support/dns.js +6 -7
- package/lib/support/engineUtils.js +85 -38
- package/lib/support/errors.js +4 -13
- package/lib/support/fileUtil.js +81 -68
- package/lib/support/filters.js +15 -20
- package/lib/support/getViewPort.js +6 -7
- package/lib/support/har/index.js +208 -216
- package/lib/support/images/index.js +54 -26
- package/lib/support/logging.js +20 -17
- package/lib/support/pathToFolder.js +18 -23
- package/lib/support/preURL.js +5 -6
- package/lib/support/processes.js +4 -6
- package/lib/support/setResourceTimingBufferSize.js +2 -4
- package/lib/support/statistics.js +58 -56
- package/lib/support/stop.js +7 -8
- package/lib/support/storageManager.js +44 -44
- package/lib/support/tcpdump.js +22 -16
- package/lib/support/userTiming.js +7 -13
- package/lib/support/util.js +204 -224
- package/lib/support/xvfb.js +11 -13
- package/lib/video/defaults.js +6 -10
- package/lib/video/postprocessing/finetune/addTextToVideo.js +15 -15
- package/lib/video/postprocessing/finetune/convertFps.js +14 -8
- package/lib/video/postprocessing/finetune/getFont.js +7 -9
- package/lib/video/postprocessing/finetune/getTimingMetrics.js +19 -18
- package/lib/video/postprocessing/finetune/index.js +40 -36
- package/lib/video/postprocessing/finetune/removeOrange.js +10 -11
- package/lib/video/postprocessing/visualmetrics/extraMetrics.js +17 -13
- package/lib/video/postprocessing/visualmetrics/getVideoMetrics.js +12 -13
- package/lib/video/postprocessing/visualmetrics/visualMetrics.js +117 -128
- package/lib/video/screenRecording/android/recorder.js +12 -17
- package/lib/video/screenRecording/desktop/convert.js +13 -11
- package/lib/video/screenRecording/desktop/desktopRecorder.js +29 -24
- package/lib/video/screenRecording/desktop/ffmpegRecorder.js +60 -63
- package/lib/video/screenRecording/desktop/osx/getSPDisplaysDataType.js +4 -6
- package/lib/video/screenRecording/desktop/osx/getScreen.js +9 -10
- package/lib/video/screenRecording/firefox/firefoxWindowRecorder.js +54 -54
- package/lib/video/screenRecording/ios/convertToMp4.js +10 -11
- package/lib/video/screenRecording/ios/iosRecorder.js +23 -21
- package/lib/video/screenRecording/iosSimulator/convertToMp4.js +10 -11
- package/lib/video/screenRecording/iosSimulator/recorder.js +10 -9
- package/lib/video/screenRecording/recorder.js +8 -9
- package/lib/video/screenRecording/setOrangeBackground.js +5 -6
- package/lib/video/video.js +28 -34
- package/package.json +19 -17
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const log =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class ClickAndHold {
|
|
1
|
+
import intel from 'intel';
|
|
2
|
+
import { By, Origin } from 'selenium-webdriver';
|
|
3
|
+
const log = intel.getLogger('browsertime.command.mouse');
|
|
4
|
+
export class ClickAndHold {
|
|
7
5
|
constructor(browser) {
|
|
8
6
|
this.driver = browser.getDriver();
|
|
9
7
|
this.actions = this.driver.actions({ async: true });
|
|
@@ -17,12 +15,14 @@ class ClickAndHold {
|
|
|
17
15
|
*/
|
|
18
16
|
async byXpath(xpath) {
|
|
19
17
|
try {
|
|
20
|
-
const element = await this.driver.findElement(
|
|
18
|
+
const element = await this.driver.findElement(By.xpath(xpath));
|
|
21
19
|
return this.actions.move({ origin: element }).press().perform();
|
|
22
|
-
} catch (
|
|
20
|
+
} catch (error) {
|
|
23
21
|
log.error('Could not click and hold on element with xpath %s', xpath);
|
|
24
|
-
log.verbose(
|
|
25
|
-
throw Error(
|
|
22
|
+
log.verbose(error);
|
|
23
|
+
throw new Error(
|
|
24
|
+
'Could not click and hold on element with xpath ' + xpath
|
|
25
|
+
);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -34,15 +34,15 @@ class ClickAndHold {
|
|
|
34
34
|
*/
|
|
35
35
|
async bySelector(selector) {
|
|
36
36
|
try {
|
|
37
|
-
const element = await this.driver.findElement(
|
|
37
|
+
const element = await this.driver.findElement(By.css(selector));
|
|
38
38
|
return this.actions.move({ origin: element }).press().perform();
|
|
39
|
-
} catch (
|
|
39
|
+
} catch (error) {
|
|
40
40
|
log.error(
|
|
41
41
|
'Could not click and hold on element with selector %s',
|
|
42
42
|
selector
|
|
43
43
|
);
|
|
44
|
-
log.verbose(
|
|
45
|
-
throw Error(
|
|
44
|
+
log.verbose(error);
|
|
45
|
+
throw new Error(
|
|
46
46
|
'Could not click and hold on element with selector ' + selector
|
|
47
47
|
);
|
|
48
48
|
}
|
|
@@ -55,14 +55,11 @@ class ClickAndHold {
|
|
|
55
55
|
*/
|
|
56
56
|
async atCursor() {
|
|
57
57
|
try {
|
|
58
|
-
return this.actions
|
|
59
|
-
|
|
60
|
-
.press()
|
|
61
|
-
.perform();
|
|
62
|
-
} catch (e) {
|
|
58
|
+
return this.actions.move({ origin: Origin.POINTER }).press().perform();
|
|
59
|
+
} catch (error) {
|
|
63
60
|
log.error('Could not click and hold at cursor');
|
|
64
|
-
log.verbose(
|
|
65
|
-
throw Error('Could not click and hold at cursor');
|
|
61
|
+
log.verbose(error);
|
|
62
|
+
throw new Error('Could not click and hold at cursor');
|
|
66
63
|
}
|
|
67
64
|
}
|
|
68
65
|
|
|
@@ -76,13 +73,13 @@ class ClickAndHold {
|
|
|
76
73
|
async atPosition(xPos, yPos) {
|
|
77
74
|
try {
|
|
78
75
|
return this.actions
|
|
79
|
-
.move({ x: xPos, y: yPos, origin:
|
|
76
|
+
.move({ x: xPos, y: yPos, origin: Origin.VIEWPORT })
|
|
80
77
|
.press()
|
|
81
78
|
.perform();
|
|
82
|
-
} catch (
|
|
79
|
+
} catch (error) {
|
|
83
80
|
log.error('Could not click and hold at position (%d,%d)', xPos, yPos);
|
|
84
|
-
log.verbose(
|
|
85
|
-
throw Error(
|
|
81
|
+
log.verbose(error);
|
|
82
|
+
throw new Error(
|
|
86
83
|
'Could not click and hold at position (' + xPos + ',' + yPos + ')'
|
|
87
84
|
);
|
|
88
85
|
}
|
|
@@ -96,12 +93,12 @@ class ClickAndHold {
|
|
|
96
93
|
*/
|
|
97
94
|
async releaseAtXpath(xpath) {
|
|
98
95
|
try {
|
|
99
|
-
const element = await this.driver.findElement(
|
|
96
|
+
const element = await this.driver.findElement(By.xpath(xpath));
|
|
100
97
|
return this.actions.move({ origin: element }).release().perform();
|
|
101
|
-
} catch (
|
|
98
|
+
} catch (error) {
|
|
102
99
|
log.error('Could not release on xpath %s', xpath);
|
|
103
|
-
log.verbose(
|
|
104
|
-
throw Error('Could not release on xpath ' + xpath);
|
|
100
|
+
log.verbose(error);
|
|
101
|
+
throw new Error('Could not release on xpath ' + xpath);
|
|
105
102
|
}
|
|
106
103
|
}
|
|
107
104
|
|
|
@@ -113,12 +110,12 @@ class ClickAndHold {
|
|
|
113
110
|
*/
|
|
114
111
|
async releaseAtSelector(selector) {
|
|
115
112
|
try {
|
|
116
|
-
const element = await this.driver.findElement(
|
|
113
|
+
const element = await this.driver.findElement(By.css(selector));
|
|
117
114
|
return this.actions.move({ origin: element }).release().perform();
|
|
118
|
-
} catch (
|
|
115
|
+
} catch (error) {
|
|
119
116
|
log.error('Could not release on selector %s', selector);
|
|
120
|
-
log.verbose(
|
|
121
|
-
throw Error('Could not release on selector ' + selector);
|
|
117
|
+
log.verbose(error);
|
|
118
|
+
throw new Error('Could not release on selector ' + selector);
|
|
122
119
|
}
|
|
123
120
|
}
|
|
124
121
|
|
|
@@ -132,15 +129,15 @@ class ClickAndHold {
|
|
|
132
129
|
async releaseAtPosition(xPos, yPos) {
|
|
133
130
|
try {
|
|
134
131
|
return this.actions
|
|
135
|
-
.move({ x: xPos, y: yPos, origin:
|
|
132
|
+
.move({ x: xPos, y: yPos, origin: Origin.VIEWPORT })
|
|
136
133
|
.release()
|
|
137
134
|
.perform();
|
|
138
|
-
} catch (
|
|
135
|
+
} catch (error) {
|
|
139
136
|
log.error('Could not release at position (%d,%d)', xPos, yPos);
|
|
140
|
-
log.verbose(
|
|
141
|
-
throw Error(
|
|
137
|
+
log.verbose(error);
|
|
138
|
+
throw new Error(
|
|
139
|
+
'Could not release at position (' + xPos + ',' + yPos + ')'
|
|
140
|
+
);
|
|
142
141
|
}
|
|
143
142
|
}
|
|
144
143
|
}
|
|
145
|
-
|
|
146
|
-
module.exports = ClickAndHold;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const log =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class ContextClick {
|
|
1
|
+
import intel from 'intel';
|
|
2
|
+
import { By } from 'selenium-webdriver';
|
|
3
|
+
const log = intel.getLogger('browsertime.command.mouse');
|
|
4
|
+
export class ContextClick {
|
|
7
5
|
constructor(browser) {
|
|
8
6
|
this.driver = browser.getDriver();
|
|
9
7
|
this.actions = this.driver.actions({ async: true });
|
|
@@ -17,12 +15,12 @@ class ContextClick {
|
|
|
17
15
|
*/
|
|
18
16
|
async byXpath(xpath) {
|
|
19
17
|
try {
|
|
20
|
-
const element = await this.driver.findElement(
|
|
18
|
+
const element = await this.driver.findElement(By.xpath(xpath));
|
|
21
19
|
return this.actions.contextClick(element).perform();
|
|
22
|
-
} catch (
|
|
20
|
+
} catch (error) {
|
|
23
21
|
log.error('Could not context click on element with xpath %s', xpath);
|
|
24
|
-
log.verbose(
|
|
25
|
-
throw Error('Could not context click on element with xpath ' + xpath);
|
|
22
|
+
log.verbose(error);
|
|
23
|
+
throw new Error('Could not context click on element with xpath ' + xpath);
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
26
|
|
|
@@ -34,12 +32,14 @@ class ContextClick {
|
|
|
34
32
|
*/
|
|
35
33
|
async bySelector(selector) {
|
|
36
34
|
try {
|
|
37
|
-
const element = await this.driver.findElement(
|
|
35
|
+
const element = await this.driver.findElement(By.css(selector));
|
|
38
36
|
return this.actions.contextClick(element).perform();
|
|
39
|
-
} catch (
|
|
37
|
+
} catch (error) {
|
|
40
38
|
log.error('Could not context click on element with css %s', selector);
|
|
41
|
-
log.verbose(
|
|
42
|
-
throw Error(
|
|
39
|
+
log.verbose(error);
|
|
40
|
+
throw new Error(
|
|
41
|
+
'Could not context click on element with css ' + selector
|
|
42
|
+
);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -51,11 +51,10 @@ class ContextClick {
|
|
|
51
51
|
async atCursor() {
|
|
52
52
|
try {
|
|
53
53
|
return this.actions.contextClick().perform();
|
|
54
|
-
} catch (
|
|
54
|
+
} catch (error) {
|
|
55
55
|
log.error('Could not perform context click');
|
|
56
|
-
log.verbose(
|
|
57
|
-
throw Error('Could not perform context click');
|
|
56
|
+
log.verbose(error);
|
|
57
|
+
throw new Error('Could not perform context click');
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
module.exports = ContextClick;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const log =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class DoubleClick {
|
|
1
|
+
import intel from 'intel';
|
|
2
|
+
import { By } from 'selenium-webdriver';
|
|
3
|
+
const log = intel.getLogger('browsertime.command.mouse');
|
|
4
|
+
export class DoubleClick {
|
|
7
5
|
constructor(browser, pageCompleteCheck) {
|
|
8
6
|
this.browser = browser;
|
|
9
7
|
this.actions = this.browser.getDriver().actions({ async: true });
|
|
@@ -20,15 +18,15 @@ class DoubleClick {
|
|
|
20
18
|
try {
|
|
21
19
|
const element = await this.browser
|
|
22
20
|
.getDriver()
|
|
23
|
-
.findElement(
|
|
21
|
+
.findElement(By.xpath(xpath));
|
|
24
22
|
await this.actions.doubleClick(element).perform();
|
|
25
23
|
if (options && 'wait' in options && options.wait === true) {
|
|
26
24
|
return this.browser.extraWait(this.pageCompleteCheck);
|
|
27
25
|
}
|
|
28
|
-
} catch (
|
|
26
|
+
} catch (error) {
|
|
29
27
|
log.error('Could not double click on element with xpath %s', xpath);
|
|
30
|
-
log.verbose(
|
|
31
|
-
throw Error('Could not double click on element with xpath ' + xpath);
|
|
28
|
+
log.verbose(error);
|
|
29
|
+
throw new Error('Could not double click on element with xpath ' + xpath);
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
32
|
|
|
@@ -42,15 +40,17 @@ class DoubleClick {
|
|
|
42
40
|
try {
|
|
43
41
|
const element = await this.browser
|
|
44
42
|
.getDriver()
|
|
45
|
-
.findElement(
|
|
43
|
+
.findElement(By.css(selector));
|
|
46
44
|
await this.actions.doubleClick(element).perform();
|
|
47
45
|
if (options && 'wait' in options && options.wait === true) {
|
|
48
46
|
return this.browser.extraWait(this.pageCompleteCheck);
|
|
49
47
|
}
|
|
50
|
-
} catch (
|
|
48
|
+
} catch (error) {
|
|
51
49
|
log.error('Could not double click on element with xpath %s', selector);
|
|
52
|
-
log.verbose(
|
|
53
|
-
throw Error(
|
|
50
|
+
log.verbose(error);
|
|
51
|
+
throw new Error(
|
|
52
|
+
'Could not double click on element with xpath ' + selector
|
|
53
|
+
);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -65,12 +65,10 @@ class DoubleClick {
|
|
|
65
65
|
if (options && 'wait' in options && options.wait === true) {
|
|
66
66
|
return this.browser.extraWait(this.pageCompleteCheck);
|
|
67
67
|
}
|
|
68
|
-
} catch (
|
|
68
|
+
} catch (error) {
|
|
69
69
|
log.error('Could not perform double click');
|
|
70
|
-
log.verbose(
|
|
71
|
-
throw Error('Could not perform double click');
|
|
70
|
+
log.verbose(error);
|
|
71
|
+
throw new Error('Could not perform double click');
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
module.exports = DoubleClick;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
ClickAndHold: require('./clickAndHold'),
|
|
7
|
-
ContextClick: require('./contextClick'),
|
|
8
|
-
MouseMove: require('./mouseMove')
|
|
9
|
-
};
|
|
1
|
+
export { ClickAndHold } from './clickAndHold.js';
|
|
2
|
+
export { DoubleClick } from './doubleClick.js';
|
|
3
|
+
export { ContextClick } from './contextClick.js';
|
|
4
|
+
export { SingleClick } from './singleClick.js';
|
|
5
|
+
export { MouseMove } from './mouseMove.js';
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const log =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class MouseMove {
|
|
1
|
+
import intel from 'intel';
|
|
2
|
+
import { By, Origin } from 'selenium-webdriver';
|
|
3
|
+
const log = intel.getLogger('browsertime.command.mouse');
|
|
4
|
+
export class MouseMove {
|
|
7
5
|
constructor(browser) {
|
|
8
6
|
this.driver = browser.getDriver();
|
|
9
7
|
this.actions = this.driver.actions({ async: true });
|
|
@@ -17,12 +15,12 @@ class MouseMove {
|
|
|
17
15
|
*/
|
|
18
16
|
async byXpath(xpath) {
|
|
19
17
|
try {
|
|
20
|
-
const element = await this.driver.findElement(
|
|
18
|
+
const element = await this.driver.findElement(By.xpath(xpath));
|
|
21
19
|
return this.actions.move({ origin: element }).perform();
|
|
22
|
-
} catch (
|
|
20
|
+
} catch (error) {
|
|
23
21
|
log.error('Could not find element by xpath %s', xpath);
|
|
24
|
-
log.verbose(
|
|
25
|
-
throw Error('Could not find element by xpath ' + xpath);
|
|
22
|
+
log.verbose(error);
|
|
23
|
+
throw new Error('Could not find element by xpath ' + xpath);
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
26
|
|
|
@@ -34,12 +32,12 @@ class MouseMove {
|
|
|
34
32
|
*/
|
|
35
33
|
async bySelector(selector) {
|
|
36
34
|
try {
|
|
37
|
-
const element = await this.driver.findElement(
|
|
35
|
+
const element = await this.driver.findElement(By.css(selector));
|
|
38
36
|
return this.actions.move({ origin: element }).perform();
|
|
39
|
-
} catch (
|
|
37
|
+
} catch (error) {
|
|
40
38
|
log.error('Could not find element by selector %s', selector);
|
|
41
|
-
log.verbose(
|
|
42
|
-
throw Error('Could not find element by selector ' + selector);
|
|
39
|
+
log.verbose(error);
|
|
40
|
+
throw new Error('Could not find element by selector ' + selector);
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
43
|
|
|
@@ -52,10 +50,10 @@ class MouseMove {
|
|
|
52
50
|
async toPosition(xPos, yPos) {
|
|
53
51
|
try {
|
|
54
52
|
return this.actions.move({ x: xPos, y: yPos }).perform();
|
|
55
|
-
} catch (
|
|
53
|
+
} catch (error) {
|
|
56
54
|
log.error('Could not move mouse to position.');
|
|
57
|
-
log.verbose(
|
|
58
|
-
throw Error('Could not move mouse to position.');
|
|
55
|
+
log.verbose(error);
|
|
56
|
+
throw new Error('Could not move mouse to position.');
|
|
59
57
|
}
|
|
60
58
|
}
|
|
61
59
|
|
|
@@ -68,14 +66,12 @@ class MouseMove {
|
|
|
68
66
|
async byOffset(xOffset, yOffset) {
|
|
69
67
|
try {
|
|
70
68
|
return this.actions
|
|
71
|
-
.move({ x: xOffset, y: yOffset, origin:
|
|
69
|
+
.move({ x: xOffset, y: yOffset, origin: Origin.POINTER })
|
|
72
70
|
.perform();
|
|
73
|
-
} catch (
|
|
71
|
+
} catch (error) {
|
|
74
72
|
log.error('Could not move mouse by offset');
|
|
75
|
-
log.verbose(
|
|
76
|
-
throw Error('Could not move mouse by offset');
|
|
73
|
+
log.verbose(error);
|
|
74
|
+
throw new Error('Could not move mouse by offset');
|
|
77
75
|
}
|
|
78
76
|
}
|
|
79
77
|
}
|
|
80
|
-
|
|
81
|
-
module.exports = MouseMove;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const log =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class SingleClick {
|
|
1
|
+
import intel from 'intel';
|
|
2
|
+
import { By } from 'selenium-webdriver';
|
|
3
|
+
const log = intel.getLogger('browsertime.command.mouse');
|
|
4
|
+
export class SingleClick {
|
|
7
5
|
constructor(browser, pageCompleteCheck) {
|
|
8
6
|
this.browser = browser;
|
|
9
7
|
this.actions = this.browser.getDriver().actions({ async: true });
|
|
@@ -20,15 +18,15 @@ class SingleClick {
|
|
|
20
18
|
try {
|
|
21
19
|
const element = await this.browser
|
|
22
20
|
.getDriver()
|
|
23
|
-
.findElement(
|
|
21
|
+
.findElement(By.xpath(xpath));
|
|
24
22
|
await this.actions.click(element).perform();
|
|
25
23
|
if (options && 'wait' in options && options.wait === true) {
|
|
26
24
|
return this.browser.extraWait(this.pageCompleteCheck);
|
|
27
25
|
}
|
|
28
|
-
} catch (
|
|
26
|
+
} catch (error) {
|
|
29
27
|
log.error('Could not single click on element with xpath %s', xpath);
|
|
30
|
-
log.verbose(
|
|
31
|
-
throw Error('Could not single click on element with xpath ' + xpath);
|
|
28
|
+
log.verbose(error);
|
|
29
|
+
throw new Error('Could not single click on element with xpath ' + xpath);
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
32
|
|
|
@@ -42,15 +40,15 @@ class SingleClick {
|
|
|
42
40
|
try {
|
|
43
41
|
const element = await this.browser
|
|
44
42
|
.getDriver()
|
|
45
|
-
.findElement(
|
|
43
|
+
.findElement(By.css(selector));
|
|
46
44
|
await this.actions.click(element).perform();
|
|
47
45
|
if (options && 'wait' in options && options.wait === true) {
|
|
48
46
|
return this.browser.extraWait(this.pageCompleteCheck);
|
|
49
47
|
}
|
|
50
|
-
} catch (
|
|
48
|
+
} catch (error) {
|
|
51
49
|
log.error('Could not single click on element with selector %s', selector);
|
|
52
|
-
log.verbose(
|
|
53
|
-
throw Error(
|
|
50
|
+
log.verbose(error);
|
|
51
|
+
throw new Error(
|
|
54
52
|
'Could not single click on element with selector ' + selector
|
|
55
53
|
);
|
|
56
54
|
}
|
|
@@ -68,12 +66,10 @@ class SingleClick {
|
|
|
68
66
|
if (options && 'wait' in options && options.wait === true) {
|
|
69
67
|
return this.browser.extraWait(this.pageCompleteCheck);
|
|
70
68
|
}
|
|
71
|
-
} catch (
|
|
69
|
+
} catch (error) {
|
|
72
70
|
log.error('Could not perform single click');
|
|
73
|
-
log.verbose(
|
|
74
|
-
throw Error('Could not perform single click');
|
|
71
|
+
log.verbose(error);
|
|
72
|
+
throw new Error('Could not perform single click');
|
|
75
73
|
}
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
|
-
|
|
79
|
-
module.exports = SingleClick;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import intel from 'intel';
|
|
2
|
+
const log = intel.getLogger('browsertime.command.navigation');
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Navigation {
|
|
4
|
+
export default class Navigation {
|
|
6
5
|
constructor(browser, pageCompleteCheck) {
|
|
7
6
|
this.browser = browser;
|
|
8
7
|
this.pageCompleteCheck = pageCompleteCheck;
|
|
@@ -18,10 +17,10 @@ class Navigation {
|
|
|
18
17
|
if (options && 'wait' in options && options.wait == true) {
|
|
19
18
|
return this.browser.extraWait(this.pageCompleteCheck);
|
|
20
19
|
}
|
|
21
|
-
} catch (
|
|
20
|
+
} catch (error) {
|
|
22
21
|
log.error('Could not navigate back');
|
|
23
|
-
log.verbose(
|
|
24
|
-
throw Error(`Could not navigate back`);
|
|
22
|
+
log.verbose(error);
|
|
23
|
+
throw new Error(`Could not navigate back`);
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
26
|
|
|
@@ -35,10 +34,10 @@ class Navigation {
|
|
|
35
34
|
if (options && 'wait' in options && options.wait === true) {
|
|
36
35
|
return this.browser.extraWait(this.pageCompleteCheck);
|
|
37
36
|
}
|
|
38
|
-
} catch (
|
|
37
|
+
} catch (error) {
|
|
39
38
|
log.error('Could not navigate forward');
|
|
40
|
-
log.verbose(
|
|
41
|
-
throw Error(`Could not navigate forward`);
|
|
39
|
+
log.verbose(error);
|
|
40
|
+
throw new Error(`Could not navigate forward`);
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
|
|
@@ -52,11 +51,10 @@ class Navigation {
|
|
|
52
51
|
if (options && 'wait' in options && options.wait === true) {
|
|
53
52
|
return this.browser.extraWait(this.pageCompleteCheck);
|
|
54
53
|
}
|
|
55
|
-
} catch (
|
|
54
|
+
} catch (error) {
|
|
56
55
|
log.error('Could not refresh page');
|
|
57
|
-
log.verbose(
|
|
58
|
-
throw Error(`Could not refresh page`);
|
|
56
|
+
log.verbose(error);
|
|
57
|
+
throw new Error(`Could not refresh page`);
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
|
-
module.exports = Navigation;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
class Screenshot {
|
|
1
|
+
export default class Screenshot {
|
|
4
2
|
constructor(screenshotManager, browser, index) {
|
|
5
3
|
this.screenshotManager = screenshotManager;
|
|
6
4
|
this.browser = browser;
|
|
@@ -15,4 +13,3 @@ class Screenshot {
|
|
|
15
13
|
return this.screenshotManager.save(name, screenshot, url, this.index);
|
|
16
14
|
}
|
|
17
15
|
}
|
|
18
|
-
module.exports = Screenshot;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const log = require('intel').getLogger('browsertime.command.scroll');
|
|
4
|
-
|
|
1
|
+
import intel from 'intel';
|
|
2
|
+
const log = intel.getLogger('browsertime.command.scroll');
|
|
5
3
|
const delay = ms => new Promise(res => setTimeout(res, ms));
|
|
6
|
-
class Scroll {
|
|
4
|
+
export default class Scroll {
|
|
7
5
|
constructor(browser, options) {
|
|
8
6
|
this.browser = browser;
|
|
9
7
|
this.options = options;
|
|
@@ -30,7 +28,7 @@ class Scroll {
|
|
|
30
28
|
log.error(
|
|
31
29
|
'scroll.byLines is only supported in Firefox. Please use scroll.byPixels instead.'
|
|
32
30
|
);
|
|
33
|
-
throw Error(
|
|
31
|
+
throw new Error(
|
|
34
32
|
'scroll.byLines is only supported in Firefox. Please use scroll.byPixels instead.'
|
|
35
33
|
);
|
|
36
34
|
}
|
|
@@ -76,4 +74,3 @@ class Scroll {
|
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
76
|
}
|
|
79
|
-
module.exports = Scroll;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import intel from 'intel';
|
|
2
|
+
const log = intel.getLogger('browsertime.command.select');
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Select {
|
|
4
|
+
export default class Select {
|
|
6
5
|
constructor(browser) {
|
|
7
6
|
this.browser = browser;
|
|
8
7
|
}
|
|
@@ -19,10 +18,10 @@ class Select {
|
|
|
19
18
|
try {
|
|
20
19
|
const script = `const select = document.getElementById('${selectId}'); select.value = '${value}'; select.dispatchEvent(new Event('change'));`;
|
|
21
20
|
await this.browser.runScript(script, 'CUSTOM');
|
|
22
|
-
} catch (
|
|
21
|
+
} catch (error) {
|
|
23
22
|
log.error('Could not select value for select with id %s', selectId);
|
|
24
|
-
log.verbose(
|
|
25
|
-
throw Error(`Could not select value for select with id ${selectId}`);
|
|
23
|
+
log.verbose(error);
|
|
24
|
+
throw new Error(`Could not select value for select with id ${selectId}`);
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
27
|
|
|
@@ -38,10 +37,12 @@ class Select {
|
|
|
38
37
|
try {
|
|
39
38
|
const script = `const select = document.querySelector("select[name='${selectName}']"); select.value = '${value}'; select.dispatchEvent(new Event('change'));`;
|
|
40
39
|
await this.browser.runScript(script, 'CUSTOM');
|
|
41
|
-
} catch (
|
|
40
|
+
} catch (error) {
|
|
42
41
|
log.error('Could not select value for select with name %s', selectName);
|
|
43
|
-
log.verbose(
|
|
44
|
-
throw Error(
|
|
42
|
+
log.verbose(error);
|
|
43
|
+
throw new Error(
|
|
44
|
+
`Could not select value for select with name ${selectName}`
|
|
45
|
+
);
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
|
|
@@ -58,13 +59,13 @@ class Select {
|
|
|
58
59
|
const script = `const select = document.getElementById('${selectId}'); select.selectedIndex = ${index};select.dispatchEvent(new Event('change'));`;
|
|
59
60
|
const value = await this.browser.runScript(script, 'CUSTOM');
|
|
60
61
|
return value;
|
|
61
|
-
} catch (
|
|
62
|
+
} catch (error) {
|
|
62
63
|
log.error(
|
|
63
64
|
'Could not select value for select with id %s by index',
|
|
64
65
|
selectId
|
|
65
66
|
);
|
|
66
|
-
log.verbose(
|
|
67
|
-
throw Error(`Could not select value for select with id ${selectId}`);
|
|
67
|
+
log.verbose(error);
|
|
68
|
+
throw new Error(`Could not select value for select with id ${selectId}`);
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
|
|
@@ -81,13 +82,13 @@ class Select {
|
|
|
81
82
|
const script = `const select = document.querySelector("select[name='${selectName}']"); select.selectedIndex = ${index};select.dispatchEvent(new Event('change'));`;
|
|
82
83
|
const value = await this.browser.runScript(script, 'CUSTOM');
|
|
83
84
|
return value;
|
|
84
|
-
} catch (
|
|
85
|
+
} catch (error) {
|
|
85
86
|
log.error(
|
|
86
87
|
'Could not select value for select with name %s by index',
|
|
87
88
|
selectName
|
|
88
89
|
);
|
|
89
|
-
log.verbose(
|
|
90
|
-
throw Error(`Could not select value for select name ${selectName}`);
|
|
90
|
+
log.verbose(error);
|
|
91
|
+
throw new Error(`Could not select value for select name ${selectName}`);
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
|
|
@@ -102,10 +103,10 @@ class Select {
|
|
|
102
103
|
const script = `const select = document.getElementById('${selectId}'); select.selectedIndex = -1;select.dispatchEvent(new Event('change'));`;
|
|
103
104
|
const value = await this.browser.runScript(script, 'CUSTOM');
|
|
104
105
|
return value;
|
|
105
|
-
} catch (
|
|
106
|
+
} catch (error) {
|
|
106
107
|
log.error('Could not deleselect by select id %s', selectId);
|
|
107
|
-
log.verbose(
|
|
108
|
-
throw Error(`Could not deleselect by select id ${selectId}`);
|
|
108
|
+
log.verbose(error);
|
|
109
|
+
throw new Error(`Could not deleselect by select id ${selectId}`);
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
112
|
|
|
@@ -127,10 +128,10 @@ class Select {
|
|
|
127
128
|
try {
|
|
128
129
|
const value = await this.browser.runScript(script, 'CUSTOM');
|
|
129
130
|
return value;
|
|
130
|
-
} catch (
|
|
131
|
+
} catch (error) {
|
|
131
132
|
log.error('Could not get select options for id %s', selectId);
|
|
132
|
-
log.verbose(
|
|
133
|
-
throw Error(`Could not get select options for id ${selectId}`);
|
|
133
|
+
log.verbose(error);
|
|
134
|
+
throw new Error(`Could not get select options for id ${selectId}`);
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
137
|
|
|
@@ -145,11 +146,10 @@ class Select {
|
|
|
145
146
|
const script = `const select = document.getElementById('${selectId}'); return select.options[select.selectedIndex].value;`;
|
|
146
147
|
const value = await this.browser.runScript(script, 'CUSTOM');
|
|
147
148
|
return value;
|
|
148
|
-
} catch (
|
|
149
|
+
} catch (error) {
|
|
149
150
|
log.error('Could not select value for select with id %s', selectId);
|
|
150
|
-
log.verbose(
|
|
151
|
-
throw Error(`Could not select value for select with id ${selectId}`);
|
|
151
|
+
log.verbose(error);
|
|
152
|
+
throw new Error(`Could not select value for select with id ${selectId}`);
|
|
152
153
|
}
|
|
153
154
|
}
|
|
154
155
|
}
|
|
155
|
-
module.exports = Select;
|