簡體   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