appium-remote-debugger
Version:
Appium proxy for Remote Debugger protocol
52 lines • 1.95 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCookies = getCookies;
exports.setCookie = setCookie;
exports.deleteCookie = deleteCookie;
const property_accessors_1 = require("./property-accessors");
/**
* Retrieves all cookies for the current page by sending a Page.getCookies
* command to the remote debugger.
*
* @returns A promise that resolves to a dictionary containing the cookies.
*/
async function getCookies() {
this.log.debug('Getting cookies');
return await this.requireRpcClient().send('Page.getCookies', {
appIdKey: (0, property_accessors_1.getAppIdKey)(this),
pageIdKey: (0, property_accessors_1.getPageIdKey)(this),
});
}
/**
* Sets a cookie on the current page by sending a Page.setCookie command
* to the remote debugger.
*
* @param cookie - Dictionary containing the cookie properties to set.
* @returns A promise that resolves when the cookie has been set.
*/
async function setCookie(cookie) {
this.log.debug('Setting cookie');
return await this.requireRpcClient().send('Page.setCookie', {
appIdKey: (0, property_accessors_1.getAppIdKey)(this),
pageIdKey: (0, property_accessors_1.getPageIdKey)(this),
cookie,
});
}
/**
* Deletes a cookie from the current page by sending a Page.deleteCookie
* command to the remote debugger.
*
* @param cookieName - The name of the cookie to delete.
* @param url - The URL associated with the cookie to delete.
* @returns A promise that resolves when the cookie has been deleted.
*/
async function deleteCookie(cookieName, url) {
this.log.debug(`Deleting cookie '${cookieName}' on '${url}'`);
return await this.requireRpcClient().send('Page.deleteCookie', {
appIdKey: (0, property_accessors_1.getAppIdKey)(this),
pageIdKey: (0, property_accessors_1.getPageIdKey)(this),
cookieName,
url,
});
}
//# sourceMappingURL=cookies.js.map