1"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[6061],{22002:(e,t,n)=>{n.d(t,{R:()=>l,x:()=>a});var s=n(7378);const i={},r=s.createContext(i);function l(e){const t=s.useContext(r);return s.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(i):e.components||i:l(e.components),s.createElement(r.Provider,{value:t},e.children)}},63128:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>o,contentTitle:()=>a,default:()=>d,frontMatter:()=>l,metadata:()=>s,toc:()=>c});const s=JSON.parse('{"id":"api/element/getValue","title":"getValue","description":"Get the value of a `, or text ` found by given selector.","source":"@site/docs/api/element/_getValue.md","sourceDirName":"api/element","slug":"/api/element/getValue","permalink":"/docs/api/element/getValue","draft":false,"unlisted":false,"editUrl":"https://github.com/webdriverio/webdriverio/edit/main/packages/webdriverio/src/commands/element/getValue.ts","tags":[],"version":"current","frontMatter":{"id":"getValue","title":"getValue","custom_edit_url":"https://github.com/webdriverio/webdriverio/edit/main/packages/webdriverio/src/commands/element/getValue.ts"},"sidebar":"api","previous":{"title":"getText","permalink":"/docs/api/element/getText"},"next":{"title":"isClickable","permalink":"/docs/api/element/isClickable"}}');var i=n(86106),r=n(22002);const l={id:"getValue",title:"getValue",custom_edit_url:"https://github.com/webdriverio/webdriverio/edit/main/packages/webdriverio/src/commands/element/getValue.ts"},a=void 0,o={},c=[{value:"Usage",id:"usage",level:2},{value:"Examples",id:"examples",level:2},{value:"Returns",id:"returns",level:2}];function u(e){const t={code:"code",h2:"h2",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(t.p,{children:["Get the value of a ",(0,i.jsx)(t.code,{children:"<textarea>"}),", ",(0,i.jsx)(t.code,{children:"<select>"})," or text ",(0,i.jsx)(t.code,{children:"<input>"})," found by given selector.\nIf multiple elements are found via the given selector, an array of values is returned instead.\nFor input with checkbox or radio type use isSelected."]}),"\n",(0,i.jsx)(t.h2,{id:"usage",children:"Usage"}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-js",children:"await $(selector).getValue()\n"})}),"\n",(0,i.jsx)(t.h2,{id:"examples",children:"Examples"}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-html",metastring:'title="index.html"',children:'<input type="text" value="John Doe" id="username">\n'})}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-js",metastring:'title="getValue.js"',children:"it('should demonstrate the getValue command', async () => {\n const inputUser = await $('#username');\n const value = await inputUser.getValue();\n console.log(value); // outputs: \"John Doe\"\n});\n"})}),"\n",(0,i.jsx)(t.h2,{id:"returns",children:"Returns"}),"\n",(0,i.jsxs)(t.ul,{children:["\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.strong,{children:"<String>"}),"\n",(0,i.jsxs)(t.strong,{children:[(0,i.jsx)("code",{children:(0,i.jsx)("var",{children:"return"})}),":"]})," requested element(s) value"]}),"\n"]})]})}function d(e={}){const{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,i.jsx)(t,{...e,children:(0,i.jsx)(u,{...e})}):u(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.