0

I'm new to TS and WebdriverIO.

describe('Test', () => {

    it('Test', async () => {
        console.log(Generallib.createRandomCharacter(8, "CompanyDesc"))
        console.log('Setting the store')
        console.log(browser);
        // @ts-ignore
        browser.sharedStore.set('key', 'value');
        // browser.sharedStore.set('SomeDesc', 'See this');
        console.log(browser);
        console.log('Store set');
        console.log('Accessing the store');
        await browser.pause(5000);
        console.log(browser.sharedStore.get('someDesc'));
        console.log('Store accessed')
    });
});

Using Shared Store (https://webdriver.io/docs/shared-store-service/#usage) I am trying to set and access a value.

But I am getting the below message saying promise is pending:

[0-3] Store set
[0-3] Accessing the store
[0-3] Promise { <pending> }
[0-3] Store accessed
[0-3] PASSED in chrome - /test/specs/Test.ts

Looking for some help on how to resolve this.

Prakash P
  • 419
  • 1
  • 8
  • 18

1 Answers1

2

"[0-3] Promise { }" is not an error, await will handle the promise to get the action done in sync manner. Use await:

await browser.sharedStore.set('key', 'value');

Refer: How and when to use ‘async’ and ‘await’

tan js
  • 204
  • 2
  • 10