PageSourceSearch

https://webdriver.io/assets/js/ba649b2a.1efadcd2.js

js webdriver.io collected 2026-09-24 08:32:24 UTC 4,728 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[1172],{22002:(e,t,i)=>{i.d(t,{R:()=>n,x:()=>a});var o=i(7378);const s={},r=o.createContext(s);function n(e){const t=o.useContext(r);return o.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:n(e.components),o.createElement(r.Provider,{value:t},e.children)}},54516:(e,t,i)=>{i.r(t),i.d(t,{assets:()=>c,contentTitle:()=>a,default:()=>u,frontMatter:()=>n,metadata:()=>o,toc:()=>l});const o=JSON.parse('{"id":"api/browser/getCookies","title":"getCookies","description":"Retrieve a cookie","source":"@site/docs/api/browser/_getCookies.md","sourceDirName":"api/browser","slug":"/api/browser/getCookies","permalink":"/docs/api/browser/getCookies","draft":false,"unlisted":false,"editUrl":"https://github.com/webdriverio/webdriverio/edit/main/packages/webdriverio/src/commands/browser/getCookies.ts","tags":[],"version":"current","frontMatter":{"id":"getCookies","title":"getCookies","custom_edit_url":"https://github.com/webdriverio/webdriverio/edit/main/packages/webdriverio/src/commands/browser/getCookies.ts"},"sidebar":"api","previous":{"title":"executeAsync","permalink":"/docs/api/browser/executeAsync"},"next":{"title":"getPuppeteer","permalink":"/docs/api/browser/getPuppeteer"}}');var s=i(86106),r=i(22002);const n={id:"getCookies",title:"getCookies",custom_edit_url:"https://github.com/webdriverio/webdriverio/edit/main/packages/webdriverio/src/commands/browser/getCookies.ts"},a=void 0,c={},l=[{value:"Usage",id:"usage",level:2},{value:"Parameters",id:"parameters",level:2},{value:"Example",id:"example",level:2},{value:"Returns",id:"returns",level:2}];function d(e){const t={a:"a",code:"code",h2:"h2",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(t.p,{children:["Retrieve a ",(0,s.jsx)(t.a,{href:"https://w3c.github.io/webdriver/webdriver-spec.html#cookies",children:"cookie"}),"\nvisible to the current page. You can query a specific cookie by providing the cookie name or\nretrieve all."]}),"\n",(0,s.jsx)(t.h2,{id:"usage",children:"Usage"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-js",children:"await browser.getCookies(filter, sourceOrigin)\n"})}),"\n",(0,s.jsx)(t.h2,{id:"parameters",children:"Parameters"}),"\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{children:"Name"}),(0,s.jsx)(t.th,{children:"Type"}),(0,s.jsx)(t.th,{children:"Details"})]})}),(0,s.jsxs)(t.tbody,{children:[(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{children:(0,s.jsx)(t.code,{children:"filter"})}),(0,s.jsx)(t.td,{children:(0,s.jsx)(t.code,{children:"remote.StorageCookieFilter"})}),(0,s.jsx)(t.td,{children:"an object that allows to filter for cookies with specific attributes"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{children:(0,s.jsx)(t.code,{children:"sourceOrigin"})}),(0,s.jsx)(t.td,{children:(0,s.jsx)(t.code,{children:"string, null"})}),(0,s.jsx)(t.td,{children:"an optional source origin to fetch cookies for, if not provided it will default to the current page's origin, if explicitly set to null it will fetch cookies without a partition (only supported in BiDi)"})]})]})]}),"\n",(0,s.jsx)(t.h2,{id:"example",children:"Example"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-js",metastring:'title="getCookies.js"',children:"it('should return a cookie for me', async () => {\n    await browser.setCookies([\n        {name: 'test', value: '123'},\n        {name: 'test2', value: '456'}\n    ])\n    const testCookie = await browser.getCookies(['test'])\n    console.log(testCookie); // outputs: [{ name: 'test', value: '123' }]\n\n    const allCookies = await browser.getCookies()\n    console.log(allCookies);\n    // outputs:\n    // [\n    //    { name: 'test', value: '123' },\n    //    { name: 'test2', value: '456' }\n    // ]\n\n    // filter cookies by domain\n    const stagingCookies = await browser.getCookies({\n        domain: 'staging.myapplication.com'\n    })\n})\n"})}),"\n",(0,s.jsx)(t.h2,{id:"returns",children:"Returns"}),"\n",(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.strong,{children:"<Cookie[]>"}),"\n",(0,s.jsxs)(t.strong,{children:[(0,s.jsx)("code",{children:(0,s.jsx)("var",{children:"return"})}),":"]}),"                            requested cookies"]}
1),"\n"]})]})}function u(e={}){const{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.