【问题标题】:Promise pending - webdriverio - sharedStore承诺未决 - webdriverio - sharedStore
【发布时间】:2022-07-19 21:09:01
【问题描述】:

我是 TS 和 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')
    });
});

使用共享存储 (https://webdriver.io/docs/shared-store-service/#usage) 我正在尝试设置和访问一个值。

但我收到以下消息说承诺待定:

[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

寻求有关如何解决此问题的帮助。

【问题讨论】:

    标签: webdriver-io


    【解决方案1】:

    使用

    > async - await
    
    *await browser.sharedStore.set('key', 'value');*
    

    【讨论】:

    • 请阅读How to Answeredit 您的问题,以解释为什么此代码实际上可以解决手头的问题。永远记住,您不仅在解决问题,而且还在教育 OP 和这篇文章的任何未来读者。
    猜你喜欢
    • 2020-03-16
    • 1970-01-01
    • 2020-10-22
    • 2014-12-15
    • 2018-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多