如何在 Katalon Studio 中处理测试用例失败
How to handle test case fails in Katalon Studio
在我的测试用例中,我决定是否要切换我的单选按钮。我检查我的单选按钮是否没有 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
(处于我希望的状态)时,我的测试用例失败了。我如何才能让它不失败,而是执行剩余的测试?
简单来说,我有一个可以在两种模式之间切换的开关,我们称它们为模式 1 和模式 2。此特定测试测试模式 1 的首选项,因此在测试模式 1 的首选项之前,我必须切换到模式 1。当测试开始时切换处于模式 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测试模式 1 的偏好。
WebUI.verifyElementNotHasAttribute()
- flow control 还有另一个参数。
您需要设置 FailureHandling.OPTIONAL
以便测试继续执行,即使函数 returns 为 false。然后就可以把"else"部分写成相应的逻辑了。
在我的测试用例中,我决定是否要切换我的单选按钮。我检查我的单选按钮是否没有 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
(处于我希望的状态)时,我的测试用例失败了。我如何才能让它不失败,而是执行剩余的测试?
简单来说,我有一个可以在两种模式之间切换的开关,我们称它们为模式 1 和模式 2。此特定测试测试模式 1 的首选项,因此在测试模式 1 的首选项之前,我必须切换到模式 1。当测试开始时切换处于模式 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测试模式 1 的偏好。
WebUI.verifyElementNotHasAttribute()
- flow control 还有另一个参数。
您需要设置 FailureHandling.OPTIONAL
以便测试继续执行,即使函数 returns 为 false。然后就可以把"else"部分写成相应的逻辑了。