/**
   * 编辑病例
   *
   * @param age
   * @return
   */
  public static String editCase(String age) {
    WebElement eEditBtn = driver.findElement(By.id(edit_case_btn));
    eEditBtn.click();

    WebElement eAgeYear = driver.findElement(By.id(age_year_input));
    eAgeYear.clear();
    eAgeYear.sendKeys(age);

    boolean flag = Utils.swipe(driver, By.id(pub_case), 2);
    if (flag) {
      WebElement eEditCase = driver.findElement(By.id(pub_case));
      eEditCase.click();
    } else {
      Assertion.assertEquals(true, flag, "发布按钮未找到,请检查后再试!");
    }

    String terminalAge = "";
    boolean findCaseAge = Utils.isElementExist(driver, By.id(terminal_age));
    int num = 0;
    if (findCaseAge == false) {
      while (findCaseAge == false && num < 10) {
        findCaseAge = Utils.isElementExist(driver, By.id(terminal_age));
        System.out.println(num);
        if (findCaseAge) {
          terminalAge = Utils.getText(driver, By.id(terminal_age));
        } else {
          num++;
        }
      }
    } else {
      terminalAge = Utils.getText(driver, By.id(terminal_age));
    }

    return terminalAge;
  }
  /**
   * 删除病例
   *
   * @return
   */
  public static boolean deleteCase() {
    WebElement eEditBtn = driver.findElement(By.id(edit_case_btn));
    eEditBtn.click();

    Utils.sleep(5);
    boolean flag = Utils.swipe(driver, By.id(delete_case_btn), 5);
    if (flag) {
      WebElement eDeleteCase = driver.findElement(By.id(delete_case_btn));
      eDeleteCase.click();
    } else {
      Assertion.assertEquals(true, flag, "删除按钮未找到,请检查后再试!");
    }

    boolean deleteCaseContent = Utils.isElementExist(driver, By.id(delete_case_message));
    int num = 0;
    while (deleteCaseContent == false && num < 10) {
      System.out.println(num);
      deleteCaseContent = Utils.isElementExist(driver, By.id(delete_case_message));
      num++;
    }

    return deleteCaseContent;
  }
  /**
   * 发布病例,并根据终端页信息验证是否发布成功。
   *
   * @param case_title
   * @param age
   * @param main_suit
   * @param case_talk
   * @return
   */
  public static String pubCase(String case_title, String age, String main_suit, String case_talk) {
    WebElement ePubCaseBtn = driver.findElement(By.id(pub_case_btn));
    ePubCaseBtn.click();

    WebElement eSelectMajor = driver.findElement(By.id(select_major));
    eSelectMajor.click();

    WebElement eSelectMajorNext = driver.findElement(By.id(select_major_next));
    eSelectMajorNext.click();

    WebElement eCaseTitle = driver.findElement(By.id(case_title_input));
    eCaseTitle.sendKeys(case_title);

    WebElement eSelectWomen = driver.findElement(By.id(selcect_women));
    eSelectWomen.click();

    WebElement eAgeYear = driver.findElement(By.id(age_year_input));
    eAgeYear.sendKeys(age);

    WebElement eMainSuit = driver.findElement(By.id(main_suit_input));
    eMainSuit.clear();
    eMainSuit.sendKeys(main_suit);

    WebElement eCaseTalk = driver.findElement(By.id(case_talk_input));
    eCaseTalk.clear();
    eCaseTalk.sendKeys(case_talk);

    WebElement eLoadPic = driver.findElement(By.id(preoperative_pic));
    eLoadPic.click();

    WebElement eSelectPic1 = driver.findElement(By.xpath(SELECT_PIC1));
    eSelectPic1.click();

    WebElement eSelectPic2 = driver.findElement(By.xpath(SELECT_PIC2));
    eSelectPic2.click();

    WebElement eSelectPicNext = driver.findElement(By.id(SELECT_PIC_NEXT));
    eSelectPicNext.click();

    eSelectPicNext.click();

    boolean flag = Utils.swipe(driver, By.id(pub_case), 2);
    boolean ePubCaseAttribute;
    if (flag) {
      ePubCaseAttribute =
          Boolean.parseBoolean(driver.findElement(By.id(pub_case)).getAttribute("clickable"));
      if (ePubCaseAttribute) {
        WebElement ePubCase = driver.findElement(By.id(pub_case));
        ePubCase.click();
      } else {
        Assertion.assertEquals(true, ePubCaseAttribute, "未触发发布按钮,是置灰状态!");
      }
    } else {
      Assertion.assertEquals(true, flag, "发布按钮未找到,请检查后再试!");
    }

    String terminalCaseName = "";
    boolean findCaseTitle = Utils.isElementExist(driver, By.id(terminal_case_name));
    int num = 0;
    if (findCaseTitle == false) {
      while (findCaseTitle == false && num < 10) {
        findCaseTitle = Utils.isElementExist(driver, By.id(terminal_case_name));
        System.out.println(num);
        if (findCaseTitle) {
          terminalCaseName = Utils.getText(driver, By.id(terminal_case_name));
        } else {
          num++;
        }
      }
    } else {
      terminalCaseName = Utils.getText(driver, By.id(terminal_case_name));
    }

    return terminalCaseName;
  }