繁体   English   中英

我如何解决 Katalon 中的此错误 Groovy:unexpected token: do // Groovy:unexpected token: if // Groovy:expecting EOF, found 'if'

[英]How I can resolve this error in Katalon Groovy:unexpected token: do // Groovy:unexpected token: if // Groovy:expecting EOF, found 'if'

// Read data from XML file
public static String getElementTextByTagName(String tagName) {
    try {
        String dirPath = System.getProperty('user.dir') + "\\DataFiles\\TestData.xml"
        List<File> xmlFiles = getXMLFilesByDirectory(dirPath);
        Iterator var3 = xmlFiles.iterator();

        XMLSearchResult searchResult;
        do {
            if (!var3.hasNext()) {
                throw new ElementNotFoundInXMLException("Element Not Found");
            }

            File xmlFile = (File)var3.next();
            searchResult = searchForElementInsideFile(xmlFile, tagName);
        } while(!searchResult.isFound());

        return searchResult.getElementText();
    } catch (ElementNotFoundInXMLException var6) {
        var6.printStackTrace();
        return null;
    }
}

在此处输入图像描述

  • 错误出现在do 语句行if 语句的下方

Katalon Studio 使用版本 Groovy,在回答这个问题时,它支持 do-while 循环。

为此,您必须执行此问题中概述的操作。

我花时间在这里链接答案,而不是投票结束问题,因为它已经被另一个问题回答了,这是一种专业的礼貌。

欢迎来到 StackOverflow。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM