UNPKG

appium-uiautomator2-driver

Version:
65 lines 2.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getPageSource = getPageSource; exports.getOrientation = getOrientation; exports.setOrientation = setOrientation; exports.openNotifications = openNotifications; exports.suspendChromedriverProxy = suspendChromedriverProxy; exports.mobileGetDeviceInfo = mobileGetDeviceInfo; exports.mobileResetAccessibilityCache = mobileResetAccessibilityCache; /** * Retrieves the current page source. * @returns The XML page source of the current screen. */ async function getPageSource() { return String(await this.uiautomator2.jwproxy.command('/source', 'GET', {})); } /** * Gets the current device orientation. * @returns The current device orientation ('LANDSCAPE' or 'PORTRAIT'). */ async function getOrientation() { return (await this.uiautomator2.jwproxy.command(`/orientation`, 'GET', {})); } /** * Sets the device orientation. * @param orientation - The desired orientation ('LANDSCAPE' or 'PORTRAIT'). */ async function setOrientation(orientation) { const normalizedOrientation = orientation.toUpperCase(); await this.uiautomator2.jwproxy.command(`/orientation`, 'POST', { orientation: normalizedOrientation, }); } /** * Opens the device notification shade. */ async function openNotifications() { await this.uiautomator2.jwproxy.command('/appium/device/open_notifications', 'POST', {}); } /** * Stops proxying to Chromedriver and restores UIA2 proxy. */ function suspendChromedriverProxy() { if (!this.uiautomator2?.proxyReqRes || !this.uiautomator2?.proxyCommand) { return; } this.chromedriver = undefined; this.proxyReqRes = this.uiautomator2.proxyReqRes.bind(this.uiautomator2); this.proxyCommand = this.uiautomator2.proxyCommand.bind(this.uiautomator2); this.jwpProxyActive = true; } /** * Retrieves device info via the UIA2 server. * @returns Device information as a string record. */ async function mobileGetDeviceInfo() { return (await this.uiautomator2.jwproxy.command('/appium/device/info', 'GET')); } /** * Resets the accessibility cache on the device. */ async function mobileResetAccessibilityCache() { await this.uiautomator2.jwproxy.command('/appium/reset_ax_cache', 'POST', {}); } //# sourceMappingURL=misc.js.map