gpt4 book ai didi

java - 如何将文本值存入数组?

转载 作者:行者123 更新时间:2023-11-30 01:46:35 24 4
gpt4 key购买 nike

我有一组价格值,下面的脚本正在生成一组我需要比较的值集。我的 Katalon-studio 脚本如下(测试用例和关键字),如何将这些值获取到数组/列表,请帮忙。

测试用例

for(int i=1; i<=9; i++){    
CustomKeywords.'decypha_equities.public_equities_selctor.navigatetoMainequitiesid'(Integer.toString(i))
}

关键字

public class public_equities_selctor {

private String market_selector_selector(String navid){
return '//*[@id="exchange_'+ navid +'"]/div[2]';
}

private TestObject getequitiesid(String navid){
TestObject equitiesitem = new TestObject(navid);
equitiesitem.addProperty("xpath", ConditionType.EQUALS,market_selector_selector(navid),true);
return equitiesitem
}

@Keyword
public void navigatetoMainequitiesid(String navid){
TestObject equitiesitem = getequitiesid(navid);
WebUI.waitForElementPresent(equitiesitem,GlobalVariable.time_1)
String abc = WebUI.getText(equitiesitem)
}

实际14,304 ,1,529 ,。.

预计到数组列表中,这样我就可以将它们与现有的数组列表进行比较

我的控制台

2019-08-30 10:31:54.220 DEBUG testcase.public_equities_comparison      - 1: decypha_equities.public_equities_selctor.navigatetoMainequitiesid(Integer.toString(i))
8,566 (0.45%)
2019-08-30 10:31:54.424 INFO k.k.c.m.CustomKeywordDelegatingMetaClass - decypha_equities.public_equities_selctor.navigatetoMainequitiesid is PASSED
2019-08-30 10:31:54.424 DEBUG testcase.public_equities_comparison - 1: decypha_equities.public_equities_selctor.navigatetoMainequitiesid(Integer.toString(i))
3,869 (0.16%)
2019-08-30 10:31:54.482 INFO k.k.c.m.CustomKeywordDelegatingMetaClass - decypha_equities.public_equities_selctor.navigatetoMainequitiesid is PASSED
2019-08-30 10:31:54.482 DEBUG testcase.public_equities_comparison - 1: decypha_equities.public_equities_selctor.navigatetoMainequitiesid(Integer.toString(i))
6,606 (0.51%)
2019-08-30 10:31:54.581 INFO k.k.c.m.CustomKeywordDelegatingMetaClass - decypha_equities.public_equities_selctor.navigatetoMainequitiesid is PASSED
2019-08-30 10:31:54.581 DEBUG testcase.public_equities_comparison - 1: decypha_equities.public_equities_selctor.navigatetoMainequitiesid(Integer.toString(i))
9,806 (0.24%)
2019-08-30 10:31:54.662 INFO k.k.c.m.CustomKeywordDelegatingMetaClass - decypha_equities.public_equities_selctor.navigatetoMainequitiesid is PASSED
2019-08-30 10:31:54.662 DEBUG testcase.public_equities_comparison - 1: decypha_equities.public_equities_selctor.navigatetoMainequitiesid(Integer.toString(i))
2,791 (-0.22%)
2019-08-30 10:31:54.728 INFO k.k.c.m.CustomKeywordDelegatingMetaClass - decypha_equities.public_equities_selctor.navigatetoMainequitiesid is PASSED
2019-08-30 10:31:54.728 DEBUG testcase.public_equities_comparison - 1: decypha_equities.public_equities_selctor.navigatetoMainequitiesid(Integer.toString(i))
14,304 (-0.66%)
2019-08-30 10:31:54.794 INFO k.k.c.m.CustomKeywordDelegatingMetaClass - decypha_equities.public_equities_selctor.navigatetoMainequitiesid is PASSED
2019-08-30 10:31:54.795 DEBUG testcase.public_equities_comparison - 1: decypha_equities.public_equities_selctor.navigatetoMainequitiesid(Integer.toString(i))
1,529 (-0.07%)
2019-08-30 10:31:54.862 INFO k.k.c.m.CustomKeywordDelegatingMetaClass - decypha_equities.public_equities_selctor.navigatetoMainequitiesid is PASSED
2019-08-30 10:31:54.862 DEBUG testcase.public_equities_comparison - 1: decypha_equities.public_equities_selctor.navigatetoMainequitiesid(Integer.toString(i))
1,847 (-0.85%)
2019-08-30 10:31:54.914 INFO k.k.c.m.CustomKeywordDelegatingMetaClass - decypha_equities.public_equities_selctor.navigatetoMainequitiesid is PASSED
2019-08-30 10:31:54.914 DEBUG testcase.public_equities_comparison - 1: decypha_equities.public_equities_selctor.navigatetoMainequitiesid(Integer.toString(i))
5,028 (-0.23%)
2019-08-30 10:31:54.969 INFO k.k.c.m.CustomKeywordDelegatingMetaClass - decypha_equities.public_equities_selctor.navigatetoMainequitiesid is PASSED
2019-08-30 10:31:54.970 INFO c.k.katalon.core.main.TestCaseExecutor - END Test Cases/PUBLIC EQUITIES/public_equities_comparison


最佳答案

首先,声明一个空数组:

def myArray = []

然后编辑 for 循环,将自定义关键字的返回结果添加到数组中:

for(int i=1; i<=9; i++){    
myArray << CustomKeywords.'decypha_equities.public_equities_selctor.navigatetoMainequitiesid'(Integer.toString(i))
}

并在 navigatetoMainequitiesid() 方法的末尾添加一条 return 语句并更改返回类型:

    @Keyword
public String navigatetoMainequitiesid(String navid){
TestObject equitiesitem = getequitiesid(navid);
WebUI.waitForElementPresent(equitiesitem,GlobalVariable.time_1)
String abc = WebUI.getText(equitiesitem)
return abc
}

关于java - 如何将文本值存入数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57720979/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com