typescriptautomationwebdriver-io

TypeError: Cannot read properties of undefined (reading 'set') while using WebDriverIO SharedStore service


I follow exactly this instruction from WebDriverIO about Shared Store Service https://webdriver.io/docs/shared-store-service/, for example:

Install it in package.json:

npm install @wdio/shared-store-service --save-dev

Add it to wdio configuration file:

// wdio.conf.js
export const config = {
    // ...
    services: ['shared-store'],
    // ...
};

But when I try to use it in my test, like this:

const companyUrl = await $('#companyUrl').getValue();
await browser.sharedStore.set('companyUrl', companyUrl)

I always get this error:

TypeError: Cannot read properties of undefined (reading 'set')

So the sharedStore is not utilized. What am I still missing?


Solution

  • So my problem was, I have many wdio.conf files for different tests, and I placed shared-store in the wrong conf file.

    After put it in the correct .conf file in which I need shared-store, I have no problem anymore, for example:

    services: [
       ['chromedriver'],
       ['shared-store'],
    ],