【问题标题】:TestCafe conditional if else web element how continue to next condition if first one failedTestCafe 条件 if else web 元素如果第一个失败,如何继续下一个条件
【发布时间】:2020-08-05 05:34:34
【问题描述】:
if (btnSubmit.exists) {
    await t
        .click(btnSubmit) //this failed due to button not exist actual is stopped in here
} else if (buttonOK.exists) {
    await t
        .click(buttonOK) //i want to continue to execute this button which is exist
} else {
    console.log("foo")
}

我有类似这样的简单代码,如果第一个条件未找到 web 元素,则运行自动化,然后继续下一个条件,但实际是保持失败并在第一个条件下停止。

screen

【问题讨论】:

    标签: javascript testing automated-tests e2e-testing testcafe


    【解决方案1】:

    试试,

        if (await btnSubmit.exists) {
            await t.click(btnSubmit)
        } else if (await buttonOK.exists) {
            await t.click(buttonOK)
        } else {
            console.log("foo")
        }
    

    【讨论】:

    • 感谢@VysakhMohan 的建议,刚刚尝试成功,但是“t.click”的动作没有在前端执行,还有其他建议吗?
    • 你能发布按钮的 HTML
    猜你喜欢
    • 2019-03-05
    • 1970-01-01
    • 2019-02-27
    • 1970-01-01
    • 1970-01-01
    • 2022-01-06
    • 1970-01-01
    • 2015-01-04
    • 1970-01-01
    相关资源
    最近更新 更多