//获取元素列表public List<WebElement> ListElements(WebElement webElement, By parentBy, By childrenBy) { //定义一个list集合存储全部的元素列表参数 List<WebElement> elements = new ArrayList<WebElement>(); int statusNum=0; By[] elementBys = {parentBy, childrenBy}; if (webElement != null) { for (int i = 0; i < elementBys.length; i++) { if (elementBys[i] != null) { statusNum=i+1; }else { continue; } } } else { System.out.println("传输元素为空"); } switch (statusNum) { case 0: System.out.println("输入数据有误"); break; case 1: elements = webElement.findElements(parentBy); break; case 2: elements = driver.findElement(parentBy).findElements(childrenBy); break; } return elements;}