无法在Java中选择随机值

时间:2014-04-04 11:11:07

标签: java

我编写的代码如下: 我试过的代码如下:

@Test()
public void FilterMatching() throws Exception{

Properties properties = new Properties();
properties.load(new FileReader("C:\\FilterSection\\dropdown.properties"));
ArrayList<String> expectedDropDownItems = new ArrayList<String>();
Collections.shuffle(expectedDropDownItems);
List<String> randomFive = new ArrayList<String>();
for (int i=0; i<5; i++) {
   if (i < expectedDropDownItems.size()) {
       randomFive.add((String) expectedDropDownItems.get(i));
   }
}
Log.info("1. Verifying the Visualization drop down values are matching in both property file and UI");
String[] expectedDropDownItemsInArray =  properties.getProperty("visualizationId").trim().split(",");

Random r = new Random();
for(int i=expectedDropDownItemsInArray.length;i>0;i--){
   int index = r.nextInt(i);
   String temp = expectedDropDownItemsInArray[i];
   expectedDropDownItemsInArray[i] = expectedDropDownItemsInArray[index];
   expectedDropDownItemsInArray[index] = temp;
}

for(int i=0; i<expectedDropDownItemsInArray.length; i++)
    expectedDropDownItems.add(expectedDropDownItemsInArray[i]);
Thread.sleep(6000);

}

情况是

  1. 转到属性文件
  2. 存储属性文件
  3. 中每个下拉列表的值
  4. 或者从属性文件
  5. 中选择每个密钥对值中的任意5个随机值
  6. 来到FE并验证值是否存在于逐个下拉中(在第一种意义上,从属性获取一组值并在完成下一步后检查类似的下拉)
  7. 任何人都可以帮我解决这个问题

0 个答案:

没有答案