// 获得下一节点信息 public void getNext() { try { List<WebElement> nextRadios = dr.findElements( By.xpath( "//TD[contains(text(),'选择处理路径')]/following-sibling::*//INPUT[@type='radio']")); for (WebElement w : nextRadios) { System.out.println("nextRadios----" + w.getAttribute("id")); } List<WebElement> nextPaths = dr.findElements(By.xpath("//TD[contains(text(),'选择处理路径')]/following-sibling::*//LABEL")); for (WebElement w : nextPaths) { System.out.println("nextPaths----" + w.getText()); } // List<WebElement> nextCheckboxes = dr.findElements(By // .cssSelector("input[type=checkbox]")); // 有可能是Checkbox或者是radio List<WebElement> nextCheckboxes = dr.findElements(By.xpath("//TD[contains(text(),'下一步处理人')]/following-sibling::*//INPUT")); for (WebElement w : nextCheckboxes) { System.out.println("nextCheckboxes----" + w.getAttribute("id")); } List<WebElement> nextPersons = dr.findElements(By.xpath("//TD[contains(text(),'下一步处理人')]/following-sibling::*//LABEL")); for (WebElement w : nextPersons) { System.out.println("nextPersons----" + w.getText()); } int i = 0; String nextPath = ""; for (WebElement w : nextRadios) { // 获得处理路径 if (w.isSelected()) { nextPath = nextPaths.get(i).getText(); String regEx = "会签"; // 判断是否会签 Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(nextPath); apl.setCountersign(m.find()); // 设置会签标志 regEx = "结束"; // 判断流程结束 p = Pattern.compile(regEx); m = p.matcher(nextPath); this.quitFlowFlag = m.find(); // 设置流程结束标志 regEx = "项目经理"; // 判断流程结束 p = Pattern.compile(regEx); m = p.matcher(nextPath); if (m.find()) { // 设置流程结束标志 apl.setRole("proManger"); } break; } i++; } int j = 0; String[] nextPersonSelected = new String[nextPersons.size()]; for (WebElement w : nextCheckboxes) { // 获得下一步处理人 if (w.isSelected()) { nextPersonSelected[j] = nextPersons.get(j).getText(); } j++; } String nextNode = nextPersonSelected[0]; // 先选择一个测试 System.out.println("nextNode------" + nextNode); String nextName = ""; if (apl.getIsCountersign()) { // 如果是会签,字段要截取 nextName = nextNode.substring(nextNode.indexOf('(') + 1, nextNode.indexOf(')')); } else { nextName = nextNode; } System.out.println("nextName------" + nextName); Map<String, String> map = StaticProvider.getLoginName(nextName); String loginName = map.get("LOGINNAME").toString(); System.out.println("loginName-------" + loginName); apl.setLoginName(loginName); // 设置登录名 } catch (Exception e) { e.printStackTrace(); } }