private void testNewInstructorLink() {
    ______TS("add new instructor link");
    assertTrue(courseEditPage.clickShowNewInstructorFormButton());

    assertTrue(courseEditPage.clickOnNewInstructorAccessLevelViewDetails("Co-owner"));
    assertTrue(courseEditPage.clickOnNewInstructorAccessLevelViewDetails("Manager"));
    assertTrue(courseEditPage.clickOnNewInstructorAccessLevelViewDetails("Observer"));
    assertTrue(courseEditPage.clickOnNewInstructorAccessLevelViewDetails("Tutor"));
  }
  private void testInputValidation() {

    ______TS("Checking max-length enforcement by the text boxes");

    String maxLengthInstructorName =
        StringHelper.generateStringOfLength(FieldValidator.PERSON_NAME_MAX_LENGTH);
    String longInstructorName =
        StringHelper.generateStringOfLength(FieldValidator.PERSON_NAME_MAX_LENGTH + 1);

    courseEditPage.clickEditInstructorLink(1);
    courseEditPage.clickShowNewInstructorFormButton();

    // Add instructor
    assertEquals(
        maxLengthInstructorName, courseEditPage.fillNewInstructorName(maxLengthInstructorName));
    assertEquals(
        longInstructorName.substring(0, FieldValidator.PERSON_NAME_MAX_LENGTH),
        courseEditPage.fillNewInstructorName(longInstructorName));
    // Edit instructor
    assertEquals(
        maxLengthInstructorName, courseEditPage.editInstructorName(1, maxLengthInstructorName));
    assertEquals(
        longInstructorName.substring(0, FieldValidator.PERSON_NAME_MAX_LENGTH),
        courseEditPage.editInstructorName(1, longInstructorName));

    String maxLengthEmail = StringHelper.generateStringOfLength(FieldValidator.EMAIL_MAX_LENGTH);
    String longEmail = StringHelper.generateStringOfLength(FieldValidator.EMAIL_MAX_LENGTH + 1);

    // Add instructor
    assertEquals(maxLengthEmail, courseEditPage.fillNewInstructorEmail(maxLengthEmail));
    assertEquals(
        longEmail.substring(0, FieldValidator.EMAIL_MAX_LENGTH),
        courseEditPage.fillNewInstructorEmail(longEmail));
    // Edit instructor
    assertEquals(maxLengthEmail, courseEditPage.editInstructorEmail(1, maxLengthEmail));
    assertEquals(
        longEmail.substring(0, FieldValidator.EMAIL_MAX_LENGTH),
        courseEditPage.editInstructorEmail(1, longEmail));
  }
  private void testNewInstructorLink() {
    courseEditPage = getCourseEditPage();

    ______TS("add new instructor link");
    assertEquals(true, courseEditPage.clickShowNewInstructorFormButton());
  }
  private void testAddInstructorAction() throws Exception {

    ______TS("success: add an instructor with privileges");

    courseEditPage.clickShowNewInstructorFormButton();
    courseEditPage.fillNewInstructorName("Teammates Instructor");
    courseEditPage.fillNewInstructorEmail("*****@*****.**");

    int newInstructorIndex = 8;

    courseEditPage.selectRoleForInstructor(newInstructorIndex, "Custom");
    courseEditPage.clickCourseLevelPrivilegesLink(
        newInstructorIndex, InstructorCourseEditPage.COURSE_MODIFY_COURSE);
    courseEditPage.clickCourseLevelPrivilegesLink(
        newInstructorIndex, InstructorCourseEditPage.COURSE_MODIFY_STUDENTS);
    courseEditPage.clickCourseLevelPrivilegesLink(
        newInstructorIndex, InstructorCourseEditPage.COURSE_MODIFY_OTHERS_COMMENTS);

    courseEditPage.clickAddSectionLevelPrivilegesLink(newInstructorIndex);
    courseEditPage.clickSectionSelectionCheckBox(newInstructorIndex, 0, 1);
    courseEditPage.clickSectionLevelPrivilegeLink(
        newInstructorIndex, 0, InstructorCourseEditPage.SECTION_VIEW_STUDENTS);
    courseEditPage.clickSectionLevelPrivilegeLink(
        newInstructorIndex, 0, InstructorCourseEditPage.SECTION_VIEW_RESPONSES_IN_SESSION);

    courseEditPage.clickAddInstructorButton();

    courseEditPage.verifyStatus(
        String.format(
            Const.StatusMessages.COURSE_INSTRUCTOR_ADDED,
            "Teammates Instructor",
            "*****@*****.**"));

    AppUrl courseDetailsLink =
        createUrl(Const.ActionURIs.INSTRUCTOR_COURSE_DETAILS_PAGE)
            .withCourseId(courseId)
            .withUserId(testData.instructors.get("InsCrsEdit.test").googleId);

    InstructorCourseDetailsPage courseDetailsPage =
        AppPage.getNewPageInstance(browser, courseDetailsLink, InstructorCourseDetailsPage.class);
    courseDetailsPage.verifyHtmlPart(
        By.id("instructors"), "/instructorCourseDetailsAddInstructor.html");
    courseEditPage = getCourseEditPage();
    courseEditPage.clickEditInstructorLink(3);
    courseEditPage.verifyHtmlMainContent("/instructorCourseEditAddInstructor.html");

    ______TS("failure: add an existing instructor");

    courseEditPage.addNewInstructor("Teammates Instructor", "*****@*****.**");
    courseEditPage.verifyStatus(Const.StatusMessages.COURSE_INSTRUCTOR_EXISTS);

    ______TS("failure: add an instructor with an invalid parameter");

    String invalidEmail = "InsCrsEdit.email.tmt";

    courseEditPage.addNewInstructor("Teammates Instructor", invalidEmail);
    courseEditPage.verifyStatus(new FieldValidator().getInvalidityInfoForEmail(invalidEmail));

    String invalidName = "";

    courseEditPage.addNewInstructor(invalidName, "*****@*****.**");
    courseEditPage.verifyStatus(new FieldValidator().getInvalidityInfoForPersonName(invalidName));
  }