【问题标题】:WebDriverIO :: error: setValue is not a function"WebDriverIO :: 错误:setValue 不是函数”
【发布时间】:2021-07-29 10:55:43
【问题描述】:

我在尝试为元素设置值时发现错误:setValue is not a function。 但我想出了一个解决方案,比如使用 async 函数

 describe("Interaction with web elements", function () {
        it("Enter Value in a field", async function () {
            await browser.url('/');
            const Search = await $('#twotabsearchtextbox')
            await Search.setValue('MacBook');
        })
    });

是否有任何其他替代方法来修复它们?

【问题讨论】:

  • 您在什么情况下使用setValue 导致该错误?
  • setValue(), getText() 任何方法都不能用作同步功能......我只能使用异步 ===>> 你知道任何解决方案

标签: javascript unit-testing automation webdriver-io setvalue


【解决方案1】:

它不起作用,因为您没有添加 async 和 await

describe("interaction with web elements",()=>{
    it("enter value in a field", async() => {
        await browser.url('/');
        const search = await browser.$('#twotabsearchtextbox');
        search.setValue('mac');
        await browser.pause(500);
    })
})

这应该可以工作

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-25
    • 1970-01-01
    • 2019-05-21
    • 2022-10-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多