예제 #1
0
  // 走审批流程
  //	@Test(dependsOnMethods = { "apply" })
  public void doApproval() {
    try {
      while (!quitFlowFlag) {

        login(apl.getLoginName(), apl.getPassWord());
        doDaiban();
        dr.switchTo().defaultContent();
        dr.switchTo().frame(1);

        if (apl.getRole().equals("proManger")) {
          doProManger();
          login("baoj_lz", "1");
          locate();
          //					return;
        } else {
          // 提交下一步
          ((JavascriptExecutor) dr).executeScript("isAuditOperate = true;dosubmit()");
          Thread.sleep(1000);
          getNext(); // 获得提交下一处理信息
          confirmNext();
          logout();
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
예제 #2
0
  public Approval toApproval(CRApproval crApproval) {
    if (crApproval == null) return Approval.automaticApproval();

    Approval approval;
    if (crApproval.getType() == CRApprovalCondition.manual) approval = Approval.manualApproval();
    else approval = Approval.automaticApproval();

    AuthConfig authConfig = approval.getAuthConfig();
    for (String user : crApproval.getAuthorizedUsers()) {
      authConfig.add(new AdminUser(new CaseInsensitiveString(user)));
    }
    for (String user : crApproval.getAuthorizedRoles()) {
      authConfig.add(new AdminRole(new CaseInsensitiveString(user)));
    }

    return approval;
  }
예제 #3
0
 // 进入待办
 public void doDaiban() {
   try {
     dr.switchTo().defaultContent();
     dr.switchTo().frame(0);
     dr.findElement(
             By.xpath("//div[@id='blockdivOne1']//a[contains(@title,'" + apl.getProName() + "')]"))
         .click();
     Thread.sleep(1000);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
예제 #4
0
  @Test(
      dependsOnMethods = {"locate"},
      dataProvider = "dp",
      dataProviderClass = StaticProvider.class)
  public void apply(Map<String, String> map) {
    // 切换frame
    try {

      dr.switchTo().frame(1);

      // 调用JS
      ((JavascriptExecutor) dr).executeScript("chooseProject()");

      // 切换frame
      dr.switchTo().frame("fraChoosePrj");

      // 复选框处理
      dr.findElement(By.xpath("//img[contains(@src,'item_chk0')][1]")).click();

      // 切换frame
      dr.switchTo().defaultContent();
      dr.switchTo().frame(1);

      // 调用JS
      // ((JavascriptExecutor)dr).executeScript("dochooseProj()");
      dr.findElement(By.xpath("//*[contains(text(),'确定')]")).click();

      dr.findElement(By.id("BO_REGISTERAPPLICATION_NAME"))
          .sendKeys(map.get("BO_REGISTERAPPLICATION_NAME"));
      dr.findElement(By.id("APPLICATION_INVEST")).sendKeys(map.get("APPLICATION_INVEST"));
      // dr.findElement(By.id("COMPLETION_DATE")).sendKeys(map.get("COMPLETION_DATE"));

      SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
      Date dt = new Date();
      dr.findElement(By.id("COMPLETION_DATE")).sendKeys(df.format(dt));

      System.out.println(map.get("COMPLETION_DATE").toString());
      dr.findElement(By.id("PROJECT_BACKGROUND")).sendKeys(map.get("PROJECT_BACKGROUND"));
      dr.findElement(By.id("BUILD_CONTENT1")).sendKeys(map.get("BUILD_CONTENT1"));
      dr.findElement(By.id("PROJECT_COST")).sendKeys(map.get("PROJECT_COST"));
      dr.findElement(By.id("PROJECT_AMOUNT")).sendKeys(map.get("PROJECT_AMOUNT"));
      dr.findElement(By.id("INVEST_NUM")).sendKeys(map.get("INVEST_NUM"));
      dr.findElement(By.id("PROJECT_COUNT")).sendKeys(map.get("PROJECT_COUNT"));
      dr.findElement(By.id("DIRECT_INCOME")).sendKeys(map.get("DIRECT_INCOME"));
      dr.findElement(By.id("INDIRECT_INCOME")).sendKeys(map.get("INDIRECT_INCOME"));

      apl.setProName(map.get("BO_REGISTERAPPLICATION_NAME")); // 设置项目名称

      // 提交下一步
      ((JavascriptExecutor) dr).executeScript("dosubmit()");
      Thread.sleep(1000);

      getNext(); // 获得提交下一处理信息
      //
      confirmNext(); // 确认提交
      Thread.sleep(1000);
      logout();
      System.out.println("立项申请编辑完成-------");

      doApproval();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
예제 #5
0
  // 获得下一节点信息
  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();
    }
  }