UNPKG

appium-xcuitest-driver

Version:

Appium driver for iOS using XCUITest for backend

59 lines 2.79 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.mobilePushNotification = mobilePushNotification; exports.mobileExpectNotification = mobileExpectNotification; const driver_1 = require("appium/driver"); const lodash_1 = __importDefault(require("lodash")); const utils_1 = require("../utils"); /** * Simulates push notification delivery to a simulated device. * * **Only "remote" push notifications are supported.** VoIP, Complication, File Provider, and other types are unsupported. * * Supported in Xcode SDK 11.4+. * * @param bundleId - The bundle identifier of the target application * @param payload - Valid push payload. * @group Simulator Only */ async function mobilePushNotification(bundleId, payload) { const simulator = (0, utils_1.requireSimulator)(this, 'Push notification'); if (!bundleId) { throw new driver_1.errors.InvalidArgumentError(`'bundleId' argument must be a valid bundle identifier string`); } if (!lodash_1.default.isPlainObject(payload)) { throw new driver_1.errors.InvalidArgumentError(`The 'payload' argument value must be a valid dictionary. ` + `Got ${JSON.stringify(payload)} instead`); } if (!lodash_1.default.isPlainObject(payload.aps)) { throw new driver_1.errors.InvalidArgumentError(`The 'payload.aps' value must be a valid dictionary. ` + `Got ${JSON.stringify(payload.aps)} instead`); } await simulator.pushNotification({ ...payload, 'Simulator Target Bundle': bundleId, }); } /** * Blocks until the expected notification is delivered. * * This method is a thin wrapper over the * [`XCTNSNotificationExpectation`](https://developer.apple.com/documentation/xctest/xctnsnotificationexpectation?language=objc) and * [`XCTDarwinNotificationExpectation`](https://developer.apple.com/documentation/xctest/xctdarwinnotificationexpectation?language=objc) entities. * * @param name - The name of the notification to expect * @param type - Which notification type to expect. * @param timeoutSeconds - For how long to wait until the notification is delivered (in float seconds). * @throws A [`TimeoutError`](https://www.selenium.dev/selenium/docs/api/javascript/module/selenium-webdriver/lib/error_exports_TimeoutError.html) if the expected notification has not been delivered within the given timeout. */ async function mobileExpectNotification(name, type = 'plain', timeoutSeconds = 60) { await this.proxyCommand('/wda/expectNotification', 'POST', { name, type, timeout: timeoutSeconds, }); } //# sourceMappingURL=notifications.js.map