【问题标题】:How to handle test case fails in Katalon Studio如何在 Katalon Studio 中处理测试用例失败
【发布时间】:2019-03-05 18:25:43
【问题描述】:

在我的测试用例中,我决定是否要切换我的单选按钮。我检查我的单选按钮是否没有checked 属性,如下所示:

TestObject srcCurrOpModeRadioBtn = guiUtils.createControl('config-src-op-mode-currentradio')
        if(WebUI.verifyElementNotHasAttribute(srcCurrOpModeRadioBtn, 'checked', 5)){
            TestObject srcCurrOpModeToggle = guiUtils.createControl('config-src-op-mode-current')
            WebUI.click(srcCurrOpModeToggle)
            WebUI.delay(1)
        }

当我的对象没有checked 属性时,这可以正常工作,但是当我的对象已经是checked(处于我想要的状态)时,我的测试用例会失败。我怎样才能使它不会失败,而是执行剩余的测试?

简单来说,我有一个在 2 种模式之间切换的开关,我们称它们为 mode1 和 mode2。这个特定的测试测试 mode1 的偏好,所以在测试 mode1 的偏好之前,我必须切换到 mode1。我的逻辑在测试开始时处于模式 2 时有效,但当我已经处于模式 1 时它会失败。 I know that it fails because when mode1 is selected, its radio button already has a checked attribute and so the if statement fails but I don't want my test case to fail because of this, I want to test mode1's preferences .

【问题讨论】:

    标签: katalon-studio


    【解决方案1】:

    WebUI.verifyElementNotHasAttribute() - flow control 还有另一个参数。

    您需要设置FailureHandling.OPTIONAL,这样即使函数返回false,测试也会继续执行。然后你就可以用相应的逻辑编写“else”部分了。

    【讨论】:

    • 不错!非常感谢,没想到这么简单:D
    猜你喜欢
    • 1970-01-01
    • 2021-04-11
    • 2019-01-08
    • 1970-01-01
    • 1970-01-01
    • 2020-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多