【问题标题】:How to skip a test case in Katalon Studio如何在 Katalon Studio 中跳过测试用例
【发布时间】:2021-04-11 02:53:06
【问题描述】:

我们如何在 Katalon Studio 中跳过特定的测试用例?

对于我的应用程序,不同的站点具有不同的要求,因此所有功能不会出现在所有站点中。我想让脚本保持动态,所以如果找不到几个链接,我希望脚本跳过一些测试用例。

 @Keyword
        def ClickonLinkText(String text) {
            try {
                WebDriver webDriver = DriverFactory.getWebDriver()
                KeywordUtil.logInfo("Clicking Link text")
                if(webDriver.findElement(By.linkText(text)).click()){
                KeywordUtil.logInfo("found")
            }else{
                KeywordUtil.logInfo("Not found")
// Need to skip the test case if not found!!
            }
                KeywordUtil.markPassed("Clicked on link text successfully")
            } catch (WebElementNotFoundException e) {
                KeywordUtil.markFailed("Link text not found")
            } catch (Exception e) {
                KeywordUtil.markFailed("Fail to click on the Link text")
            }
        }

【问题讨论】:

    标签: groovy automated-tests testcase katalon-studio skip


    【解决方案1】:

    您可以为该用例使用测试侦听器:

    1. 在测试资源管理器中,右键单击测试侦听器 > 新建 > 新建测试侦听器
    2. 在对话框中,为您的测试用例命名(在我的示例中为“ExampleListener”),并选中“Generate Sample Before Test Case Method”
    3. 检查所需条件,如果为真则跳过测试用例:
    class ExampleListener {
        /**
         * Executes before every test case starts.
         * @param testCaseContext related information of the executed test case.
         */
        @BeforeTestCase
        def sampleBeforeTestCase(TestCaseContext testCaseContext) {
            if(condition){
                testCaseContext.skipThisTestCase()
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2019-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多