class HomePage(object): def __init__(self, driver): self.element = PySelenium(driver) # 点击选择校区按钮 def click_campus(self): self.element.js_click_element('Index', 'Campus') # 从下拉框中选择校区 def select_campus(self, campus_index): self.element.get_ul_li('Index', 'CampusList', campus_index)
def setUpClass(cls) -> None: # 初始化开始 LogInfo().log.info('Initialization Start') cls.driver = SelectBrowser().select_browser('chrome') cls.dr = PySelenium(cls.driver) cls.dr.test_url( ReadIni('Sys_config.ini', 'Base').get_value('website_url')) cls.dr.maximize_window() # 初始化开始 LogInfo().log.info('Initialization Completed') # 登录业务流程-测试用例 LogInfo().log.info('Login Cases Suite Start Running ') cls.login = LoginBusiness(cls.driver)
def setUpClass(cls) -> None: # 初始化开始 LogInfo().log.info('Initialization Start') cls.driver = SelectBrowser().select_browser('chrome') cls.dr = PySelenium(cls.driver) cls.dr.test_url( ReadIni('Sys_config.ini', 'Base').get_value('website_url')) cls.dr.maximize_window() # 初始化结束 LogInfo().log.info('Initialization Completed') # 前置条件:登录系统 LogInfo().log.info('Preposition: Login System') username = ReadIni('Sys_config.ini', 'Base').get_value('username') password = ReadIni('Sys_config.ini', 'Base').get_value('password') cls.login = LoginBusiness(cls.driver) cls.login.login_suc(username, password) # 选择校区 cls.campus_select = HomeBusiness(cls.driver) cls.campus_select.select_campus(4) cls.log.info('Campus Selected') # 员工管理业务流程 LogInfo().log.info('Account Cases Suite Start Running') cls.account = AccountBusiness(cls.driver) # 课程管理业务流程 LogInfo().log.info('Course Cases Suite Start Running') cls.course = CourseBusiness(cls.driver) # 班级管理业务流程 LogInfo().log.info('Class Cases Suite Start Running') cls.classroom = ClassBusiness(cls.driver) # 班级管理业务流程 LogInfo().log.info('Customer Cases Suite Start Running') cls.customer = CustomerBusiness(cls.driver)
class DemoPage(object): def __init__(self, driver): self.element = PySelenium(driver) # 输入关键字 def send_keywords(self, keywords): self.element.input_element('SearchInfo', 'search_input', keywords) # 点击提交信息 def click_submit(self): self.element.click_element('SearchInfo', 'submit') # 获取wording信息 def get_wording(self): return self.element.get_element_text('SearchInfo', 'nums_text') # 获取当前页面url def get_url(self): return self.element.get_current_url()
def __init__(self, driver): self.element = PySelenium(driver)
class LoginPage(object): def __init__(self, driver): self.element = PySelenium(driver) # 清空输入框 def clear_input(self): self.element.element_clear('Login', 'UserName') self.element.element_clear('Login', 'PassWord') # 输入用户名 def send_username(self, keywords): self.element.input_element('Login', 'UserName', keywords) # 输入密码 def send_password(self, keywords): self.element.input_element('Login', 'PassWord', keywords) # 点击登录 def click_submit(self): self.element.click_element('Login', 'Submit') # 获取首页机构名称 def get_org_name(self): return self.element.get_element_text('Index', 'OrgName') # 点击退出 def click_logout(self): self.element.click_element('Index', 'Logout') # 获取欢迎登录文字 def get_welcome(self): return self.element.get_element_text('Login', 'Welcome')
class AccountPage(object): def __init__(self, driver): self.element = PySelenium(driver) # 点击管理菜单 def click_menu_manage(self): self.element.js_click_element('Index', 'MenuManage') # 选择人员管理 def click_account(self): self.element.get_ul_li('Index', 'ManageList', 0) # 获取按钮文字 def get_add_text(self): return self.element.get_element_text('AccountManage', 'AddAccountBtn') # 点击新增人员按钮 def click_add_account_btn(self): self.element.click_element('AccountManage', 'AddAccountBtn') # 获取对话框标题 def get_dialog_title(self): return self.element.get_element_text('AccountManage', 'DialogTitle') # 输入员工姓名 def input_account_name(self, content): self.element.element_clear('AccountManage', 'AccountName') self.element.click_element('AccountManage', 'AccountName') self.element.input_element('AccountManage', 'AccountName', content) # 输入用户名(由于用户名会自动生成,暂不做特殊处理) def input_account_nickname(self): self.element.click_element('AccountManage', 'AccountNickName') # 输入员工电话 def input_account_phone(self, content): self.element.element_clear('AccountManage', 'AccountPhone') self.element.click_element('AccountManage', 'AccountPhone') self.element.input_element('AccountManage', 'AccountPhone', content) # 点击角色下拉菜单 def click_role_select(self): self.element.js_click_element('AccountManage', 'AccountRole') # 点击等级下拉菜单 def click_level_select(self): self.element.js_click_element('AccountManage', 'AccountLevel') # 选择角色 def select_role_and_level(self): self.element.get_ul_li('AccountManage', 'RoleAndLevelList') # 点击创建员工按钮 def click_create_btn(self): self.element.click_element('AccountManage', 'CreateAccountBtn') # 获取员工列表中的员工姓名 def get_account_name(self): return self.element.get_element_text('AccountManage', 'AccountListName') # 获取员工列表中的员工电话 def get_account_phone(self): return self.element.get_element_text('AccountManage', 'AccountListPhone')
def setUpClass(cls) -> None: cls.driver = SelectBrowser().select_browser('chrome') cls.dr = PySelenium(cls.driver) cls.dr.test_url('https://www.baidu.com/') cls.dr.maximize_window() cls.demo = DemoBusiness(cls.driver)
class ClassPage(object): def __init__(self, driver): self.element = PySelenium(driver) # 点击教务菜单 def click_menu_education(self): self.element.js_click_element('Index', 'MenuEducation') # 选择班级管理 def click_class(self): self.element.get_ul_li('Index', 'EducationList', 3) # 获取按钮文字 def get_add_text(self): return self.element.get_element_text('ClassManage', 'AddClassBtn') # 点击新增班级按钮 def click_add_class_btn(self): self.element.click_element('ClassManage', 'AddClassBtn') # 获取对话框标题 def get_dialog_title(self): return self.element.get_element_text('ClassManage', 'DialogTitle') # 选择课程信息 def select_course(self): self.element.js_click_element('ClassManage', 'SelectCourse') self.element.get_ul_li('ClassManage', 'SelectList') # 输入班级名称 def input_class_name(self, content): self.element.click_element('ClassManage', 'ClassName') self.element.element_force_clear('ClassManage', 'ClassName') self.element.input_element('ClassManage', 'ClassName', content) # 选择开课时间 def select_class_time(self): self.element.click_element('ClassManage', 'ClassTime') self.element.js_click_element('ClassManage', 'Today') # 选择上课教师 def select_teacher(self): self.element.js_click_element('ClassManage', 'ClassTeacher') self.element.get_ul_li('ClassManage', 'SelectList') # 输入预招人数 def input_student_num(self, content): self.element.element_force_clear('ClassManage', 'ClassNum') self.element.input_element('ClassManage', 'ClassNum', content) # 选择助教 def select_sup_teacher(self): self.element.js_click_element('ClassManage', 'ClassSup') self.element.get_ul_li('ClassManage', 'SelectList') # 保存新班级信息 def submit_class_info(self): self.element.js_click_element('ClassManage', 'SaveClassInfo') # 获取线下课程列表中第一条数据的班级名称 def get_list_class_name(self, num): return self.element.get_tr_td_desc('ClassManage', 'OfflineListFirstRow', num) # 选择线上视频班级 def click_online_class_tab(self): self.element.js_click_element('ClassManage', 'OnlineTab') # 选择课程信息 def select_online_course(self): self.element.js_click_element('ClassManage', 'SelectCourse') self.element.get_ul_li('ClassManage', 'SelectOnlineList') # 保存新班级信息 def submit_online_class_info(self): self.element.js_click_element('ClassManage', 'SaveOnlineClassInfo') # 获取线上课程列表中第一条数据的班级名称 def get_list_online_class_name(self, num): return self.element.get_tr_td_asc('ClassManage', 'OnlineListFirstRow', num) """ 排课相关 """ # 点击排课按钮 def click_plan_class_btn(self): self.element.js_click_element('ClassManage', 'PlanClassBtn') # 获取排课页面历史课程文字 def get_history_schedule(self): return self.element.get_element_text('ClassManage', 'HistorySchedule') # 点击选择按时间排课 def click_plan_class_by_time(self): self.element.js_click_element('ClassManage', 'PlanClassByTime') # 点击选择按次数排课 def click_plan_class_by_count(self): self.element.js_click_element('ClassManage', 'PlanClassByCount') # 点击选择按日历排课 def click_plan_class_by_calendar(self): self.element.js_click_element('ClassManage', 'PlanClassByCalendar') # 点击日期选择器(by time) def click_date_selector_by_time(self): self.element.js_click_element('ClassManage', 'DateSelectorByTime') # 点击选择第一页日期 def click_date_first_page(self): self.element.get_tr_td('ClassManage', 'FirstSelectorPage') # 点击选择第二页日期 def click_date_second_page(self): self.element.get_tr_td('ClassManage', 'SecondSelectorPage') # 点击选择日期为今天 def click_date_today(self): self.element.js_click_element('ClassManage', 'SelectorToday') # 点击选择星期(by time) def click_week_by_time(self): self.element.get_div_span('ClassManage', 'WeekSelectorByTime') # 点击选择星期(by count) def click_week_by_count(self): self.element.get_div_span('ClassManage', 'WeekSelectorByCount') # 输入时间 def input_time(self): self.element.js_click_element('ClassManage', 'ClassTimeSelectorInput')
class CoursePage(object): def __init__(self, driver): self.element = PySelenium(driver) # 点击教务菜单 def click_menu_education(self): self.element.js_click_element('Index', 'MenuEducation') # 选择课程管理 def click_course(self): self.element.get_ul_li('Index', 'EducationList', 4) # 获取按钮文字 def get_add_text(self): return self.element.get_element_text('CourseManage', 'AddCourseBtn') # 点击新增课程按钮 def click_add_course_btn(self): self.element.click_element('CourseManage', 'AddCourseBtn') # 获取对话框标题 def get_dialog_title(self): return self.element.get_element_text('CourseManage', 'DialogTitle') # 课程设置选择线下班组课 def click_offline_course(self): self.element.js_click_element('CourseManage', 'OfflineCourseRadio') # 课程设置选择线上视频课 def click_online_course(self): self.element.js_click_element('CourseManage', 'OnlineCourseRadio') # 课程类型选择班组课 def click_group_course(self): self.element.js_click_element('CourseManage', 'GroupCourseRadio') # 课程类型选择1对1 def click_one_for_one(self): self.element.js_click_element('CourseManage', 'OneForOneCourseRadio') # 输入课程名称 def input_course_name(self, content): self.element.click_element('CourseManage', 'CourseName') self.element.input_element('CourseManage', 'CourseName', content) # 输入上课时间 def input_course_time(self, content): self.element.click_element('CourseManage', 'CourseTime') self.element.input_element('CourseManage', 'CourseTime', content) # 输入单次扣课时数 def input_course_num(self, content): self.element.click_element('CourseManage', 'CourseNum') self.element.input_element('CourseManage', 'CourseNum', content) # 输入课时单价 def input_course_price(self, content): self.element.click_element('CourseManage', 'CoursePrice') self.element.input_element('CourseManage', 'CoursePrice', content) # 点击添加套餐按钮 def click_add_course_package(self): self.element.click_element('CourseManage', 'AddCoursePackage') # 输入套餐课时数 def input_course_package_num(self, content): self.element.click_element('CourseManage', 'CoursePackageNum') self.element.input_element('CourseManage', 'CoursePackageNum', content) # 输入套餐价格 def input_course_package_price(self, content): self.element.click_element('CourseManage', 'CoursePackagePrice') self.element.input_element('CourseManage', 'CoursePackagePrice', content) # 保存课程信息 def submit_course_info(self): self.element.js_click_element('CourseManage', 'SaveCourseInfo') # 获取列表中课程名称 def get_list_course_name(self): return self.element.get_element_text('CourseManage', 'CourseListName') # 获取列表中课程类型 def get_list_course_type(self): return self.element.get_element_text('CourseManage', 'CourseListType') # 获取列表中是否有套餐 def get_list_course_package(self): return self.element.get_element_text('CourseManage', 'CourseListPackage') # 选择线上视频课Tab def click_online_course_tab(self): self.element.js_click_element('CourseManage', 'OnlineTab') # 获取第一个输入框的Title def get_online_first_input_title(self): return self.element.get_element_text('CourseManage', 'CourseNameTitle') # 保存课程信息 def submit_online_course_info(self): self.element.js_click_element('CourseManage', 'SaveOnlineCourseInfo') # 获取线上课程列表中课程名称 def get_list_online_course_name(self): return self.element.get_element_text('CourseManage', 'OnlineListName')