Webdriver io - 当控制台输出中明确存在值时,expect 中的方法未定义返回

我是 webdriver io 和 typescript 的新手。

无法理解为什么从页面文件输出到控制台显示值但测试并特别期望它的一部分总是将其报告为未定义。

Repo。 测试执行的控制台输出:

itemsPrice: 129.94 \**this is from console.log mentioned below*


Error: Expect  to have property value

Expected: "Item total: $129.94"
Received: undefined
describe('Test',() => {
    it.only('Order',async () => {
        ...
        await expect(await CheckoutOverviewPage.getItemsPrice()).toHaveValue(129.94);
    });
});
import Page from './page';

class CheckoutOverviewPage extends Page {

    get itemsPrice () { return $('//*[@class="summary_subtotal_label"]')}
    
    async getItemsPrice () {
        var finalValue;
        (await this.itemsPrice).getText().then((text) => {
            console.log("itemsPrice: " + parseFloat(text.replace('Item total: $','')));
            finalValue = parseFloat(text.replace('Item Total: $',''));
        });
        return finalValue
    }
huangyanglv 回答:Webdriver io - 当控制台输出中明确存在值时,expect 中的方法未定义返回

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/440.html

大家都在问