playwright-automation-core 1.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 +21 -0
- package/README.md +225 -0
- package/dist/api/api.assertions.d.ts +196 -0
- package/dist/api/api.assertions.d.ts.map +1 -0
- package/dist/api/api.assertions.js +462 -0
- package/dist/api/api.assertions.js.map +1 -0
- package/dist/api/api.builder.d.ts +134 -0
- package/dist/api/api.builder.d.ts.map +1 -0
- package/dist/api/api.builder.js +273 -0
- package/dist/api/api.builder.js.map +1 -0
- package/dist/api/api.client.d.ts +157 -0
- package/dist/api/api.client.d.ts.map +1 -0
- package/dist/api/api.client.js +493 -0
- package/dist/api/api.client.js.map +1 -0
- package/dist/api/index.d.ts +8 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +17 -0
- package/dist/api/index.js.map +1 -0
- package/dist/core/base.driver.d.ts +130 -0
- package/dist/core/base.driver.d.ts.map +1 -0
- package/dist/core/base.driver.js +264 -0
- package/dist/core/base.driver.js.map +1 -0
- package/dist/core/driver.factory.d.ts +120 -0
- package/dist/core/driver.factory.d.ts.map +1 -0
- package/dist/core/driver.factory.js +222 -0
- package/dist/core/driver.factory.js.map +1 -0
- package/dist/core/element.actions.d.ts +119 -0
- package/dist/core/element.actions.d.ts.map +1 -0
- package/dist/core/element.actions.js +379 -0
- package/dist/core/element.actions.js.map +1 -0
- package/dist/core/hook.manager.d.ts +186 -0
- package/dist/core/hook.manager.d.ts.map +1 -0
- package/dist/core/hook.manager.js +297 -0
- package/dist/core/hook.manager.js.map +1 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +22 -0
- package/dist/core/index.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +128 -0
- package/dist/index.js.map +1 -0
- package/dist/mobile/index.d.ts +7 -0
- package/dist/mobile/index.d.ts.map +1 -0
- package/dist/mobile/index.js +14 -0
- package/dist/mobile/index.js.map +1 -0
- package/dist/mobile/mobile.assertions.d.ts +146 -0
- package/dist/mobile/mobile.assertions.d.ts.map +1 -0
- package/dist/mobile/mobile.assertions.js +333 -0
- package/dist/mobile/mobile.assertions.js.map +1 -0
- package/dist/mobile/mobile.driver.d.ts +297 -0
- package/dist/mobile/mobile.driver.d.ts.map +1 -0
- package/dist/mobile/mobile.driver.js +808 -0
- package/dist/mobile/mobile.driver.js.map +1 -0
- package/dist/types/common.types.d.ts +200 -0
- package/dist/types/common.types.d.ts.map +1 -0
- package/dist/types/common.types.js +3 -0
- package/dist/types/common.types.js.map +1 -0
- package/dist/types/config.types.d.ts +192 -0
- package/dist/types/config.types.d.ts.map +1 -0
- package/dist/types/config.types.js +3 -0
- package/dist/types/config.types.js.map +1 -0
- package/dist/types/driver.types.d.ts +500 -0
- package/dist/types/driver.types.d.ts.map +1 -0
- package/dist/types/driver.types.js +3 -0
- package/dist/types/driver.types.js.map +1 -0
- package/dist/types/enums.d.ts +53 -0
- package/dist/types/enums.d.ts.map +1 -0
- package/dist/types/enums.js +62 -0
- package/dist/types/enums.js.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +15 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/config.manager.d.ts +144 -0
- package/dist/utils/config.manager.d.ts.map +1 -0
- package/dist/utils/config.manager.js +473 -0
- package/dist/utils/config.manager.js.map +1 -0
- package/dist/utils/errors.d.ts +149 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +290 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/helpers.d.ts +124 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/dist/utils/helpers.js +421 -0
- package/dist/utils/helpers.js.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +78 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +145 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +235 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/wait.utils.d.ts +95 -0
- package/dist/utils/wait.utils.d.ts.map +1 -0
- package/dist/utils/wait.utils.js +306 -0
- package/dist/utils/wait.utils.js.map +1 -0
- package/dist/web/index.d.ts +8 -0
- package/dist/web/index.d.ts.map +1 -0
- package/dist/web/index.js +16 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/web.assertions.d.ts +164 -0
- package/dist/web/web.assertions.d.ts.map +1 -0
- package/dist/web/web.assertions.js +427 -0
- package/dist/web/web.assertions.js.map +1 -0
- package/dist/web/web.driver.d.ts +174 -0
- package/dist/web/web.driver.d.ts.map +1 -0
- package/dist/web/web.driver.js +571 -0
- package/dist/web/web.driver.js.map +1 -0
- package/dist/web/web.page.d.ts +286 -0
- package/dist/web/web.page.d.ts.map +1 -0
- package/dist/web/web.page.js +570 -0
- package/dist/web/web.page.js.map +1 -0
- package/package.json +115 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Playwright-Core Framework
|
|
4
|
+
*
|
|
5
|
+
* A unified automation framework supporting:
|
|
6
|
+
* - Web automation (Playwright)
|
|
7
|
+
* - API testing (Playwright Request)
|
|
8
|
+
* - Mobile automation (WebdriverIO + Appium)
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.camelToKebab = exports.escapeRegex = exports.truncate = exports.formatDuration = exports.formatBytes = exports.loadJson = exports.saveJson = exports.ensureDir = exports.formatTimestamp = exports.generateUUID = exports.generateId = exports.isObject = exports.deepClone = exports.deepMerge = exports.isErrorOfType = exports.isFrameworkError = exports.wrapError = exports.FileOperationError = exports.NetworkError = exports.AssertionError = exports.ContextError = exports.SessionError = exports.ScreenshotError = exports.ConfigurationError = exports.MobileOperationError = exports.ApiValidationError = exports.ApiRequestError = exports.NavigationError = exports.ElementNotInteractableError = exports.ElementNotFoundError = exports.DriverNotInitializedError = exports.DriverInitializationError = exports.FrameworkError = exports.getConfig = exports.ConfigManager = exports.retry = exports.waitFor = exports.sleep = exports.waitUtils = exports.RetryExhaustedError = exports.WaitTimeoutError = exports.WaitUtils = exports.getLogger = exports.Logger = exports.HttpMethod = exports.LogLevel = exports.AutomationEngine = exports.MobilePlatform = exports.BrowserType = exports.Platform = void 0;
|
|
14
|
+
exports.MobileAssertions = exports.AppState = exports.MobileDriver = exports.createRequest = exports.ApiRequestBuilder = exports.ApiAssertions = exports.ApiClient = exports.WebAssertions = exports.WebPage = exports.WebDriver = exports.getHookManager = exports.HookEvent = exports.HookManager = exports.ElementActions = exports.getDriverFactory = exports.DriverFactory = exports.BaseDriver = exports.setNestedValue = exports.getNestedValue = exports.flattenObject = exports.deepEqual = exports.omit = exports.pick = exports.objectToMap = exports.mapToObject = exports.measureTime = exports.throttle = exports.debounce = exports.safeJsonParse = exports.getOSPlatform = exports.isCI = exports.toTitleCase = exports.kebabToCamel = void 0;
|
|
15
|
+
// ============ Types ============
|
|
16
|
+
var types_1 = require("./types");
|
|
17
|
+
// Enums
|
|
18
|
+
Object.defineProperty(exports, "Platform", { enumerable: true, get: function () { return types_1.Platform; } });
|
|
19
|
+
Object.defineProperty(exports, "BrowserType", { enumerable: true, get: function () { return types_1.BrowserType; } });
|
|
20
|
+
Object.defineProperty(exports, "MobilePlatform", { enumerable: true, get: function () { return types_1.MobilePlatform; } });
|
|
21
|
+
Object.defineProperty(exports, "AutomationEngine", { enumerable: true, get: function () { return types_1.AutomationEngine; } });
|
|
22
|
+
Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return types_1.LogLevel; } });
|
|
23
|
+
Object.defineProperty(exports, "HttpMethod", { enumerable: true, get: function () { return types_1.HttpMethod; } });
|
|
24
|
+
// ============ Utilities ============
|
|
25
|
+
var utils_1 = require("./utils");
|
|
26
|
+
// Logger
|
|
27
|
+
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return utils_1.Logger; } });
|
|
28
|
+
Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return utils_1.getLogger; } });
|
|
29
|
+
// Wait utilities
|
|
30
|
+
Object.defineProperty(exports, "WaitUtils", { enumerable: true, get: function () { return utils_1.WaitUtils; } });
|
|
31
|
+
Object.defineProperty(exports, "WaitTimeoutError", { enumerable: true, get: function () { return utils_1.WaitTimeoutError; } });
|
|
32
|
+
Object.defineProperty(exports, "RetryExhaustedError", { enumerable: true, get: function () { return utils_1.RetryExhaustedError; } });
|
|
33
|
+
Object.defineProperty(exports, "waitUtils", { enumerable: true, get: function () { return utils_1.waitUtils; } });
|
|
34
|
+
Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { return utils_1.sleep; } });
|
|
35
|
+
Object.defineProperty(exports, "waitFor", { enumerable: true, get: function () { return utils_1.waitFor; } });
|
|
36
|
+
Object.defineProperty(exports, "retry", { enumerable: true, get: function () { return utils_1.retry; } });
|
|
37
|
+
// Config manager
|
|
38
|
+
Object.defineProperty(exports, "ConfigManager", { enumerable: true, get: function () { return utils_1.ConfigManager; } });
|
|
39
|
+
Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return utils_1.getConfig; } });
|
|
40
|
+
// Errors
|
|
41
|
+
Object.defineProperty(exports, "FrameworkError", { enumerable: true, get: function () { return utils_1.FrameworkError; } });
|
|
42
|
+
Object.defineProperty(exports, "DriverInitializationError", { enumerable: true, get: function () { return utils_1.DriverInitializationError; } });
|
|
43
|
+
Object.defineProperty(exports, "DriverNotInitializedError", { enumerable: true, get: function () { return utils_1.DriverNotInitializedError; } });
|
|
44
|
+
Object.defineProperty(exports, "ElementNotFoundError", { enumerable: true, get: function () { return utils_1.ElementNotFoundError; } });
|
|
45
|
+
Object.defineProperty(exports, "ElementNotInteractableError", { enumerable: true, get: function () { return utils_1.ElementNotInteractableError; } });
|
|
46
|
+
Object.defineProperty(exports, "NavigationError", { enumerable: true, get: function () { return utils_1.NavigationError; } });
|
|
47
|
+
Object.defineProperty(exports, "ApiRequestError", { enumerable: true, get: function () { return utils_1.ApiRequestError; } });
|
|
48
|
+
Object.defineProperty(exports, "ApiValidationError", { enumerable: true, get: function () { return utils_1.ApiValidationError; } });
|
|
49
|
+
Object.defineProperty(exports, "MobileOperationError", { enumerable: true, get: function () { return utils_1.MobileOperationError; } });
|
|
50
|
+
Object.defineProperty(exports, "ConfigurationError", { enumerable: true, get: function () { return utils_1.ConfigurationError; } });
|
|
51
|
+
Object.defineProperty(exports, "ScreenshotError", { enumerable: true, get: function () { return utils_1.ScreenshotError; } });
|
|
52
|
+
Object.defineProperty(exports, "SessionError", { enumerable: true, get: function () { return utils_1.SessionError; } });
|
|
53
|
+
Object.defineProperty(exports, "ContextError", { enumerable: true, get: function () { return utils_1.ContextError; } });
|
|
54
|
+
Object.defineProperty(exports, "AssertionError", { enumerable: true, get: function () { return utils_1.AssertionError; } });
|
|
55
|
+
Object.defineProperty(exports, "NetworkError", { enumerable: true, get: function () { return utils_1.NetworkError; } });
|
|
56
|
+
Object.defineProperty(exports, "FileOperationError", { enumerable: true, get: function () { return utils_1.FileOperationError; } });
|
|
57
|
+
Object.defineProperty(exports, "wrapError", { enumerable: true, get: function () { return utils_1.wrapError; } });
|
|
58
|
+
Object.defineProperty(exports, "isFrameworkError", { enumerable: true, get: function () { return utils_1.isFrameworkError; } });
|
|
59
|
+
Object.defineProperty(exports, "isErrorOfType", { enumerable: true, get: function () { return utils_1.isErrorOfType; } });
|
|
60
|
+
// Helper utilities
|
|
61
|
+
Object.defineProperty(exports, "deepMerge", { enumerable: true, get: function () { return utils_1.deepMerge; } });
|
|
62
|
+
Object.defineProperty(exports, "deepClone", { enumerable: true, get: function () { return utils_1.deepClone; } });
|
|
63
|
+
Object.defineProperty(exports, "isObject", { enumerable: true, get: function () { return utils_1.isObject; } });
|
|
64
|
+
Object.defineProperty(exports, "generateId", { enumerable: true, get: function () { return utils_1.generateId; } });
|
|
65
|
+
Object.defineProperty(exports, "generateUUID", { enumerable: true, get: function () { return utils_1.generateUUID; } });
|
|
66
|
+
Object.defineProperty(exports, "formatTimestamp", { enumerable: true, get: function () { return utils_1.formatTimestamp; } });
|
|
67
|
+
Object.defineProperty(exports, "ensureDir", { enumerable: true, get: function () { return utils_1.ensureDir; } });
|
|
68
|
+
Object.defineProperty(exports, "saveJson", { enumerable: true, get: function () { return utils_1.saveJson; } });
|
|
69
|
+
Object.defineProperty(exports, "loadJson", { enumerable: true, get: function () { return utils_1.loadJson; } });
|
|
70
|
+
Object.defineProperty(exports, "formatBytes", { enumerable: true, get: function () { return utils_1.formatBytes; } });
|
|
71
|
+
Object.defineProperty(exports, "formatDuration", { enumerable: true, get: function () { return utils_1.formatDuration; } });
|
|
72
|
+
Object.defineProperty(exports, "truncate", { enumerable: true, get: function () { return utils_1.truncate; } });
|
|
73
|
+
Object.defineProperty(exports, "escapeRegex", { enumerable: true, get: function () { return utils_1.escapeRegex; } });
|
|
74
|
+
Object.defineProperty(exports, "camelToKebab", { enumerable: true, get: function () { return utils_1.camelToKebab; } });
|
|
75
|
+
Object.defineProperty(exports, "kebabToCamel", { enumerable: true, get: function () { return utils_1.kebabToCamel; } });
|
|
76
|
+
Object.defineProperty(exports, "toTitleCase", { enumerable: true, get: function () { return utils_1.toTitleCase; } });
|
|
77
|
+
Object.defineProperty(exports, "isCI", { enumerable: true, get: function () { return utils_1.isCI; } });
|
|
78
|
+
Object.defineProperty(exports, "getOSPlatform", { enumerable: true, get: function () { return utils_1.getOSPlatform; } });
|
|
79
|
+
Object.defineProperty(exports, "safeJsonParse", { enumerable: true, get: function () { return utils_1.safeJsonParse; } });
|
|
80
|
+
Object.defineProperty(exports, "debounce", { enumerable: true, get: function () { return utils_1.debounce; } });
|
|
81
|
+
Object.defineProperty(exports, "throttle", { enumerable: true, get: function () { return utils_1.throttle; } });
|
|
82
|
+
Object.defineProperty(exports, "measureTime", { enumerable: true, get: function () { return utils_1.measureTime; } });
|
|
83
|
+
Object.defineProperty(exports, "mapToObject", { enumerable: true, get: function () { return utils_1.mapToObject; } });
|
|
84
|
+
Object.defineProperty(exports, "objectToMap", { enumerable: true, get: function () { return utils_1.objectToMap; } });
|
|
85
|
+
Object.defineProperty(exports, "pick", { enumerable: true, get: function () { return utils_1.pick; } });
|
|
86
|
+
Object.defineProperty(exports, "omit", { enumerable: true, get: function () { return utils_1.omit; } });
|
|
87
|
+
Object.defineProperty(exports, "deepEqual", { enumerable: true, get: function () { return utils_1.deepEqual; } });
|
|
88
|
+
Object.defineProperty(exports, "flattenObject", { enumerable: true, get: function () { return utils_1.flattenObject; } });
|
|
89
|
+
Object.defineProperty(exports, "getNestedValue", { enumerable: true, get: function () { return utils_1.getNestedValue; } });
|
|
90
|
+
Object.defineProperty(exports, "setNestedValue", { enumerable: true, get: function () { return utils_1.setNestedValue; } });
|
|
91
|
+
// ============ Core ============
|
|
92
|
+
var core_1 = require("./core");
|
|
93
|
+
// Base driver
|
|
94
|
+
Object.defineProperty(exports, "BaseDriver", { enumerable: true, get: function () { return core_1.BaseDriver; } });
|
|
95
|
+
// Driver factory
|
|
96
|
+
Object.defineProperty(exports, "DriverFactory", { enumerable: true, get: function () { return core_1.DriverFactory; } });
|
|
97
|
+
Object.defineProperty(exports, "getDriverFactory", { enumerable: true, get: function () { return core_1.getDriverFactory; } });
|
|
98
|
+
// Element actions
|
|
99
|
+
Object.defineProperty(exports, "ElementActions", { enumerable: true, get: function () { return core_1.ElementActions; } });
|
|
100
|
+
// Hook manager
|
|
101
|
+
Object.defineProperty(exports, "HookManager", { enumerable: true, get: function () { return core_1.HookManager; } });
|
|
102
|
+
Object.defineProperty(exports, "HookEvent", { enumerable: true, get: function () { return core_1.HookEvent; } });
|
|
103
|
+
Object.defineProperty(exports, "getHookManager", { enumerable: true, get: function () { return core_1.getHookManager; } });
|
|
104
|
+
// ============ Web Module ============
|
|
105
|
+
var web_1 = require("./web");
|
|
106
|
+
// Web driver
|
|
107
|
+
Object.defineProperty(exports, "WebDriver", { enumerable: true, get: function () { return web_1.WebDriver; } });
|
|
108
|
+
// Web page interactions
|
|
109
|
+
Object.defineProperty(exports, "WebPage", { enumerable: true, get: function () { return web_1.WebPage; } });
|
|
110
|
+
// Web assertions
|
|
111
|
+
Object.defineProperty(exports, "WebAssertions", { enumerable: true, get: function () { return web_1.WebAssertions; } });
|
|
112
|
+
// ============ API Module ============
|
|
113
|
+
var api_1 = require("./api");
|
|
114
|
+
// API client
|
|
115
|
+
Object.defineProperty(exports, "ApiClient", { enumerable: true, get: function () { return api_1.ApiClient; } });
|
|
116
|
+
// API assertions
|
|
117
|
+
Object.defineProperty(exports, "ApiAssertions", { enumerable: true, get: function () { return api_1.ApiAssertions; } });
|
|
118
|
+
// API request builder
|
|
119
|
+
Object.defineProperty(exports, "ApiRequestBuilder", { enumerable: true, get: function () { return api_1.ApiRequestBuilder; } });
|
|
120
|
+
Object.defineProperty(exports, "createRequest", { enumerable: true, get: function () { return api_1.createRequest; } });
|
|
121
|
+
// ============ Mobile Module ============
|
|
122
|
+
var mobile_1 = require("./mobile");
|
|
123
|
+
// Mobile driver
|
|
124
|
+
Object.defineProperty(exports, "MobileDriver", { enumerable: true, get: function () { return mobile_1.MobileDriver; } });
|
|
125
|
+
Object.defineProperty(exports, "AppState", { enumerable: true, get: function () { return mobile_1.AppState; } });
|
|
126
|
+
// Mobile assertions
|
|
127
|
+
Object.defineProperty(exports, "MobileAssertions", { enumerable: true, get: function () { return mobile_1.MobileAssertions; } });
|
|
128
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;AAEH,kCAAkC;AAClC,iCAgDiB;AA/Cf,QAAQ;AACR,iGAAA,QAAQ,OAAA;AACR,oGAAA,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@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mobile Module - WebdriverIO + Appium-based mobile automation
|
|
3
|
+
*/
|
|
4
|
+
export { MobileDriver, TouchPoint, GestureOptions, AppState, } from "./mobile.driver";
|
|
5
|
+
export { MobileAssertions, MobileSoftAssertionResult, } from "./mobile.assertions";
|
|
6
|
+
export type { Browser as WebdriverBrowser, Element as WebdriverElement, } from "webdriverio";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mobile/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EACL,YAAY,EACZ,UAAU,EACV,cAAc,EACd,QAAQ,GACT,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAG7B,YAAY,EACV,OAAO,IAAI,gBAAgB,EAC3B,OAAO,IAAI,gBAAgB,GAC5B,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Mobile Module - WebdriverIO + Appium-based mobile automation
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MobileAssertions = exports.AppState = exports.MobileDriver = void 0;
|
|
7
|
+
// Mobile Driver
|
|
8
|
+
var mobile_driver_1 = require("./mobile.driver");
|
|
9
|
+
Object.defineProperty(exports, "MobileDriver", { enumerable: true, get: function () { return mobile_driver_1.MobileDriver; } });
|
|
10
|
+
Object.defineProperty(exports, "AppState", { enumerable: true, get: function () { return mobile_driver_1.AppState; } });
|
|
11
|
+
// Mobile Assertions
|
|
12
|
+
var mobile_assertions_1 = require("./mobile.assertions");
|
|
13
|
+
Object.defineProperty(exports, "MobileAssertions", { enumerable: true, get: function () { return mobile_assertions_1.MobileAssertions; } });
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mobile/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,gBAAgB;AAChB,iDAKyB;AAJvB,6GAAA,YAAY,OAAA;AAGZ,yGAAA,QAAQ,OAAA;AAGV,oBAAoB;AACpB,yDAG6B;AAF3B,qHAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { AssertionOptions, Locator } from "../types";
|
|
2
|
+
import { Logger } from "../utils";
|
|
3
|
+
import { MobileDriver, AppState } from "./mobile.driver";
|
|
4
|
+
/**
|
|
5
|
+
* Soft assertion result
|
|
6
|
+
*/
|
|
7
|
+
export interface MobileSoftAssertionResult {
|
|
8
|
+
passed: boolean;
|
|
9
|
+
message: string;
|
|
10
|
+
expected?: unknown;
|
|
11
|
+
actual?: unknown;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Mobile Assertions class providing assertion methods for mobile testing.
|
|
15
|
+
*/
|
|
16
|
+
export declare class MobileAssertions {
|
|
17
|
+
private driver;
|
|
18
|
+
private logger;
|
|
19
|
+
private softErrors;
|
|
20
|
+
constructor(driver: MobileDriver, logger?: Logger);
|
|
21
|
+
/**
|
|
22
|
+
* Get soft assertion errors
|
|
23
|
+
*/
|
|
24
|
+
getSoftErrors(): MobileSoftAssertionResult[];
|
|
25
|
+
/**
|
|
26
|
+
* Clear soft assertion errors
|
|
27
|
+
*/
|
|
28
|
+
clearSoftErrors(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Check if all soft assertions passed
|
|
31
|
+
*/
|
|
32
|
+
allSoftAssertionsPassed(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Assert all soft assertions and throw if any failed
|
|
35
|
+
*/
|
|
36
|
+
assertAllSoftAssertions(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Handle assertion result
|
|
39
|
+
*/
|
|
40
|
+
private handleAssertion;
|
|
41
|
+
/**
|
|
42
|
+
* Assert element is displayed
|
|
43
|
+
*/
|
|
44
|
+
assertDisplayed(locator: Locator | string, options?: AssertionOptions): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Assert element is not displayed
|
|
47
|
+
*/
|
|
48
|
+
assertNotDisplayed(locator: Locator | string, options?: AssertionOptions): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Assert element exists
|
|
51
|
+
*/
|
|
52
|
+
assertExists(locator: Locator | string, options?: AssertionOptions): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Assert element is enabled
|
|
55
|
+
*/
|
|
56
|
+
assertEnabled(locator: Locator | string, options?: AssertionOptions): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Assert element is disabled
|
|
59
|
+
*/
|
|
60
|
+
assertDisabled(locator: Locator | string, options?: AssertionOptions): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Assert element has exact text
|
|
63
|
+
*/
|
|
64
|
+
assertText(locator: Locator | string, expectedText: string, options?: AssertionOptions): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Assert element contains text
|
|
67
|
+
*/
|
|
68
|
+
assertTextContains(locator: Locator | string, expectedText: string, options?: AssertionOptions): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Assert element text matches pattern
|
|
71
|
+
*/
|
|
72
|
+
assertTextMatches(locator: Locator | string, pattern: RegExp, options?: AssertionOptions): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Assert element has attribute with value
|
|
75
|
+
*/
|
|
76
|
+
assertAttribute(locator: Locator | string, attribute: string, expectedValue: string, options?: AssertionOptions): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Assert element attribute contains value
|
|
79
|
+
*/
|
|
80
|
+
assertAttributeContains(locator: Locator | string, attribute: string, expectedValue: string, options?: AssertionOptions): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Assert current context
|
|
83
|
+
*/
|
|
84
|
+
assertContext(expectedContext: string, options?: AssertionOptions): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Assert in native context
|
|
87
|
+
*/
|
|
88
|
+
assertNativeContext(options?: AssertionOptions): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Assert in webview context
|
|
91
|
+
*/
|
|
92
|
+
assertWebviewContext(options?: AssertionOptions): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Assert app is installed
|
|
95
|
+
*/
|
|
96
|
+
assertAppInstalled(appId: string, options?: AssertionOptions): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Assert app is not installed
|
|
99
|
+
*/
|
|
100
|
+
assertAppNotInstalled(appId: string, options?: AssertionOptions): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Assert app state
|
|
103
|
+
*/
|
|
104
|
+
assertAppState(expectedState: AppState, appId?: string, options?: AssertionOptions): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Assert app is running in foreground
|
|
107
|
+
*/
|
|
108
|
+
assertAppRunning(appId?: string, options?: AssertionOptions): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Assert device orientation
|
|
111
|
+
*/
|
|
112
|
+
assertOrientation(expectedOrientation: "PORTRAIT" | "LANDSCAPE", options?: AssertionOptions): Promise<void>;
|
|
113
|
+
/**
|
|
114
|
+
* Assert device is locked
|
|
115
|
+
*/
|
|
116
|
+
assertLocked(options?: AssertionOptions): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Assert device is unlocked
|
|
119
|
+
*/
|
|
120
|
+
assertUnlocked(options?: AssertionOptions): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Assert keyboard is shown
|
|
123
|
+
*/
|
|
124
|
+
assertKeyboardShown(options?: AssertionOptions): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Assert keyboard is hidden
|
|
127
|
+
*/
|
|
128
|
+
assertKeyboardHidden(options?: AssertionOptions): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Assert condition is true
|
|
131
|
+
*/
|
|
132
|
+
assertTrue(condition: boolean, message: string, options?: AssertionOptions): void;
|
|
133
|
+
/**
|
|
134
|
+
* Assert condition is false
|
|
135
|
+
*/
|
|
136
|
+
assertFalse(condition: boolean, message: string, options?: AssertionOptions): void;
|
|
137
|
+
/**
|
|
138
|
+
* Assert values are equal
|
|
139
|
+
*/
|
|
140
|
+
assertEqual<T>(actual: T, expected: T, message?: string, options?: AssertionOptions): void;
|
|
141
|
+
/**
|
|
142
|
+
* Always fail with message
|
|
143
|
+
*/
|
|
144
|
+
fail(message: string, options?: AssertionOptions): void;
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=mobile.assertions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mobile.assertions.d.ts","sourceRoot":"","sources":["../../src/mobile/mobile.assertions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,MAAM,EAAkB,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAWzD;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,UAAU,CAAmC;gBAEzC,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,MAAM;IAKjD;;OAEG;IACI,aAAa,IAAI,yBAAyB,EAAE;IAInD;;OAEG;IACI,eAAe,IAAI,IAAI;IAI9B;;OAEG;IACI,uBAAuB,IAAI,OAAO;IAIzC;;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G,OAAO,CAAC,IAAI,CAAC;IAc1E;;OAEG;IACU,mBAAmB,CAC9B,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAchB;;OAEG;IACU,oBAAoB,CAC/B,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAgBhB;;OAEG;IACI,UAAU,CACf,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,gBAAqB,GAC7B,IAAI;IAKP;;OAEG;IACI,WAAW,CAChB,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,gBAAqB,GAC7B,IAAI;IAKP;;OAEG;IACI,WAAW,CAAC,CAAC,EAClB,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,CAAC,EACX,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,GAAE,gBAAqB,GAC7B,IAAI;IASP;;OAEG;IACI,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,IAAI;CAInE"}
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MobileAssertions = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const mobile_driver_1 = require("./mobile.driver");
|
|
6
|
+
/**
|
|
7
|
+
* Default assertion options
|
|
8
|
+
*/
|
|
9
|
+
const DEFAULT_ASSERTION_OPTIONS = {
|
|
10
|
+
timeout: 10000,
|
|
11
|
+
message: "",
|
|
12
|
+
soft: false,
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Mobile Assertions class providing assertion methods for mobile testing.
|
|
16
|
+
*/
|
|
17
|
+
class MobileAssertions {
|
|
18
|
+
driver;
|
|
19
|
+
logger;
|
|
20
|
+
softErrors = [];
|
|
21
|
+
constructor(driver, logger) {
|
|
22
|
+
this.driver = driver;
|
|
23
|
+
this.logger = logger || utils_1.Logger.getInstance();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get soft assertion errors
|
|
27
|
+
*/
|
|
28
|
+
getSoftErrors() {
|
|
29
|
+
return [...this.softErrors];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Clear soft assertion errors
|
|
33
|
+
*/
|
|
34
|
+
clearSoftErrors() {
|
|
35
|
+
this.softErrors = [];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Check if all soft assertions passed
|
|
39
|
+
*/
|
|
40
|
+
allSoftAssertionsPassed() {
|
|
41
|
+
return this.softErrors.length === 0;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Assert all soft assertions and throw if any failed
|
|
45
|
+
*/
|
|
46
|
+
assertAllSoftAssertions() {
|
|
47
|
+
if (this.softErrors.length > 0) {
|
|
48
|
+
const messages = this.softErrors
|
|
49
|
+
.map((e, i) => `${i + 1}. ${e.message}`)
|
|
50
|
+
.join("\n");
|
|
51
|
+
const errorCount = this.softErrors.length;
|
|
52
|
+
this.softErrors = [];
|
|
53
|
+
throw new utils_1.AssertionError(`${errorCount} soft assertion(s) failed:\n${messages}`, "all passed", "some failed");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Handle assertion result
|
|
58
|
+
*/
|
|
59
|
+
handleAssertion(passed, message, expected, actual, options) {
|
|
60
|
+
if (passed) {
|
|
61
|
+
this.logger.debug(`✓ Mobile Assertion passed: ${message}`);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const errorMessage = options.message || message;
|
|
65
|
+
const result = {
|
|
66
|
+
passed: false,
|
|
67
|
+
message: errorMessage,
|
|
68
|
+
expected,
|
|
69
|
+
actual,
|
|
70
|
+
};
|
|
71
|
+
if (options.soft) {
|
|
72
|
+
this.logger.warn(`✗ Soft mobile assertion failed: ${errorMessage}`);
|
|
73
|
+
this.softErrors.push(result);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
this.logger.error(`✗ Mobile Assertion failed: ${errorMessage}`);
|
|
77
|
+
throw new utils_1.AssertionError(errorMessage, expected, actual);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// ============ Element Visibility Assertions ============
|
|
81
|
+
/**
|
|
82
|
+
* Assert element is displayed
|
|
83
|
+
*/
|
|
84
|
+
async assertDisplayed(locator, options = {}) {
|
|
85
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
86
|
+
const description = typeof locator === "string" ? locator : locator.value;
|
|
87
|
+
try {
|
|
88
|
+
await this.driver.waitForDisplayed(locator, opts.timeout);
|
|
89
|
+
this.handleAssertion(true, `Element is displayed: ${description}`, "displayed", "displayed", opts);
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
this.handleAssertion(false, `Element should be displayed: ${description}`, "displayed", "not displayed", opts);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Assert element is not displayed
|
|
97
|
+
*/
|
|
98
|
+
async assertNotDisplayed(locator, options = {}) {
|
|
99
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
100
|
+
const description = typeof locator === "string" ? locator : locator.value;
|
|
101
|
+
try {
|
|
102
|
+
await this.driver.waitForNotDisplayed(locator, opts.timeout);
|
|
103
|
+
this.handleAssertion(true, `Element is not displayed: ${description}`, "not displayed", "not displayed", opts);
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
this.handleAssertion(false, `Element should not be displayed: ${description}`, "not displayed", "displayed", opts);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Assert element exists
|
|
111
|
+
*/
|
|
112
|
+
async assertExists(locator, options = {}) {
|
|
113
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
114
|
+
const description = typeof locator === "string" ? locator : locator.value;
|
|
115
|
+
try {
|
|
116
|
+
await this.driver.findElement(locator);
|
|
117
|
+
this.handleAssertion(true, `Element exists: ${description}`, "exists", "exists", opts);
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
this.handleAssertion(false, `Element should exist: ${description}`, "exists", "not found", opts);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Assert element is enabled
|
|
125
|
+
*/
|
|
126
|
+
async assertEnabled(locator, options = {}) {
|
|
127
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
128
|
+
const description = typeof locator === "string" ? locator : locator.value;
|
|
129
|
+
const isEnabled = await this.driver.isEnabled(locator);
|
|
130
|
+
this.handleAssertion(isEnabled, `Element should be enabled: ${description}`, "enabled", "disabled", opts);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Assert element is disabled
|
|
134
|
+
*/
|
|
135
|
+
async assertDisabled(locator, options = {}) {
|
|
136
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
137
|
+
const description = typeof locator === "string" ? locator : locator.value;
|
|
138
|
+
const isEnabled = await this.driver.isEnabled(locator);
|
|
139
|
+
this.handleAssertion(!isEnabled, `Element should be disabled: ${description}`, "disabled", "enabled", opts);
|
|
140
|
+
}
|
|
141
|
+
// ============ Text Assertions ============
|
|
142
|
+
/**
|
|
143
|
+
* Assert element has exact text
|
|
144
|
+
*/
|
|
145
|
+
async assertText(locator, expectedText, options = {}) {
|
|
146
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
147
|
+
const description = typeof locator === "string" ? locator : locator.value;
|
|
148
|
+
const actualText = await this.driver.getText(locator);
|
|
149
|
+
const passed = actualText === expectedText;
|
|
150
|
+
this.handleAssertion(passed, `Element text should be "${expectedText}", got "${actualText}": ${description}`, expectedText, actualText, opts);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Assert element contains text
|
|
154
|
+
*/
|
|
155
|
+
async assertTextContains(locator, expectedText, options = {}) {
|
|
156
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
157
|
+
const description = typeof locator === "string" ? locator : locator.value;
|
|
158
|
+
const actualText = await this.driver.getText(locator);
|
|
159
|
+
const passed = actualText.includes(expectedText);
|
|
160
|
+
this.handleAssertion(passed, `Element text should contain "${expectedText}", got "${actualText}": ${description}`, `contains "${expectedText}"`, actualText, opts);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Assert element text matches pattern
|
|
164
|
+
*/
|
|
165
|
+
async assertTextMatches(locator, pattern, options = {}) {
|
|
166
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
167
|
+
const description = typeof locator === "string" ? locator : locator.value;
|
|
168
|
+
const actualText = await this.driver.getText(locator);
|
|
169
|
+
const passed = pattern.test(actualText);
|
|
170
|
+
this.handleAssertion(passed, `Element text should match ${pattern}, got "${actualText}": ${description}`, pattern.toString(), actualText, opts);
|
|
171
|
+
}
|
|
172
|
+
// ============ Attribute Assertions ============
|
|
173
|
+
/**
|
|
174
|
+
* Assert element has attribute with value
|
|
175
|
+
*/
|
|
176
|
+
async assertAttribute(locator, attribute, expectedValue, options = {}) {
|
|
177
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
178
|
+
const description = typeof locator === "string" ? locator : locator.value;
|
|
179
|
+
const actualValue = await this.driver.getAttribute(locator, attribute);
|
|
180
|
+
const passed = actualValue === expectedValue;
|
|
181
|
+
this.handleAssertion(passed, `Attribute ${attribute} should be "${expectedValue}", got "${actualValue}": ${description}`, expectedValue, actualValue, opts);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Assert element attribute contains value
|
|
185
|
+
*/
|
|
186
|
+
async assertAttributeContains(locator, attribute, expectedValue, options = {}) {
|
|
187
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
188
|
+
const description = typeof locator === "string" ? locator : locator.value;
|
|
189
|
+
const actualValue = await this.driver.getAttribute(locator, attribute);
|
|
190
|
+
const passed = actualValue?.includes(expectedValue) ?? false;
|
|
191
|
+
this.handleAssertion(passed, `Attribute ${attribute} should contain "${expectedValue}", got "${actualValue}": ${description}`, `contains "${expectedValue}"`, actualValue, opts);
|
|
192
|
+
}
|
|
193
|
+
// ============ Context Assertions ============
|
|
194
|
+
/**
|
|
195
|
+
* Assert current context
|
|
196
|
+
*/
|
|
197
|
+
async assertContext(expectedContext, options = {}) {
|
|
198
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
199
|
+
const actualContext = await this.driver.getContext();
|
|
200
|
+
const passed = actualContext === expectedContext;
|
|
201
|
+
this.handleAssertion(passed, `Context should be "${expectedContext}", got "${actualContext}"`, expectedContext, actualContext, opts);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Assert in native context
|
|
205
|
+
*/
|
|
206
|
+
async assertNativeContext(options = {}) {
|
|
207
|
+
await this.assertContext("NATIVE_APP", options);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Assert in webview context
|
|
211
|
+
*/
|
|
212
|
+
async assertWebviewContext(options = {}) {
|
|
213
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
214
|
+
const actualContext = await this.driver.getContext();
|
|
215
|
+
const passed = actualContext.includes("WEBVIEW");
|
|
216
|
+
this.handleAssertion(passed, `Should be in webview context, got "${actualContext}"`, "WEBVIEW_*", actualContext, opts);
|
|
217
|
+
}
|
|
218
|
+
// ============ App State Assertions ============
|
|
219
|
+
/**
|
|
220
|
+
* Assert app is installed
|
|
221
|
+
*/
|
|
222
|
+
async assertAppInstalled(appId, options = {}) {
|
|
223
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
224
|
+
const isInstalled = await this.driver.isAppInstalled(appId);
|
|
225
|
+
this.handleAssertion(isInstalled, `App should be installed: ${appId}`, "installed", "not installed", opts);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Assert app is not installed
|
|
229
|
+
*/
|
|
230
|
+
async assertAppNotInstalled(appId, options = {}) {
|
|
231
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
232
|
+
const isInstalled = await this.driver.isAppInstalled(appId);
|
|
233
|
+
this.handleAssertion(!isInstalled, `App should not be installed: ${appId}`, "not installed", "installed", opts);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Assert app state
|
|
237
|
+
*/
|
|
238
|
+
async assertAppState(expectedState, appId, options = {}) {
|
|
239
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
240
|
+
const actualState = await this.driver.getAppState(appId);
|
|
241
|
+
const passed = actualState === expectedState;
|
|
242
|
+
const stateNames = {
|
|
243
|
+
[mobile_driver_1.AppState.NOT_INSTALLED]: "NOT_INSTALLED",
|
|
244
|
+
[mobile_driver_1.AppState.NOT_RUNNING]: "NOT_RUNNING",
|
|
245
|
+
[mobile_driver_1.AppState.RUNNING_BACKGROUND_SUSPENDED]: "RUNNING_BACKGROUND_SUSPENDED",
|
|
246
|
+
[mobile_driver_1.AppState.RUNNING_BACKGROUND]: "RUNNING_BACKGROUND",
|
|
247
|
+
[mobile_driver_1.AppState.RUNNING_FOREGROUND]: "RUNNING_FOREGROUND",
|
|
248
|
+
};
|
|
249
|
+
this.handleAssertion(passed, `App state should be ${stateNames[expectedState]}, got ${stateNames[actualState]}`, stateNames[expectedState], stateNames[actualState], opts);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Assert app is running in foreground
|
|
253
|
+
*/
|
|
254
|
+
async assertAppRunning(appId, options = {}) {
|
|
255
|
+
await this.assertAppState(mobile_driver_1.AppState.RUNNING_FOREGROUND, appId, options);
|
|
256
|
+
}
|
|
257
|
+
// ============ Device State Assertions ============
|
|
258
|
+
/**
|
|
259
|
+
* Assert device orientation
|
|
260
|
+
*/
|
|
261
|
+
async assertOrientation(expectedOrientation, options = {}) {
|
|
262
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
263
|
+
const actualOrientation = await this.driver.getOrientation();
|
|
264
|
+
const passed = actualOrientation.toUpperCase() === expectedOrientation;
|
|
265
|
+
this.handleAssertion(passed, `Orientation should be ${expectedOrientation}, got ${actualOrientation}`, expectedOrientation, actualOrientation, opts);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Assert device is locked
|
|
269
|
+
*/
|
|
270
|
+
async assertLocked(options = {}) {
|
|
271
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
272
|
+
const isLocked = await this.driver.isLocked();
|
|
273
|
+
this.handleAssertion(isLocked, "Device should be locked", "locked", "unlocked", opts);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Assert device is unlocked
|
|
277
|
+
*/
|
|
278
|
+
async assertUnlocked(options = {}) {
|
|
279
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
280
|
+
const isLocked = await this.driver.isLocked();
|
|
281
|
+
this.handleAssertion(!isLocked, "Device should be unlocked", "unlocked", "locked", opts);
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Assert keyboard is shown
|
|
285
|
+
*/
|
|
286
|
+
async assertKeyboardShown(options = {}) {
|
|
287
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
288
|
+
const isShown = await this.driver.isKeyboardShown();
|
|
289
|
+
this.handleAssertion(isShown, "Keyboard should be shown", "shown", "hidden", opts);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Assert keyboard is hidden
|
|
293
|
+
*/
|
|
294
|
+
async assertKeyboardHidden(options = {}) {
|
|
295
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
296
|
+
const isShown = await this.driver.isKeyboardShown();
|
|
297
|
+
this.handleAssertion(!isShown, "Keyboard should be hidden", "hidden", "shown", opts);
|
|
298
|
+
}
|
|
299
|
+
// ============ Generic Assertions ============
|
|
300
|
+
/**
|
|
301
|
+
* Assert condition is true
|
|
302
|
+
*/
|
|
303
|
+
assertTrue(condition, message, options = {}) {
|
|
304
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
305
|
+
this.handleAssertion(condition, message, true, condition, opts);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Assert condition is false
|
|
309
|
+
*/
|
|
310
|
+
assertFalse(condition, message, options = {}) {
|
|
311
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
312
|
+
this.handleAssertion(!condition, message, false, condition, opts);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Assert values are equal
|
|
316
|
+
*/
|
|
317
|
+
assertEqual(actual, expected, message, options = {}) {
|
|
318
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
319
|
+
const passed = JSON.stringify(actual) === JSON.stringify(expected);
|
|
320
|
+
const msg = message ||
|
|
321
|
+
`Expected ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`;
|
|
322
|
+
this.handleAssertion(passed, msg, expected, actual, opts);
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Always fail with message
|
|
326
|
+
*/
|
|
327
|
+
fail(message, options = {}) {
|
|
328
|
+
const opts = { ...DEFAULT_ASSERTION_OPTIONS, ...options };
|
|
329
|
+
this.handleAssertion(false, message, "pass", "fail", opts);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
exports.MobileAssertions = MobileAssertions;
|
|
333
|
+
//# sourceMappingURL=mobile.assertions.js.map
|