1"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[4490],{1001:(e,n,i)=>{i.d(n,{A:()=>k});var t=i(7378),r=i(23372),s=i(41129),l=i(82434),a=i(30505),c=i(90703),o=i(8663),d=i(39164),u=i(60534);function h(e){return t.Children.toArray(e).filter(e=>"\n"!==e).map(e=>{if(!e||(0,t.isValidElement)(e)&&function(e){const{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return e;throw new Error(`Docusaurus error: Bad <Tabs> child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.`)})?.filter(Boolean)??[]}function m(e){const{values:n,children:i}=e;return(0,t.useMemo)(()=>{const e=n??function(e){return h(e).map(({props:{value:e,label:n,attributes:i,default:t}})=>({value:e,label:n,attributes:i,default:t}))}(i);return function(e){const n=(0,d.XI)(e,(e,n)=>e.value===n.value);if(n.length>0)throw new Error(`Docusaurus error: Duplicate values "${n.map(e=>e.value).join(", ")}" found in <Tabs>. Every value needs to be unique.`)}(e),e},[n,i])}function p({value:e,tabValues:n}){return n.some(n=>n.value===e)}function v({queryString:e=!1,groupId:n}){const i=(0,a.W6)(),r=function({queryString:e=!1,groupId:n}){if("string"==typeof e)return e;if(!1===e)return null;if(!0===e&&!n)throw new Error('Docusaurus error: The <Tabs> component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return n??null}({queryString:e,groupId:n});return[(0,o.aZ)(r),(0,t.useCallback)(e=>{if(!r)return;const n=new URLSearchParams(i.location.search);n.set(r,e),i.replace({...i.location,search:n.toString()})},[r,i])]}function x(e){const{defaultValue:n,queryString:i=!1,groupId:r}=e,s=m(e),[l,a]=(0,t.useState)(()=>function({defaultValue:e,tabValues:n}){if(0===n.length)throw new Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(e){if(!p({value:e,tabValues:n}))throw new Error(`Docusaurus error: The <Tabs> has a defaultValue "${e}" but none of its children has the corresponding value. Available values are: ${n.map(e=>e.value).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return e}const i=n.find(e=>e.default)??n[0];if(!i)throw new Error("Unexpected error: 0 tabValues");return i.value}({defaultValue:n,tabValues:s})),[o,d]=v({queryString:i,groupId:r}),[h,x]=function({groupId:e}){const n=function(e){return e?`docusaurus.tab.${e}`:null}(e),[i,r]=(0,u.Dv)(n);return[i,(0,t.useCallback)(e=>{n&&r.set(e)},[n,r])]}({groupId:r}),j=(()=>{const e=o??h;return p({value:e,tabValues:s})?e:null})();(0,c.A)(()=>{j&&a(j)},[j]);return{selectedValue:l,selectValue:(0,t.useCallback)(e=>{if(!p({value:e,tabValues:s}))throw new Error(`Can't select invalid tab value=${e}`);a(e),d(e),x(e)},[d,x,s]),tabValues:s}}var j=i(17933);const f={tabList:"tabList_PGOh",tabItem:"tabItem_Wr1C"};var b=i(86106);function g({className:e,block:n,selectedValue:i,selectValue:t,tabValues:s}){const a=[],{blockElementScrollPositionUntilNextRender:c}=(0,l.a_)(),o=e=>{const n=e.currentTarget,r=a.indexOf(n),l=s[r].value;l!==i&&(c(n),t(l))},d=e=>{let n=null;switch(e.key){case"Enter":o(e);break;case"ArrowRight":{const i=a.indexOf(e.currentTarget)+1;n=a[i]??a[0];break}case"ArrowLeft":{const i=a.indexOf(e.currentTarget)-1;n=a[i]??a[a.length-1];break}}n?.focus()};return(0,b.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,r.A)("tabs",{"tabs--block":n},e),children:s.map(({value:e,label:n,attributes:t})=>(0,b.jsx)("li",{role:"tab",tabIndex:i===e?0:-1,"aria-selected":i===e,ref:e=>{a.push(e)},onKeyDown:d,onClick:o,...t,className:(0,r.A)("tabs__item",f.tabItem,t?.className,{"tabs__item--active":i===e}),children:n??e},e))})}function w({lazy:e,children:n,selectedValue:i}){const s=(Array.isArray(n)?n:[n]).filter(Boolean);if(e){const e=s.find(e=>e.props.value===i);return e?(0,t.cloneElement)(e,{className:(0,r.A)("margin-top--md",e.props.className)}):null}return(0,b.jsx)("div",{className:"margin-top--md",children:s.map((e,n)=>(0,t.cloneElement)(e,{key:n,hidden:e.props.value!==i}))})}function y(e){const n=x(e);return(0,b.jsxs)("div",{className:(0,r.A)(s.G.tabs.container,"tabs-container",f.tabList),
1children:[(0,b.jsx)(g,{...n,...e}),(0,b.jsx)(w,{...n,...e})]})}function k(e){const n=(0,j.A)();return(0,b.jsx)(y,{...e,children:h(e.children)},String(n))}},22002:(e,n,i)=>{i.d(n,{R:()=>l,x:()=>a});var t=i(7378);const r={},s=t.createContext(r);function l(e){const n=t.useContext(s);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:l(e.components),t.createElement(s.Provider,{value:n},e.children)}},61031:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>c,contentTitle:()=>a,default:()=>u,frontMatter:()=>l,metadata:()=>t,toc:()=>o});const t=JSON.parse('{"id":"wdio-gmail-service","title":"Gmail Service","description":"wdio-gmail-service is a 3rd party package, for more information please see GitHub | npm","source":"@site/docs/_wdio-gmail-service.md","sourceDirName":".","slug":"/wdio-gmail-service","permalink":"/docs/wdio-gmail-service","draft":false,"unlisted":false,"editUrl":"https://github.com/webdriverio-community/wdio-gmail-service/edit/main/README.md","tags":[],"version":"current","frontMatter":{"id":"wdio-gmail-service","title":"Gmail Service","custom_edit_url":"https://github.com/webdriverio-community/wdio-gmail-service/edit/main/README.md"},"sidebar":"docs","previous":{"title":"Dioxus Service","permalink":"/docs/wdio-dioxus-service"},"next":{"title":"Zafira Listener Service","permalink":"/docs/wdio-zafira-listener-service"}}');var r=i(86106),s=i(22002);i(1001),i(87780);const l={id:"wdio-gmail-service",title:"Gmail Service",custom_edit_url:"https://github.com/webdriverio-community/wdio-gmail-service/edit/main/README.md"},a=void 0,c={},o=[{value:"Installation",id:"installation",level:2},{value:"Usage",id:"usage",level:2},{value:"Gmail Authentication",id:"gmail-authentication",level:3},{value:"Configuration",id:"configuration",level:3},{value:"Service Options",id:"service-options",level:2},{value:"credentials",id:"credentials",level:3},{value:"token",id:"token",level:3},{value:"intervalSec",id:"intervalsec",level:3},{value:"timeoutSec",id:"timeoutsec",level:3},{value:"Writing tests",id:"writing-tests",level:2},{value:"<code>checkInbox</code> parameters",id:"checkinbox-parameters",level:2},{value:"<code>from</code>
1",id:"from",level:3},{value:"<code>to</code>",id:"to",level:3},{value:"<code>subject</code>",id:"subject",level:3},{value:"<code>includeBody</code>",id:"includebody",level:3},{value:"<code>includeAttachments</code>",id:"includeattachments",level:3},{value:"<code>before</code>",id:"before",level:3},{value:"<code>after</code>",id:"after",level:3},{value:"<code>label</code>",id:"label",level:3}];function d(e){const n={a:"a",blockquote:"blockquote",code:"code",h2:"h2",h3:"h3",hr:"hr",p:"p",pre:"pre",...(0,s.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsxs)(n.p,{children:["wdio-gmail-service is a 3rd party package, for more information please see ",(0,r.jsx)(n.a,{href:"https://github.com/webdriverio-community/wdio-gmail-service",children:"GitHub"})," | ",(0,r.jsx)(n.a,{href:"https://www.npmjs.com/package/wdio-gmail-service",children:"npm"})]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["A WebdriverIO plugin to fetch e-mails from Google Mail using ",(0,r.jsx)(n.a,{href:"https://github.com/levz0r/gmail-tester",children:"Gmail Tester"}),"."]}),"\n",(0,r.jsx)(n.h2,{id:"installation",children:"Installation"}),"\n",(0,r.jsxs)(n.p,{children:["The easiest way is to keep ",(0,r.jsx)(n.code,{children:"wdio-gmail-service"})," as a ",(0,r.jsx)(n.code,{children:"devDependency"})," in your package.json."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-json",children:'{\n "devDependencies": {\n "wdio-gmail-service": "^2.0.0"\n }\n}\n'})}),"\n",(0,r.jsx)(n.p,{children:"You can simply do it by:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-sh",children:"npm install wdio-gmail-service --save-dev\n"})}),"\n",(0,r.jsx)(n.h2,{id:"usage",children:"Usage"}),"\n",(0,r.jsx)(n.h3,{id:"gmail-authentication",children:"Gmail Authentication"}),"\n",(0,r.jsxs)(n.p,{children:["You'll need to follow the instructions at ",(0,r.jsx)(n.a,{href:"https://github.com/levz0r/gmail-tester",children:"Gmail Tester"})," to create the ",(0,r.jsx)(n.code,{children:"credentials.json"})," (the OAuth2 Authentication file) and ",(0,r.jsx)(n.code,{children:"token.json"})," (the OAuth2 token)."]}),"\n",(0,r.jsx)(n.h3,{id:"configuration",children:"Configuration"}),"\n",(0,r.jsxs)(n.p,{children:["Add the service by adding ",(0,r.jsx)(n.code,{children:"gmail"})," to the service list, e.g.:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-js",children:"// wdio.conf.js\nimport path from 'path'\n\nexport const config = {\n // ...\n services: [['gmail', {\n credentials: path.join(process.cwd(), './credentials.json'),\n token: join(process.cwd(), './token.json'),\n intervalSec: 10,\n timeoutSec: 60\n }]]\n // ...\n};\n"})}),"\n",(0,r.jsx)(n.h2,{id:"service-options",children:"Service Options"}),"\n",(0,r.jsx)(n.h3,{id:"credentials",children:"credentials"}),"\n",(0,r.jsx)(n.p,{children:"Absolute path to a credentials JSON file."}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.code,{children:"string | Credentials"})]}),"\n",(0,r.jsxs)(n.p,{children:["Required: ",(0,r.jsx)(n.code,{children:"true"})]}),"\n",(0,r.jsx)(n.h3,{id:"token",children:"token"}),"\n",(0,r.jsx)(n.p,{children:"Absolute path to a token JSON file."}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.code,{children:"string | Record<string, unknown>"})]}),"\n",(0,r.jsxs)(n.p,{children:["Required: ",(0,r.jsx)(n.code,{children:"true"})]}),"\n",(0,r.jsx)(n.h3,{id:"intervalsec",children:"intervalSec"}),"\n",(0,r.jsx)(n.p,{children:"The interval between Gmail inbox checks."}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.code,{children:"number"})]}),"\n",(0,r.jsxs)(n.p,{children:["Default: ",(0,r.jsx)(n.code,{children:"10"})]}),"\n",(0,r.jsxs)(n.p,{children:["Required: ",(0,r.jsx)(n.code,{children:"false"})]}),"\n",(0,r.jsx)(n.h3,{id:"timeoutsec",children:"timeoutSec"}),"\n",(0,r.jsx)(n.p,{children:"The maximum time to wait for finding the email for the given filters."}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.code,{children:"number"})]}),"\n",(0,r.jsxs)(n.p,{children:["Default: ",(0,r.jsx)(n.code,{children:"60"})]}),"\n",(0,r.jsxs)(n.p,{children:["Required: ",(0,r.jsx)(n.code,{children:"false"})]}),"\n",(0,r.jsx)(n.h2,{id:"writing-tests",children:"Writing tests"}),"\n",(0,r.jsx)(n.p,{children:"In your WebdriverIO test, you can now check if an email was received."}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-js",children:"describe('Example', () => {\n it('Should check email', () => {\n // perform some actions that will send an email to setup gmail account\n const emails = await browser.checkInbox({ from: '[email protected]', subject: 'Ubisoft Password Change Request' });\n expect(emails[0].body.html).toContain('https://account-uplay.ubi.com/en-GB/action/change-password?genomeid=')\n })\n})\n"})}),"\n",(0,r.jsxs)(n.h2,{id:"checkinbox-parameters",children:[(0,r.jsx)(n.code,{children:"checkInbox"})," parameters"]}),"\n",(0,r.jsxs)(n.p,{children:["The command parameters require at least one of ",(0,r.jsx)(n.code,{children:"from"}),", ",(0,r.jsx)(n.code,{children:"to"}),", or ",(0,r.jsx)(n.code,{children:"subject"}),":"]}),"\n",(0,r.jsx)(n.h3,{id:"from",children:(0,r.jsx)(n.code,{children:"from"})}),"\n",(0,r.jsx)(n.p,{children:"Filter on the email address of the receiver."}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.code,{children:"String"})]}),"\n",(0,r.jsx)(n.h3,{id:"to",children:(0,r.jsx)(n.code,{children:"to"})}),"\n",(0,r.jsx)(n.p,{children:"Filter on the email address of the sender."}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.code,{children:"String"})]}),"\n",(0,r.jsx)(n.h3,{id:"subject",children:(0,r.jsx)(n.code,{children:"subject"})}),"\n",(0,r.jsx)(n.p,{children:"Filter on the subject of the email."}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.code,{children:"String"})]}),"\n",(0,r.jsx)(n.h3,{id:"includebody",children:(0,r.jsx)(n.code,{children:"includeBody"})}),"\n",(0,r.jsx)(n.p,{children:"Set to true to fetch decoded email bodies."}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.code,{children:"boolean"})]}),"\n",(0,r.jsx)(n.h3,{id:"includeattachments",children:(0,r.jsx)(n.code,{children:"includeAttachments"})}),"\n",(0,r.jsx)(n.p,{children:"Set to true to fetch the base64-encoded email attachments."}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.code,{children:"boolean"})]}),"\n",(0,r.jsx)(n.h3,{id:"before",children:(0,r.jsx)(n.code,{children:"before"})}),"\n",(0,r.jsx)(n.p,{children:"Filter messages received before the specified date."}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.code,{children:"Date"})]}),"\n",(0,r.jsx)(n.h3,{id:"after",children:(0,r.jsx)(n.code,{children:"after"})}),"\n",(0,r.jsx)(n.p,{children:"Filter messages received after the specified date."}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.code,{children:"Date"})]}),"\n",(0,r.jsx)(n.h3,{id:"label",children:(0,r.jsx)(n.code,{children:"label"})}),"\n",(0,r.jsxs)(n.p,{children:["The default label is 'INBOX', but can be changed to 'SPAM', 'TRASH' or a custom label. For a full list of built-in labels, see ",(0,r.jsx)(n.a,{href:"https://developers.google.com/gmail/api/guides/labels?hl=en",children:"https://developers.google.com/gmail/api/guides/labels?hl=en"})]}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.code,{children:"String"})]}),"\n",(0,r.jsx)(n.hr,{}),"\n",(0,r.jsxs)(n.p,{children:["For more information on WebdriverIO see the ",(0,r.jsx)(n.a,{href:"https://webdriver.io",children:"homepage"}),"."]})]})}function u(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(d,{...e})}):d(e)}},87780:(e,n,i)=>{i.d(n,{A:()=>l});i(7378);var t=i(23372);const r={tabItem:"tabItem_l0gC"};var s=i(86106);function l({children:e,hidden:n,className:i}){return(0,s.jsx)("div",{role:"tabpanel",className:(0,t.A)(r.tabItem,i),hidden:n,children: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.