无法将列表<Integer>输出获取到 Katalon 测试用例



我一直在努力将 Arraylist 输出列表获取到 Testcase

这是我的代码(关键字(:

@Keyword
public List<Integer> othersites() {
String[] sits = new String[9];
sits[0] = "https://www.tadawul.com.sa/wps/portal/tadawul/home/";
sits[1] = "https://www.msm.gov.om/";

WebUI.navigateToUrl(sits[0]);
String tdwl = WebUI.getText(findTestObject('Object Repository/Sites/site_tdwl'),FailureHandling.CONTINUE_ON_FAILURE)
String[] parts0 = tdwl.split("\.")
String part0 = parts0[0];
String part00 = Integer.parseInt(part0.replaceAll(",", ""))
//println part00

List<String> list = new ArrayList<String>();
list.add(part00);

List<Integer> newList1 = new ArrayList<Integer>(list.size()) ;
for (String myInt1 : list)
{
newList1.add(Integer.valueOf(myInt1));
}
return newList1
}

卡塔隆测试用例:

def newList1 = [];
newList1 << CustomKeywords.'decypha_equities.otherSiteValuesCapture.othersites'();
println newList1[0];

我可以获取整个 Arraylist,但我需要访问我的测试用例中的数组元素(而不是在关键字内(?

我的输出:

[8056, 3997, 6547, 10295, 2890, 14908, 1551, 1801, 5114]

othersites()方法返回整个列表。然后,您将结果分配给带有newList1 << CustomKeywords.'decypha_equities.otherSiteValuesCapture.othersites'();的新列表。

将测试用例更改为此

def newestList = CustomKeywords.'decypha_equities.otherSiteValuesCapture.othersites'();
println newestList[0];

以访问列表的第一个元素。

最新更新