MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / deleteCookies

Method deleteCookies

javascript/selenium-webdriver/bidi/storage.js:158–190  ·  view source on GitHub ↗

* Deletes cookies based on the provided filter and partition. * * @param {CookieFilter} [cookieFilter] - The filter to apply to the cookies. Must be an instance of CookieFilter. * @param {(BrowsingContextPartitionDescriptor|StorageKeyPartitionDescriptor)} [partition] - The partition to dele

(cookieFilter = undefined, partition = undefined)

Source from the content-addressed store, hash-verified

156 * @throws {Error} - If the provided parameters are not of the correct type.
157 */
158 async deleteCookies(cookieFilter = undefined, partition = undefined) {
159 if (cookieFilter !== undefined && !(cookieFilter instanceof CookieFilter)) {
160 throw new Error(`Params must be an instance of CookieFilter. Received:'${cookieFilter}'`)
161 }
162
163 if (
164 partition !== undefined &&
165 !(partition instanceof BrowsingContextPartitionDescriptor || partition instanceof StorageKeyPartitionDescriptor)
166 ) {
167 throw new Error(
168 `Params must be an instance of BrowsingContextPartitionDescriptor or StorageKeyPartitionDescriptor. Received:'${partition}'`,
169 )
170 }
171
172 const command = {
173 method: 'storage.deleteCookies',
174 params: {
175 filter: cookieFilter ? Object.fromEntries(cookieFilter.asMap()) : undefined,
176 partition: partition ? Object.fromEntries(partition.asMap()) : undefined,
177 },
178 }
179
180 let response = await this.bidi.send(command)
181
182 if (Object.prototype.hasOwnProperty.call(response.result, 'partitionKey')) {
183 if (
184 Object.prototype.hasOwnProperty.call(response.result.partitionKey, 'userContext') &&
185 Object.prototype.hasOwnProperty.call(response.result.partitionKey, 'sourceOrigin')
186 ) {
187 return new PartitionKey(response.result.partitionKey.userContext, response.result.partitionKey.sourceOrigin)
188 }
189 }
190 }
191}
192
193async function getStorageInstance(driver) {

Callers 2

storage_test.jsFile · 0.45
storage_test.jsFile · 0.45

Calls 3

asMapMethod · 0.65
sendMethod · 0.65
callMethod · 0.65

Tested by

no test coverage detected