appium-uiautomator2-driver
Version:
UiAutomator2 integration for Appium
56 lines • 1.92 kB
JavaScript
/**
* Retrieves the current page source.
* @returns The XML page source of the current screen.
*/
export 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').
*/
export async function getOrientation() {
return (await this.uiautomator2.jwproxy.command(`/orientation`, 'GET', {}));
}
/**
* Sets the device orientation.
* @param orientation - The desired orientation ('LANDSCAPE' or 'PORTRAIT').
*/
export async function setOrientation(orientation) {
const normalizedOrientation = orientation.toUpperCase();
await this.uiautomator2.jwproxy.command(`/orientation`, 'POST', {
orientation: normalizedOrientation,
});
}
/**
* Opens the device notification shade.
*/
export async function openNotifications() {
await this.uiautomator2.jwproxy.command('/appium/device/open_notifications', 'POST', {});
}
/**
* Stops proxying to Chromedriver and restores UIA2 proxy.
*/
export 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.
*/
export async function mobileGetDeviceInfo() {
return (await this.uiautomator2.jwproxy.command('/appium/device/info', 'GET'));
}
/**
* Resets the accessibility cache on the device.
*/
export async function mobileResetAccessibilityCache() {
await this.uiautomator2.jwproxy.command('/appium/reset_ax_cache', 'POST', {});
}
//# sourceMappingURL=misc.js.map