1"use strict";(self.webpackChunktestplane_docs=self.webpackChunktestplane_docs||[]).push([["1475"],{81774(e,s,n){n.r(s),n.d(s,{metadata:()=>t,default:()=>u,frontMatter:()=>o,contentTitle:()=>c,toc:()=>d,assets:()=>l});var t=JSON.parse('{"id":"commands/element/isFocused","title":"isFocused","description":"Overview {/ #overview /}","source":"@site/docs/commands/element/isFocused.mdx","sourceDirName":"commands/element","slug":"/commands/element/isFocused","permalink":"/docs/commands/element/isFocused","draft":false,"unlisted":false,"editUrl":"https://github.com/gemini-testing/testplane-docs/tree/master/docs/commands/element/isFocused.mdx","tags":[],"version":"current","frontMatter":{},"sidebar":"mainSidebar","previous":{"title":"isExisting","permalink":"/docs/commands/element/isExisting"},"next":{"title":"isSelected","permalink":"/docs/commands/element/isSelected"}}'),i=n(74848),r=n(28453);let o={},c="isFocused",l={},d=[{value:"Overview",id:"overview",level:2},{value:"Usage",id:"usage",level:2},{value:"Usage Examples",id:"examples",level:2},{value:"References",id:"references",level:2}];function a(e){let s={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",p:"p",pre:"pre",strong:"strong",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(s.header,{children:(0,i.jsx)(s.h1,{id:"isfocused",children:"isFocused"})}),"\n",(0,i.jsx)(s.h2,{id:"overview",children:"Overview"}),"\n",(0,i.jsxs)(s.p,{children:["Use the ",(0,i.jsx)(s.code,{children:"isFocused"})," command to determine whether a given DOM element is focused."]}),"\n",(0,i.jsxs)(s.p,{children:["The command returns ",(0,i.jsx)(s.code,{children:"true"})," if the selected element is focused; otherwise, it returns ",(0,i.jsx)(s.code,{children:"false"}),"."]}),"\n",(0,i.jsxs)(s.p,{children:["If multiple elements match the selector, the command returns ",(0,i.jsx)(s.code,{children:"true"})," if at least one of the elements is focused."]}),"\n",(0,i.jsx)(s.h2,{id:"usage",children:"Usage"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-javascript",children:"await browser.$(selector).isFocused();\n"})}),"\n",(0,i.jsx)(s.h2,{id:"examples",children:"Usage Examples"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.strong,{children:"index.html"})}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-html",children:'<input name="login" autofocus="" />\n'})}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.strong,{children:"isFocused.js"})}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-javascript",children:'it("should detect the focus of an element", async ({ browser }) => {\n await browser.url("/");\n const loginInput = await browser.$(\'[name="login"]\');\n console.log(await loginInput.isFocused()); // outputs: false\n\n await loginInput.click();\n console.log(await loginInput.isFocused()); // outputs: true\n});\n'})}),"\n",(0,i.jsx)(s.h2,{id:"references",children:"References"}),"\n",(0,i.jsxs)(s.p,{children:["We'd like to give credit to the original WebdriverIO docs ",(0,i.jsx)(s.a,{href:"https://webdriver.io/docs/api/element/isFocused",children:"article"}),", from which we drew some information while writing our version."]})]})}function u(e={}){let{wrapper:s}={...(0,r.R)(),...e.components};return s?(0,i.jsx)(s,{...e,children:(0,i.jsx)(a,{...e})}):a(e)}},28453(e,s,n){n.d(s,{R:()=>o,x:()=>c});var t=n(96540);let i={},r=t.createContext(i);function o(e){let s=t.useContext(r);return t.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function c(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:o(e.components),t.createElement(r.Provider,{value:s},e.children)}}}]);
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.