Example #1
0
    def reserve(self, event, driver, msg):
        if not ut.search(event.user.username, driver, msg):
            return False

        id_profile = ut.find_css_selector_element(driver, '#id_teacher_0 a',
                                                  msg)
        if id_profile is None:
            return False
        id_profile.click()

        i = 0
        id_reserve = None
        while True:
            id_event = ut.find_element_id(driver, 'id_meeting_' + str(i), msg)
            if id_event is None:
                msg.pop()
                break
            source = id_event.text
            if event.date in source and event.begin_time in source and event.end_time in source and str(
                    event.capacity) in source:
                id_reserve = ut.find_element_id(id_event, 'id_reserve_meeting',
                                                msg)
                if id_reserve is None:
                    return False
                break
            i += 1
        if id_reserve is None:
            msg.append('meeting not found')
            return False
        id_reserve.click()
        return True
Example #2
0
    def delete(self, driver, msg, logout_login=True):
        if logout_login:
            self.user.logout(driver, msg)
            if not self.user.login(driver, msg):
                return False
        id_profile = ut.find_element_id(driver, 'id_navbar_profile', msg)
        if id_profile is None:
            return False
        id_profile.click()

        i = 0
        id_change = None
        while True:
            id_event = ut.find_element_id(driver, 'id_meeting_' + str(i), msg)
            if id_event is None:
                break
            source = id_event.text
            if self.date in source and self.begin_time in source and self.end_time in source and str(
                    self.capacity) in source:
                id_change = ut.find_element_id(id_event, 'id_edit_meeting',
                                               msg)
                if id_change is None:
                    return False
                break
            i += 1
        if id_change is None:
            return False
        id_change.click()
        id_remove = ut.find_element_id(driver, 'id_remove_meeting', msg)
        if id_remove is None:
            return False
        id_remove.click()
        return True
Example #3
0
 def login(self, driver, msg):
     navbar_login = ut.find_element_id(driver, "id_navbar_login", msg)
     if navbar_login is None:
         return False
     navbar_login.click()
     id_username = ut.find_element_id(driver, "id_username", msg)
     id_password = ut.find_element_id(driver, "id_password", msg)
     if id_username is None or id_password is None:
         return False
     id_username.send_keys(self.username)
     id_password.send_keys(self.password)
     login_submit = ut.find_element_id(driver, "id_submit", msg)
     if login_submit is None:
         return False
     login_submit.click()
     return True
Example #4
0
    def save(self, driver, msg, logout_login=True):
        if logout_login:
            self.user.logout(driver, msg)
            if not self.user.login(driver, msg):
                return False
        id_profile = ut.find_element_id(driver, 'id_navbar_profile', msg)
        if id_profile is None:
            return False
        id_profile.click()

        i = 0
        id_change = None
        while True:
            id_event = ut.find_element_id(driver, 'id_meeting_' + str(i), msg)
            if id_event is None:
                msg.pop()
                break
            source = id_event.text
            # print(source)
            # print(self.old.date)
            # print(self.old.begin_time)
            # print(self.old.end_time)
            # print(self.old.capacity)
            if self.old.date in source and self.old.begin_time in source and self.old.end_time in source and str(
                    self.old.capacity) in source:
                id_change = ut.find_element_id(id_event, 'id_edit_meeting',
                                               msg)
                if id_change is None:
                    return False
                break
            i += 1
        if id_change is None:
            return False
        id_change.click()
        id_date = ut.find_element_id(driver, "id_date", msg)
        id_begin_time = ut.find_element_id(driver, "id_start", msg)
        id_end_time = ut.find_element_id(driver, "id_end", msg)
        id_capacity = ut.find_element_id(driver, "id_student_capacity", msg)
        if id_begin_time is None or id_capacity is None or id_date is None or id_end_time is None:
            return False
        id_end_time.clear()
        id_end_time.send_keys(self.end_time)
        id_date.clear()
        id_date.send_keys(self.date)
        id_begin_time.clear()
        id_begin_time.send_keys(self.begin_time)
        id_capacity.clear()
        id_capacity.send_keys(self.capacity)

        id_submit = ut.find_element_id(driver, "id_submit", msg)
        if id_submit is None:
            return False
        id_submit.click()
        return True
Example #5
0
 def anti_reserve(self, event, driver, msg):
     if not self.go_to_profile(driver, msg):
         return False
     i = 0
     while True:
         id_res = ut.find_element_id(driver,
                                     'id_reserved_meeting_' + str(i), msg)
         if id_res is None:
             msg.pop()
             break
         source = id_res.text
         if event.user.first_name in source and event.user.last_name in source and event.date in source and event.begin_time in source and event.end_time in source:
             id_res = ut.find_element_id(driver, "id_cancel_meeting", msg)
             if id_res is None:
                 return False
             id_res.click()
             return True
         i += 1
     return False
Example #6
0
    def create(self, driver, msg, logout_login=True):
        if logout_login:
            if not self.user.logout(driver, msg):
                msg.pop()
            if not self.user.login(driver, msg):
                return False
        create_link = ut.find_element_id(driver, "id_navbar_meeting", msg)
        if create_link is None:
            return False
        create_link.click()
        id_date = ut.find_element_id(driver, "id_date", msg)
        id_begin_time = ut.find_element_id(driver, "id_start", msg)
        id_end_time = ut.find_element_id(driver, "id_end", msg)
        id_capacity = ut.find_element_id(driver, "id_student_capacity", msg)
        if id_begin_time is None or id_capacity is None or id_date is None or id_end_time is None:
            return False
        id_end_time.send_keys(self.end_time)
        id_date.send_keys(self.date)
        id_begin_time.send_keys(self.begin_time)
        id_capacity.send_keys(self.capacity)

        id_submit = ut.find_element_id(driver, "id_submit", msg)
        if id_submit is None:
            return False
        id_submit.click()
        return True
Example #7
0
 def go_to_profile(self, driver, msg):
     navbar_profile = ut.find_element_id(driver, "id_navbar_profile", msg)
     if navbar_profile is None:
         return False
     navbar_profile.click()
     return True
Example #8
0
 def logout(self, driver, msg):
     navbar_logout = ut.find_element_id(driver, "id_navbar_logout", msg)
     if navbar_logout is None:
         return False
     navbar_logout.click()
     return True
Example #9
0
 def signup(self,
            driver,
            msg,
            send_mismatched_password=False,
            send_type=True):
     ut.find_element_id(driver, "id_navbar_signup", msg).click()
     id_first_name = ut.find_element_id(driver, "id_first_name", msg)
     id_last_name = ut.find_element_id(driver, "id_last_name", msg)
     id_username = ut.find_element_id(driver, "id_username", msg)
     id_email = ut.find_element_id(driver, "id_email", msg)
     id_password1 = ut.find_element_id(driver, "id_password1", msg)
     id_password2 = ut.find_element_id(driver, "id_password2", msg)
     id_type_student = ut.find_element_id(driver, "id_type_0", msg)
     id_type_teacher = ut.find_element_id(driver, "id_type_1", msg)
     if id_first_name is None or id_last_name is None or id_username is None \
             or id_email is None or id_password1 is None or id_password2 is None:
         msg.append("cant signup")
         return False
     id_first_name.send_keys(self.first_name)
     id_last_name.send_keys(self.last_name)
     id_username.send_keys(self.username)
     id_email.send_keys(self.email)
     id_password1.send_keys(self.password)
     if send_mismatched_password:
         id_password2.send_keys(self.password + ut.random_string(10))
     else:
         id_password2.send_keys(self.password)
     if send_type:
         if id_type_teacher is None or id_type_student is None:
             msg.append("user type not found")
             return False
     else:
         if id_type_teacher is None:
             msg.pop()
         if id_type_student is None:
             msg.pop()
     if id_type_teacher is not None and id_type_student is not None:
         if self.is_student:
             id_type_student.click()
         else:
             id_type_teacher.click()
     signup_submit = ut.find_element_id(driver, "id_submit", msg)
     if signup_submit is None:
         return False
     signup_submit.click()
     return True