appium-xcuitest-driver
Version:
Appium driver for iOS using XCUITest for backend
48 lines • 2.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.setClipboard = setClipboard;
exports.getClipboard = getClipboard;
const pasteboard_client_1 = require("../device/pasteboard-client");
const helpers_1 = require("./helpers");
/**
* Sets the primary clipboard's content on the device under test.
*
* @param content - The content to be set as base64 encoded string.
* @param contentType - The type of the content to set.
* Only `plaintext`, 'image' and 'url' are supported.
* @param mode - The mode to use. If set to 'xpc', the clipboard content will be set using
* the RemoteXPC Pasteboard service.
*/
async function setClipboard(content, contentType, mode) {
if (mode === 'xpc') {
(0, helpers_1.requireRealDevice)(this, 'Setting clipboard content');
const pasteboardClient = new pasteboard_client_1.PasteboardClient(this.device.udid, this.remoteXPCFacade);
await pasteboardClient.setPasteboard(content, contentType);
return;
}
await this.proxyCommand('/wda/setPasteboard', 'POST', {
content,
contentType,
});
}
/**
* Gets the content of the primary clipboard on the device under test.
*
* @param contentType - The type of the content to get.
* Only `plaintext`, 'image' and 'url' are supported.
* @param mode - The mode to use. If set to 'xpc', the clipboard content will be retrieved using the
* RemoteXPC Pasteboard service.
* @returns The actual clipboard content encoded into base64 string.
* An empty string is returned if the clipboard contains no data.
*/
async function getClipboard(contentType, mode) {
if (mode === 'xpc') {
(0, helpers_1.requireRealDevice)(this, 'Getting clipboard content');
const pasteboardClient = new pasteboard_client_1.PasteboardClient(this.device.udid, this.remoteXPCFacade);
return (await pasteboardClient.getPasteboard(contentType)) ?? '';
}
return await this.proxyCommand('/wda/getPasteboard', 'POST', {
contentType,
});
}
//# sourceMappingURL=clipboard.js.map