appium-xcuitest-driver
Version:
Appium driver for iOS using XCUITest for backend
49 lines • 2.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.mobileStartNetworkMonitor = mobileStartNetworkMonitor;
exports.mobileStopNetworkMonitor = mobileStopNetworkMonitor;
const driver_1 = require("appium/driver");
const network_monitor_session_1 = require("../device/network-monitor-session");
const utils_1 = require("../utils");
/**
* Starts streaming DVT NetworkMonitor events to WebDriver BiDi subscribers (`appium:xcuitest.networkMonitor`).
*
* Requires a real device on iOS/tvOS 18+ and appium-ios-remotexpc.
*
* @see https://github.com/appium/appium-ios-remotexpc
*
* If a monitor is already running, this is a no-op so the session keeps streaming.
*/
async function mobileStartNetworkMonitor() {
(0, utils_1.requireRealDevice)(this, 'DVT network monitor');
if (!(0, utils_1.isIos18OrNewer)(this.opts)) {
throw new driver_1.errors.InvalidArgumentError(`mobile: startNetworkMonitor requires iOS/tvOS 18 or newer. ` +
`The current platformVersion is '${this.opts.platformVersion ?? 'unknown'}'.`);
}
if (this._networkMonitorSession?.isRunning()) {
this.log.info(`DVT network monitor is already active; continuing`);
return;
}
if (this._networkMonitorSession) {
this._networkMonitorSession = null;
}
const session = new network_monitor_session_1.NetworkMonitorSession(this.log, this.device.udid);
try {
await session.start(this.eventEmitter);
}
catch (e) {
await session.interrupt();
throw e;
}
this._networkMonitorSession = session;
}
/** Stops DVT NetworkMonitor streaming started with `mobile: startNetworkMonitor`. */
async function mobileStopNetworkMonitor() {
if (!this._networkMonitorSession) {
this.log.info('Network monitor has not been started; nothing to stop');
return;
}
await this._networkMonitorSession.interrupt();
this._networkMonitorSession = null;
}
//# sourceMappingURL=network-monitor.js.map