@cloudscape-design/browser-test-tools 3.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/LICENSE +201 -0
- package/NOTICE +2 -0
- package/README.md +21 -0
- package/browser.d.ts +1 -0
- package/browser.js +1 -0
- package/chrome-launcher.d.ts +1 -0
- package/chrome-launcher.js +1 -0
- package/dist/browser-scripts/events-spy.d.ts +8 -0
- package/dist/browser-scripts/events-spy.js +27 -0
- package/dist/browser-scripts/index.d.ts +3 -0
- package/dist/browser-scripts/index.js +21 -0
- package/dist/browser-scripts/scroll.d.ts +10 -0
- package/dist/browser-scripts/scroll.js +45 -0
- package/dist/browser-scripts/sizes.d.ts +3 -0
- package/dist/browser-scripts/sizes.js +33 -0
- package/dist/browser.d.ts +2 -0
- package/dist/browser.js +40 -0
- package/dist/browsers/browser-creator.d.ts +21 -0
- package/dist/browsers/browser-creator.js +66 -0
- package/dist/browsers/browserstack.d.ts +21 -0
- package/dist/browsers/browserstack.js +138 -0
- package/dist/browsers/capabilities.d.ts +4 -0
- package/dist/browsers/capabilities.js +84 -0
- package/dist/browsers/devicefarm-mobile.d.ts +8 -0
- package/dist/browsers/devicefarm-mobile.js +33 -0
- package/dist/browsers/devicefarm.d.ts +15 -0
- package/dist/browsers/devicefarm.js +78 -0
- package/dist/browsers/index.d.ts +4 -0
- package/dist/browsers/index.js +16 -0
- package/dist/browsers/local.d.ts +8 -0
- package/dist/browsers/local.js +76 -0
- package/dist/chrome-launcher.d.ts +2 -0
- package/dist/chrome-launcher.js +52 -0
- package/dist/exceptions.d.ts +17 -0
- package/dist/exceptions.js +48 -0
- package/dist/image-utils/compare.d.ts +10 -0
- package/dist/image-utils/compare.js +68 -0
- package/dist/image-utils/crop.d.ts +5 -0
- package/dist/image-utils/crop.js +21 -0
- package/dist/image-utils/index.d.ts +3 -0
- package/dist/image-utils/index.js +11 -0
- package/dist/image-utils/merge.d.ts +1 -0
- package/dist/image-utils/merge.js +23 -0
- package/dist/image-utils/utils.d.ts +7 -0
- package/dist/image-utils/utils.js +59 -0
- package/dist/page-objects/base.d.ts +76 -0
- package/dist/page-objects/base.js +186 -0
- package/dist/page-objects/browser-scripts.d.ts +1 -0
- package/dist/page-objects/browser-scripts.js +11 -0
- package/dist/page-objects/events-spy.d.ts +10 -0
- package/dist/page-objects/events-spy.js +22 -0
- package/dist/page-objects/full-page-screenshot.d.ts +2 -0
- package/dist/page-objects/full-page-screenshot.js +66 -0
- package/dist/page-objects/index.d.ts +4 -0
- package/dist/page-objects/index.js +14 -0
- package/dist/page-objects/screenshot.d.ts +10 -0
- package/dist/page-objects/screenshot.js +57 -0
- package/dist/page-objects/types.d.ts +27 -0
- package/dist/page-objects/types.js +2 -0
- package/dist/page-objects/utils.d.ts +8 -0
- package/dist/page-objects/utils.js +72 -0
- package/dist/use-browser.d.ts +15 -0
- package/dist/use-browser.js +50 -0
- package/image-utils.d.ts +1 -0
- package/image-utils.js +1 -0
- package/package.json +63 -0
- package/page-objects.d.ts +1 -0
- package/page-objects.js +1 -0
- package/use-browser.d.ts +1 -0
- package/use-browser.js +1 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
30
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
31
|
+
const url_1 = require("url");
|
|
32
|
+
const p_retry_1 = __importStar(require("p-retry"));
|
|
33
|
+
const browser_creator_1 = __importDefault(require("./browser-creator"));
|
|
34
|
+
const exceptions_1 = require("../exceptions");
|
|
35
|
+
const capabilities_1 = require("./capabilities");
|
|
36
|
+
const N_SEC_SLEEP_BEFORE_RETRY = 30;
|
|
37
|
+
const browserStackHub = 'http://hub.browserstack.com:80/wd/hub';
|
|
38
|
+
const browsers = {
|
|
39
|
+
Firefox: {
|
|
40
|
+
browserName: 'firefox',
|
|
41
|
+
// Leave blank so we get the latest version. 'beta' is also a valid option
|
|
42
|
+
// browserVersion: '69.0',
|
|
43
|
+
'bstack:options': {
|
|
44
|
+
seleniumVersion: '3.14.0',
|
|
45
|
+
os: 'Windows',
|
|
46
|
+
osVersion: '10',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
Chrome: {
|
|
50
|
+
browserName: 'chrome',
|
|
51
|
+
// Leave blank so we get the latest version. 'beta' is also a valid option
|
|
52
|
+
// browserVersion: '75.0',
|
|
53
|
+
'bstack:options': {
|
|
54
|
+
seleniumVersion: '3.5.2',
|
|
55
|
+
os: 'Windows',
|
|
56
|
+
osVersion: '10',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
Safari: {
|
|
60
|
+
browserName: 'safari',
|
|
61
|
+
browserVersion: '15.1',
|
|
62
|
+
'bstack:options': {
|
|
63
|
+
seleniumVersion: '3.141.59',
|
|
64
|
+
os: 'OS X',
|
|
65
|
+
osVersion: 'Monterey',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
IE11: {
|
|
69
|
+
browserName: 'internet explorer',
|
|
70
|
+
browserVersion: '11.0',
|
|
71
|
+
'bstack:options': {
|
|
72
|
+
seleniumVersion: '3.141.59',
|
|
73
|
+
ie: {
|
|
74
|
+
driver: '3.141.59',
|
|
75
|
+
},
|
|
76
|
+
os: 'Windows',
|
|
77
|
+
osVersion: '8.1',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
IE11Win7: {
|
|
81
|
+
browserName: 'internet explorer',
|
|
82
|
+
browserVersion: '11.0',
|
|
83
|
+
'bstack:options': {
|
|
84
|
+
seleniumVersion: '3.141.59',
|
|
85
|
+
ie: {
|
|
86
|
+
driver: '3.141.59',
|
|
87
|
+
},
|
|
88
|
+
os: 'Windows',
|
|
89
|
+
osVersion: '7',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
Edge: {
|
|
93
|
+
browserName: 'edge',
|
|
94
|
+
browserVersion: '18.0',
|
|
95
|
+
'bstack:options': {
|
|
96
|
+
seleniumVersion: '3.5.2',
|
|
97
|
+
os: 'Windows',
|
|
98
|
+
osVersion: '10',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
class BrowserStackBrowserCreator extends browser_creator_1.default {
|
|
103
|
+
async getBrowser(options) {
|
|
104
|
+
const nSecSleepBeforeRetry = this.options.nSecSleepBeforeRetry || N_SEC_SLEEP_BEFORE_RETRY;
|
|
105
|
+
return (0, p_retry_1.default)(async () => {
|
|
106
|
+
try {
|
|
107
|
+
const browser = await this.setupBrowser(options);
|
|
108
|
+
return browser;
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
if (error instanceof Error && error.message.indexOf(exceptions_1.BrowserStackFullQueueErrorText) > -1) {
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
throw new p_retry_1.AbortError(error);
|
|
115
|
+
}
|
|
116
|
+
}, {
|
|
117
|
+
minTimeout: nSecSleepBeforeRetry * 1000,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
async __getBrowserUrl() {
|
|
121
|
+
return new url_1.URL(browserStackHub);
|
|
122
|
+
}
|
|
123
|
+
__getCapabilities() {
|
|
124
|
+
const capabilities = (0, capabilities_1.getCapability)(this.browserName, browsers);
|
|
125
|
+
const browserstackOptions = this.options;
|
|
126
|
+
return {
|
|
127
|
+
...capabilities,
|
|
128
|
+
'bstack:options': {
|
|
129
|
+
...capabilities['bstack:options'],
|
|
130
|
+
projectName: browserstackOptions.projectName,
|
|
131
|
+
buildName: browserstackOptions.buildName,
|
|
132
|
+
userName: browserstackOptions.credentials.user,
|
|
133
|
+
accessKey: browserstackOptions.credentials.key,
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.default = BrowserStackBrowserCreator;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Capabilities } from '@wdio/types';
|
|
2
|
+
declare const defaultCapabilities: Record<string, Capabilities.DesiredCapabilities>;
|
|
3
|
+
export declare function getCapability<T>(browserName: string, capabilities: Record<string, T>): T;
|
|
4
|
+
export default defaultCapabilities;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCapability = void 0;
|
|
4
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
const exceptions_1 = require("../exceptions");
|
|
7
|
+
const defaultCapabilities = {
|
|
8
|
+
Chrome: {
|
|
9
|
+
browserName: 'chrome',
|
|
10
|
+
},
|
|
11
|
+
ChromeHeadless: {
|
|
12
|
+
browserName: 'chrome',
|
|
13
|
+
'goog:chromeOptions': {
|
|
14
|
+
// inspired by https://github.com/alixaxel/chrome-aws-lambda/blob/master/source/index.js#L71-L114
|
|
15
|
+
args: [
|
|
16
|
+
'--disable-background-timer-throttling',
|
|
17
|
+
'--disable-breakpad',
|
|
18
|
+
'--disable-client-side-phishing-detection',
|
|
19
|
+
'--disable-cloud-import',
|
|
20
|
+
'--disable-default-apps',
|
|
21
|
+
'--disable-dev-shm-usage',
|
|
22
|
+
'--disable-extensions',
|
|
23
|
+
'--disable-gesture-typing',
|
|
24
|
+
'--disable-hang-monitor',
|
|
25
|
+
'--disable-infobars',
|
|
26
|
+
'--disable-notifications',
|
|
27
|
+
'--disable-offer-store-unmasked-wallet-cards',
|
|
28
|
+
'--disable-offer-upload-credit-cards',
|
|
29
|
+
'--disable-popup-blocking',
|
|
30
|
+
'--disable-print-preview',
|
|
31
|
+
'--disable-prompt-on-repost',
|
|
32
|
+
'--disable-setuid-sandbox',
|
|
33
|
+
'--disable-speech-api',
|
|
34
|
+
'--disable-sync',
|
|
35
|
+
'--disable-tab-for-desktop-share',
|
|
36
|
+
'--disable-translate',
|
|
37
|
+
'--disable-voice-input',
|
|
38
|
+
'--disable-wake-on-wifi',
|
|
39
|
+
'--disk-cache-size=33554432',
|
|
40
|
+
'--enable-async-dns',
|
|
41
|
+
'--enable-simple-cache-backend',
|
|
42
|
+
'--enable-tcp-fast-open',
|
|
43
|
+
'--enable-webgl',
|
|
44
|
+
'--hide-scrollbars',
|
|
45
|
+
'--ignore-gpu-blacklist',
|
|
46
|
+
'--media-cache-size=33554432',
|
|
47
|
+
'--metrics-recording-only',
|
|
48
|
+
'--mute-audio',
|
|
49
|
+
'--no-default-browser-check',
|
|
50
|
+
'--no-first-run',
|
|
51
|
+
'--no-pings',
|
|
52
|
+
'--no-zygote',
|
|
53
|
+
'--password-store=basic',
|
|
54
|
+
'--prerender-from-omnibox=disabled',
|
|
55
|
+
'--no-sandbox',
|
|
56
|
+
'--disable-gpu',
|
|
57
|
+
'--headless',
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
Firefox: {
|
|
62
|
+
browserName: 'firefox',
|
|
63
|
+
'moz:firefoxOptions': {
|
|
64
|
+
prefs: {
|
|
65
|
+
'fission.webContentIsolationStrategy': 0,
|
|
66
|
+
'fission.bfcacheInParent': false,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
Safari: {
|
|
71
|
+
browserName: 'safari',
|
|
72
|
+
},
|
|
73
|
+
IE11: {
|
|
74
|
+
browserName: 'internet explorer',
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
function getCapability(browserName, capabilities) {
|
|
78
|
+
if (!(browserName in capabilities)) {
|
|
79
|
+
throw new exceptions_1.FatalError(`Browser ${browserName} is not supported in this provider`);
|
|
80
|
+
}
|
|
81
|
+
return capabilities[browserName];
|
|
82
|
+
}
|
|
83
|
+
exports.getCapability = getCapability;
|
|
84
|
+
exports.default = defaultCapabilities;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { URL } from 'url';
|
|
3
|
+
import BrowserCreator from './browser-creator';
|
|
4
|
+
import type { Capabilities } from '@wdio/types';
|
|
5
|
+
export default class MobileBrowserCreator extends BrowserCreator {
|
|
6
|
+
__getBrowserUrl(): Promise<URL>;
|
|
7
|
+
__getCapabilities(): Capabilities.DesiredCapabilities;
|
|
8
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
7
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
8
|
+
const url_1 = require("url");
|
|
9
|
+
const browser_creator_1 = __importDefault(require("./browser-creator"));
|
|
10
|
+
const capabilities_1 = require("./capabilities");
|
|
11
|
+
// The remaining options like browserName, deviceName, etc. will be covered
|
|
12
|
+
// by default capabilities in DeviceFarm and/or the Appium server.
|
|
13
|
+
const mobileBrowsers = {
|
|
14
|
+
iOS: {
|
|
15
|
+
'appium:automationName': 'XCUITest',
|
|
16
|
+
'appium:platformName': 'iOS',
|
|
17
|
+
'appium:newCommandTimeout': 180,
|
|
18
|
+
},
|
|
19
|
+
Android: {
|
|
20
|
+
'appium:automationName': 'UiAutomator2',
|
|
21
|
+
'appium:platformName': 'Android',
|
|
22
|
+
'appium:newCommandTimeout': 180,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
class MobileBrowserCreator extends browser_creator_1.default {
|
|
26
|
+
async __getBrowserUrl() {
|
|
27
|
+
return new url_1.URL(this.options.seleniumUrl);
|
|
28
|
+
}
|
|
29
|
+
__getCapabilities() {
|
|
30
|
+
return (0, capabilities_1.getCapability)(this.browserName, mobileBrowsers);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.default = MobileBrowserCreator;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { URL } from 'url';
|
|
3
|
+
import { CredentialsOptions } from 'aws-sdk/lib/credentials';
|
|
4
|
+
import BrowserCreator from './browser-creator';
|
|
5
|
+
import type { Capabilities } from '@wdio/types';
|
|
6
|
+
export interface DevicefarmOptions {
|
|
7
|
+
retryCount?: number;
|
|
8
|
+
projectArn: string;
|
|
9
|
+
expiresInSeconds?: number;
|
|
10
|
+
credentials: CredentialsOptions;
|
|
11
|
+
}
|
|
12
|
+
export default class DevicefarmBrowserCreator extends BrowserCreator {
|
|
13
|
+
protected __getBrowserUrl(): Promise<URL>;
|
|
14
|
+
protected __getCapabilities(): Capabilities.DesiredCapabilities;
|
|
15
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
30
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
31
|
+
const url_1 = require("url");
|
|
32
|
+
const p_retry_1 = __importStar(require("p-retry"));
|
|
33
|
+
const devicefarm_1 = __importDefault(require("aws-sdk/clients/devicefarm"));
|
|
34
|
+
const browser_creator_1 = __importDefault(require("./browser-creator"));
|
|
35
|
+
const capabilities_1 = __importStar(require("./capabilities"));
|
|
36
|
+
const exceptions_1 = require("../exceptions");
|
|
37
|
+
// This uses undocumented options which prevents proper typing
|
|
38
|
+
const capabilities = {
|
|
39
|
+
...capabilities_1.default,
|
|
40
|
+
IE11: {
|
|
41
|
+
browserName: 'internet explorer',
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
class DevicefarmBrowserCreator extends browser_creator_1.default {
|
|
45
|
+
async __getBrowserUrl() {
|
|
46
|
+
const options = this.options;
|
|
47
|
+
const client = new devicefarm_1.default({ credentials: options.credentials, region: 'us-west-2' });
|
|
48
|
+
const response = await (0, p_retry_1.default)(async () => {
|
|
49
|
+
try {
|
|
50
|
+
const response = await client
|
|
51
|
+
.createTestGridUrl({
|
|
52
|
+
projectArn: options.projectArn,
|
|
53
|
+
expiresInSeconds: options.expiresInSeconds || 300,
|
|
54
|
+
})
|
|
55
|
+
.promise();
|
|
56
|
+
return response;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (isAWSError(error) && error.code === 'ThrottlingException') {
|
|
60
|
+
// Retries with backoff when throttled
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
throw new p_retry_1.AbortError(error); // Abort on any other error
|
|
64
|
+
}
|
|
65
|
+
}, { retries: options.retryCount || 10 });
|
|
66
|
+
if (!response.url) {
|
|
67
|
+
throw new exceptions_1.FatalError('Invalid response from devicefarm: ' + JSON.stringify(response));
|
|
68
|
+
}
|
|
69
|
+
return new url_1.URL(response.url);
|
|
70
|
+
}
|
|
71
|
+
__getCapabilities() {
|
|
72
|
+
return (0, capabilities_1.getCapability)(this.browserName, capabilities);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.default = DevicefarmBrowserCreator;
|
|
76
|
+
function isAWSError(obj) {
|
|
77
|
+
return obj instanceof Error && typeof obj['code'] === 'string';
|
|
78
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.local = exports.devicefarmMobile = exports.devicefarm = exports.browserstack = void 0;
|
|
7
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
8
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
var browserstack_1 = require("./browserstack");
|
|
10
|
+
Object.defineProperty(exports, "browserstack", { enumerable: true, get: function () { return __importDefault(browserstack_1).default; } });
|
|
11
|
+
var devicefarm_1 = require("./devicefarm");
|
|
12
|
+
Object.defineProperty(exports, "devicefarm", { enumerable: true, get: function () { return __importDefault(devicefarm_1).default; } });
|
|
13
|
+
var devicefarm_mobile_1 = require("./devicefarm-mobile");
|
|
14
|
+
Object.defineProperty(exports, "devicefarmMobile", { enumerable: true, get: function () { return __importDefault(devicefarm_mobile_1).default; } });
|
|
15
|
+
var local_1 = require("./local");
|
|
16
|
+
Object.defineProperty(exports, "local", { enumerable: true, get: function () { return __importDefault(local_1).default; } });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { URL } from 'url';
|
|
3
|
+
import BrowserCreator from './browser-creator';
|
|
4
|
+
import type { Capabilities } from '@wdio/types';
|
|
5
|
+
export default class LocalBrowserCreator extends BrowserCreator {
|
|
6
|
+
__getBrowserUrl(): Promise<URL>;
|
|
7
|
+
__getCapabilities(): Capabilities.DesiredCapabilities;
|
|
8
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
var _a, _b;
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
31
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
32
|
+
const url_1 = require("url");
|
|
33
|
+
const browser_creator_1 = __importDefault(require("./browser-creator"));
|
|
34
|
+
const capabilities_1 = __importStar(require("./capabilities"));
|
|
35
|
+
const localBrowsers = {
|
|
36
|
+
...capabilities_1.default,
|
|
37
|
+
Chrome: {
|
|
38
|
+
...capabilities_1.default.Chrome,
|
|
39
|
+
},
|
|
40
|
+
ChromeHeadless: {
|
|
41
|
+
...capabilities_1.default.ChromeHeadless,
|
|
42
|
+
'goog:chromeOptions': {
|
|
43
|
+
...capabilities_1.default.ChromeHeadless['goog:chromeOptions'],
|
|
44
|
+
// do not use retina screen when testing locally
|
|
45
|
+
mobileEmulation: {
|
|
46
|
+
deviceMetrics: {
|
|
47
|
+
pixelRatio: 1,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
ChromeHeadlessIntegration: {
|
|
53
|
+
...capabilities_1.default.ChromeHeadless,
|
|
54
|
+
'goog:chromeOptions': {
|
|
55
|
+
...capabilities_1.default.ChromeHeadless['goog:chromeOptions'],
|
|
56
|
+
args: [
|
|
57
|
+
'--force-prefers-reduced-motion',
|
|
58
|
+
...((_b = (_a = capabilities_1.default.ChromeHeadless['goog:chromeOptions']) === null || _a === void 0 ? void 0 : _a.args) !== null && _b !== void 0 ? _b : []),
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
Firefox: {
|
|
63
|
+
...capabilities_1.default.Firefox,
|
|
64
|
+
// https://firefox-source-docs.mozilla.org/testing/geckodriver/Capabilities.html
|
|
65
|
+
'moz:debuggerAddress': true,
|
|
66
|
+
}, // https://github.com/webdriverio/webdriverio/pull/8355
|
|
67
|
+
};
|
|
68
|
+
class LocalBrowserCreator extends browser_creator_1.default {
|
|
69
|
+
async __getBrowserUrl() {
|
|
70
|
+
return new url_1.URL(this.options.seleniumUrl);
|
|
71
|
+
}
|
|
72
|
+
__getCapabilities() {
|
|
73
|
+
return (0, capabilities_1.getCapability)(this.browserName, localBrowsers);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.default = LocalBrowserCreator;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.startWebdriver = exports.shutdownWebdriver = void 0;
|
|
7
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
8
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
const child_process_1 = require("child_process");
|
|
10
|
+
const exceptions_1 = require("./exceptions");
|
|
11
|
+
const readline_1 = __importDefault(require("readline"));
|
|
12
|
+
function spawnChromeDriver(port) {
|
|
13
|
+
const params = [`--port=${port}`, '--log-level=SEVERE', '--path=/'];
|
|
14
|
+
try {
|
|
15
|
+
(0, child_process_1.execSync)('hash chromedriver');
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
throw new exceptions_1.FatalError("Cannot find local chromedriver. Did you run 'npm i -g chromedriver'?");
|
|
19
|
+
}
|
|
20
|
+
return (0, child_process_1.spawn)('chromedriver', params);
|
|
21
|
+
}
|
|
22
|
+
let webdriverProcess;
|
|
23
|
+
function shutdownWebdriver() {
|
|
24
|
+
if (webdriverProcess) {
|
|
25
|
+
webdriverProcess.kill();
|
|
26
|
+
webdriverProcess = undefined;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.shutdownWebdriver = shutdownWebdriver;
|
|
30
|
+
function startWebdriver(port = '9515') {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
webdriverProcess = spawnChromeDriver(port);
|
|
33
|
+
webdriverProcess.on('error', error => {
|
|
34
|
+
shutdownWebdriver();
|
|
35
|
+
reject(error);
|
|
36
|
+
});
|
|
37
|
+
webdriverProcess.on('exit', () => {
|
|
38
|
+
shutdownWebdriver();
|
|
39
|
+
reject(new Error('Webdriver process exited too early'));
|
|
40
|
+
});
|
|
41
|
+
webdriverProcess.stdout.once('data', () => resolve());
|
|
42
|
+
const errorReader = readline_1.default.createInterface({ input: webdriverProcess.stderr });
|
|
43
|
+
errorReader.on('line', (line) => {
|
|
44
|
+
// chromeDriver spams to the error stream on macOS
|
|
45
|
+
// https://bugs.chromium.org/p/chromedriver/issues/detail?id=2909
|
|
46
|
+
if (line.indexOf('Please call TIS/TSM in main thread!!!') === -1) {
|
|
47
|
+
console.error(line);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.startWebdriver = startWebdriver;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare class CustomError extends Error {
|
|
2
|
+
constructor(message: string, error?: Error);
|
|
3
|
+
}
|
|
4
|
+
export declare class ScreenshotTakeError extends CustomError {
|
|
5
|
+
}
|
|
6
|
+
export declare class BrowserError extends CustomError {
|
|
7
|
+
}
|
|
8
|
+
export declare class FatalError extends CustomError {
|
|
9
|
+
}
|
|
10
|
+
export declare class FileHandlingError extends FatalError {
|
|
11
|
+
}
|
|
12
|
+
export declare class DiagnosticsError extends FatalError {
|
|
13
|
+
}
|
|
14
|
+
export declare const BrowserStackFullQueueErrorText = "All parallel tests are currently in use, including the queued tests. Please wait to finish or upgrade your plan to add more sessions.";
|
|
15
|
+
export declare const WebdriverIoUnsupportedPuppeteerErrorText = "Using DevTools capabilities is not supported for this session.";
|
|
16
|
+
export declare const WebdriverIoRemotePuppeteerErrorText = "Could't find remote debug port in Firefox options";
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.WebdriverIoRemotePuppeteerErrorText = exports.WebdriverIoUnsupportedPuppeteerErrorText = exports.BrowserStackFullQueueErrorText = exports.DiagnosticsError = exports.FileHandlingError = exports.FatalError = exports.BrowserError = exports.ScreenshotTakeError = void 0;
|
|
6
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#ES6_Custom_Error_Class
|
|
7
|
+
class CustomError extends Error {
|
|
8
|
+
constructor(message, error) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = this.constructor.name;
|
|
11
|
+
if (typeof Error.captureStackTrace === 'function') {
|
|
12
|
+
Error.captureStackTrace(this, this.constructor);
|
|
13
|
+
}
|
|
14
|
+
if (error) {
|
|
15
|
+
this.stack = (this.stack || '') + error.stack;
|
|
16
|
+
this.message += `: ${error.message}`;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
// Can originate from issues that arise during screenshot taking, does
|
|
21
|
+
// not cover test failures, we use assertions for that.
|
|
22
|
+
// Requires retry
|
|
23
|
+
class ScreenshotTakeError extends CustomError {
|
|
24
|
+
}
|
|
25
|
+
exports.ScreenshotTakeError = ScreenshotTakeError;
|
|
26
|
+
// Used for rethrowing browser exceptions
|
|
27
|
+
// Requires retry
|
|
28
|
+
class BrowserError extends CustomError {
|
|
29
|
+
}
|
|
30
|
+
exports.BrowserError = BrowserError;
|
|
31
|
+
// A family of errors that will not cause test runner to retry a failed test
|
|
32
|
+
class FatalError extends CustomError {
|
|
33
|
+
}
|
|
34
|
+
exports.FatalError = FatalError;
|
|
35
|
+
// Can originate from generic file handling and image processing
|
|
36
|
+
// Does not require retry
|
|
37
|
+
class FileHandlingError extends FatalError {
|
|
38
|
+
}
|
|
39
|
+
exports.FileHandlingError = FileHandlingError;
|
|
40
|
+
// Used for managing control flow, developer experience and diagnostics
|
|
41
|
+
// Does not require retry
|
|
42
|
+
class DiagnosticsError extends FatalError {
|
|
43
|
+
}
|
|
44
|
+
exports.DiagnosticsError = DiagnosticsError;
|
|
45
|
+
exports.BrowserStackFullQueueErrorText = 'All parallel tests are currently in use, including the queued tests. Please wait to finish or upgrade your plan to add more sessions.';
|
|
46
|
+
// https://github.com/webdriverio/webdriverio/blob/f9eae7a6747b4bf55975a891f25643bba2165936/packages/webdriverio/src/commands/browser/getPuppeteer.ts#L123
|
|
47
|
+
exports.WebdriverIoUnsupportedPuppeteerErrorText = 'Using DevTools capabilities is not supported for this session.';
|
|
48
|
+
exports.WebdriverIoRemotePuppeteerErrorText = "Could't find remote debug port in Firefox options";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ScreenshotWithOffset } from '../page-objects/types';
|
|
3
|
+
export interface CropAndCompareResult {
|
|
4
|
+
firstImage: Buffer;
|
|
5
|
+
secondImage: Buffer;
|
|
6
|
+
diffImage: Buffer | null;
|
|
7
|
+
isEqual: boolean;
|
|
8
|
+
diffPixels: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function cropAndCompare(firstScreenshot: ScreenshotWithOffset, secondScreenshot: ScreenshotWithOffset): Promise<CropAndCompareResult>;
|