def setUp(self): self.scl = Grade() self.id = self.scl.get_grade_id() self.th = Teacher() self.tcd = TClassDesc(browser()) self.phonenumber = self.th.create_phone_or_idcard("0") self.idcard = self.th.create_phone_or_idcard("1")
def get_grade(self): self.find_element(*self.view_task_desc).click() grade_eles = self.find_elements(*self.sum_grade_text) grade_lists = [] for one in grade_eles: grade_lists.append(one.text) return grade_lists def verify_grade(self, grade_lists, teacher_view_grade): for one in range(3): if grade_lists[one] not in teacher_view_grade: return False return True if "__main__" == __name__: mytask = SMyTask(browser()) mytask.goto_login() mytask.login("admin", "888888") mytask.goto_tab_page() mytask.do_homework() mytask.driver.refresh() grade_lists = mytask.get_grade() tp = TPublishHomework(browser()) tp.goto_login() tp.login("admin1", "888888") tp.goto_tab_page() print(mytask.verify_grade(grade_lists, tp.get_student_grade()))
def setUp(self): self.scl = Grade() self.id = self.scl.get_grade_id() self.st = Student() self.sed = SErrorDesc(browser()) self.phonenumber = self.st.create_phone("0")
from selenium.webdriver.common.by import By from pylib.mydriver import browser from pyuilib.TeacherHome import TeacherHome class TPublishHomework(TeacherHome): # 查看学生作业情况 view_student_grade = (By.XPATH, "//a[@ng-click='trackTask(task)']") grade_desc = (By.CSS_SELECTOR, "p[ng-if='taskTrack.summary']") def goto_tab_page(self): self.find_element(*self.exist_publish_homework).click() def get_student_grade(self): self.find_elements(*self.view_student_grade)[0].click() sleep(3) grade_text = self.find_element(*self.grade_desc).text return grade_text if "__main__" == __name__: tp = TPublishHomework(browser()) tp.goto_login() tp.login("admin1", "888888") tp.goto_tab_page() print(tp.get_student_grade())
# self.driver.switch_to.default_content() # sleep(1) # 发布作业 # self.find_element(*self.publish_submit_button).click() # sleep(1) # # 新窗口页面发布 # window_handle = self.driver.current_window_handle # self.find_element(*self.give_student_homework).click() # sleep(3) # handles = self.driver.window_handles # for one in handles: # if one != window_handle: # self.driver.switch_to.window(one) # # 选择发布的学生,发布作业 # self.find_element(*self.select_student_checkbox).click() # self.find_element(*self.submit_button_success).click() # self.find_element(*self.publish_submit_success).click() if "__main__" == __name__: # browser().switch_to.window() th = TeacherHome(browser()) th.goto_login() th.login("admin1",888888) th.publish_work(3) # print(th.get_course_info()) # print(th.get_list_info()) # th.goto_class_student() # print(th.get_student_list())
# 跳转至老师登录页面 def goto_login(self): pass # self.open() # self.find_element(*self.teacher_login_button).click() # sleep(1) # assert self.driver.current_url == "http://ci.ytesting.com/teacher/login/login.html" , "goto teacher login page fail" # 跳转至学生登录页面 # def goto_student_login(self): # self.open() # self.find_element(*self.student_login_button).click() # sleep(1) # assert self.driver.current_url == "http://ci.ytesting.com/student/login/login.html" , "goto student login page fail" # 登录操作 def login(self, username, password): if username: self.find_element(*self.username_input).send_keys(username) if password: self.find_element(*self.password_input).send_keys(password) self.find_element(*self.submit_button).click() if "__main__" == __name__: login = LoginPage(browser()) login.goto_login() login.login("admin", "888888")
# 选择发布的学生,发布作业 self.find_element(*self.select_student_checkbox).click() self.find_element(*self.submit_button_success).click() self.find_element(*self.publish_submit_success).click() # 验证作业发布成功 def verify_publish_homework(self): pub_bool = self.find_element(*self.verify_publish_success).text return pub_bool # 创建并发布作业 def create_and_publish_homework(self): self.goto_tab_page() sleep(1) self.open_publish_homework() sleep(1) self.select_publish_homework(3) sleep(1) self.publish_homework() if "__main__" == __name__: thomework = THomework(browser()) thomework.goto_login() thomework.login("admin1", 888888) thomework.goto_tab_page() thomework.create_and_publish_homework() if "作业已发布给学生" in thomework.verify_publish_homework(): print("pass")
return classes # 跳转至对应导航页 def goto_tab_page(self): pass # 完成作业 def do_homework(self): self.find_element(*self.cat_notic_button).click() self.find_element(*self.homework_select).click() self.find_element(*self.goto_homework).click() answer = self.find_elements(*self.select_answer) for one in answer: one.click() self.find_element(*self.submit_homework).click() sleep(1) self.find_element(*self.homework_last).click() if "__main__" == __name__: th = StudentHome(browser()) th.goto_login() th.login("admin", 888888) th.do_homework() # print(th.get_student_list_infos()) # print(th.get_student_classes()) # print(th.get_error_question()) # th.goto_class_student() # print(th.get_student_list())
def setUp(self): self.thomework = THomework(browser()) self.mytask = SMyTask(browser()) self.tp = TPublishHomework(browser())