PageSourceSearch

https://webdriver.io/assets/js/36c17213.782d356e.js

js webdriver.io collected 2026-09-24 08:34:53 UTC 4,920 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[22715],{22002:(e,t,s)=>{s.d(t,{R:()=>o,x:()=>i});var r=s(7378);const c={},n=r.createContext(c);function o(e){const t=r.useContext(n);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(c):e.components||c:o(e.components),r.createElement(n.Provider,{value:t},e.children)}},94780:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>a,contentTitle:()=>i,default:()=>u,frontMatter:()=>o,metadata:()=>r,toc:()=>l});const r=JSON.parse('{"id":"api/browser/custom$","title":"custom$","description":"The custom$ allows you to use a custom strategy declared by using browser.addLocatorStrategy.","source":"@site/docs/api/browser/_custom$.md","sourceDirName":"api/browser","slug":"/api/browser/custom$","permalink":"/docs/api/browser/custom$","draft":false,"unlisted":false,"editUrl":"https://github.com/webdriverio/webdriverio/edit/main/packages/webdriverio/src/commands/browser/custom$.ts","tags":[],"version":"current","frontMatter":{"id":"custom$","title":"custom$","custom_edit_url":"https://github.com/webdriverio/webdriverio/edit/main/packages/webdriverio/src/commands/browser/custom$.ts"},"sidebar":"api","previous":{"title":"custom$$","permalink":"/docs/api/browser/custom$$"},"next":{"title":"debug","permalink":"/docs/api/browser/debug"}}');var c=s(86106),n=s(22002);const o={id:"custom$",title:"custom$",custom_edit_url:"https://github.com/webdriverio/webdriverio/edit/main/packages/webdriverio/src/commands/browser/custom$.ts"},i=void 0,a={},l=[{value:"Usage",id:"usage",level:2},{value:"Parameters",id:"parameters",level:2},{value:"Examples",id:"examples",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,n.R)(),...e.components};return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(t.p,{children:["The ",(0,c.jsx)(t.code,{children:"custom$"})," allows you to use a custom strategy declared by using ",(0,c.jsx)(t.code,{children:"browser.addLocatorStrategy"}),".\nRead more on custom selector stratgies in the ",(0,c.jsx)(t.a,{href:"../../selectors#custom-selector-strategies",children:"Selector docs"}),"."]}),"\n",(0,c.jsx)(t.h2,{id:"usage",children:"Usage"}),"\n",(0,c.jsx)(t.pre,{children:(0,c.jsx)(t.code,{className:"language-js",children:"await browser.custom$(strategyName, strategyArguments)\n"})}),"\n",(0,c.jsx)(t.h2,{id:"parameters",children:"Parameters"}),"\n",(0,c.jsxs)(t.table,{children:[(0,c.jsx)(t.thead,{children:(0,c.jsxs)(t.tr,{children:[(0,c.jsx)(t.th,{children:"Name"}),(0,c.jsx)(t.th,{children:"Type"}),(0,c.jsx)(t.th,{children:"Details"})]})}),(0,c.jsxs)(t.tbody,{children:[(0,c.jsxs)(t.tr,{children:[(0,c.jsx)(t.td,{children:(0,c.jsx)(t.code,{children:"strategyName"})}),(0,c.jsx)(t.td,{children:(0,c.jsx)(t.code,{children:"string"})}),(0,c.jsx)(t.td,{})]}),(0,c.jsxs)(t.tr,{children:[(0,c.jsx)(t.td,{children:(0,c.jsx)(t.code,{children:"strategyArguments"})}),(0,c.jsx)(t.td,{children:(0,c.jsx)(t.code,{children:"*"})}),(0,c.jsx)(t.td,{})]})]})]}),"\n",(0,c.jsx)(t.h2,{id:"examples",children:"Examples"}),"\n",(0,c.jsx)(t.pre,{children:(0,c.jsx)(t.code,{className:"language-js",metastring:'reference title="customStrategy.js" useHTTPS',children:"https://github.com/webdriverio/example-recipes/blob/f5730428ec3605e856e90bf58be17c9c9da891de/queryElements/customStrategy.js#L2-L11\n"})}),"\n",(0,c.jsx)(t.pre,{children:(0,c.jsx)(t.code,{className:"language-html",metastring:'reference title="example.html" useHTTPS',children:"https://github.com/webdriverio/example-recipes/blob/f5730428ec3605e856e90bf58be17c9c9da891de/queryElements/example.html#L8-L12\n"})}),"\n",(0,c.jsx)(t.pre,{children:(0,c.jsx)(t.code,{className:"language-js",metastring:'reference title="customStrategy.js" useHTTPS',children:"https://github.com/webdriverio/example-recipes/blob/f5730428ec3605e856e90bf58be17c9c9da891de/queryElements/customStrategy.js#L16-L19\n"})}),"\n",(0,c.jsx)(t.pre,{children:(0,c.jsx)(t.code,{className:"language-js",metastring:'title="example.js"',children:"it('should fetch the project title', async () => {\n    await browser.url('https://webdriver.io')\n    browser.addLocatorStrategy('myStrat', (selector) => {\n        return document.querySelectorAll(selector)\n    })\n\n    const projectTitle = await browser.custom$('myStrat', '.projectTitle')\n\n    console.log(await projectTitle.getText()) // WEBDRIVER I/O\n})\n"})}),"\n",(0,c.jsx)(t.h2,{id:"returns",children:"Returns"}),"\n",(0,c.jsxs)(t.ul,{children:["\n",(0,c.jsx)(t.li,{children:(0,c.jsx)(t.strong,{children:"<WebdriverIO.Element>"})}),"\n"]})]})}function u(e={}){const{wrapper:t}={...(0,n.R)(),...e.components};return t?(0,c.jsx)(t,{...e,children:(0,c.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.