我添加了这个来创建一个随机组名,现在我想验证这个组名是否存在:public String generateRandomName(int length) { char[] chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" .toCharArray(); StringBuilder sb = new StringBuilder(); Random random = new Random(); for (int i = 0; i < length; i++) { char c = chars[random.nextInt(chars.length)]; sb.append(c); } String randomString = sb.toString(); return randomString;}这是我的while循环:public boolean validateGroupNameIsCorrect(String groupName) { int i = 1; WebElement NewGroupText = driver.findElement(By.xpath("//*[@id='content']/form/span["+ i + "]")); while (true) { if (getNewGroupText().getText().equals(groupName)); return true; System.out.println(i); }}
添加回答
举报
0/150
提交
取消