def test_QFXS_0012(self): """用户同时在两个部门下""" gmp = GroupMessengerPage() # 等待群发信使首页加载 gmp.wait_for_page_load() # 确保用户在企业部门下 gmp.click_back() wbp = WorkbenchPage() # 添加本机号码到指定部门1 department_name1 = "admin_department1" Preconditions.add_phone_number_to_department(department_name1) # 添加本机号码到指定部门2 department_name2 = "admin_department2" Preconditions.add_phone_number_to_department(department_name2) workbench_name = wbp.get_workbench_name() # 解决用户部门变更后不能及时刷新的问题 wbp.click_company_contacts() ecp = EnterpriseContactsPage() ecp.wait_for_page_load() time.sleep(2) ecp.click_back() time.sleep(2) if ecp.is_exist_department_name(): ecp.click_back() wbp.wait_for_workbench_page_load() wbp.click_group_messenger() gmp.wait_for_page_load() gmp.click_new_message() nmp = NewMessagePage() # 等待群发信使->新建短信页面加载 nmp.wait_for_page_load() nmp.click_add_icon() sccp = SelectCompanyContactsPage() # 等待群发信使->新建短信->选择联系人页面加载 sccp.wait_for_page_load() # 1.跳转后是否显示企业层级:企业+部门名称(部门随机显示一个) self.assertEquals(sccp.is_exist_corporate_grade(), False) self.assertEquals(sccp.is_exist_department_by_name(workbench_name), True) self.assertEquals( (sccp.is_exist_department_by_name(department_name1) or sccp.is_exist_department_by_name(department_name2)), True) sccp.click_back() nmp.wait_for_page_load() nmp.click_back() # 等待群发信使首页加载 gmp.wait_for_page_load()
def test_QFXS_0011(self): """用户在企业部门下又在企业子一层级中,直接进入企业层级""" gmp = GroupMessengerPage() # 等待群发信使首页加载 gmp.wait_for_page_load() # 确保用户既在企业部门下又在企业子一层级 gmp.click_back() wbp = WorkbenchPage() # 添加本机号码到指定部门 department_name = "admin_department" Preconditions.add_phone_number_to_department(department_name) # 添加本机号码到和通讯录 Preconditions.add_phone_number_to_he_contacts() workbench_name = wbp.get_workbench_name() # 解决用户部门变更后不能及时刷新的问题 wbp.click_company_contacts() ecp = EnterpriseContactsPage() ecp.wait_for_page_load() time.sleep(2) ecp.click_back() time.sleep(2) if ecp.is_exist_department_name(): ecp.click_back() wbp.wait_for_workbench_page_load() wbp.click_group_messenger() gmp.wait_for_page_load() gmp.click_new_message() nmp = NewMessagePage() # 等待群发信使->新建短信页面加载 nmp.wait_for_page_load() nmp.click_add_icon() sccp = SelectCompanyContactsPage() # 等待群发信使->新建短信->选择联系人页面加载 sccp.wait_for_page_load() # 1.是否直接进入企业层级:企业+部门名称 self.assertEquals(sccp.is_exist_corporate_grade(), False) self.assertEquals(sccp.is_exist_department_by_name(workbench_name), True) self.assertEquals(sccp.is_exist_department_by_name(department_name), True) sccp.click_back() nmp.wait_for_page_load() nmp.click_back() # 等待群发信使首页加载 gmp.wait_for_page_load()
def tearDown_test_QFXS_0012(): """恢复环境""" fail_time = 0 while fail_time < 5: try: Preconditions.make_already_in_message_page() mp = MessagePage() mp.open_workbench_page() wbp = WorkbenchPage() Preconditions.delete_department_by_name("admin_department1") Preconditions.delete_department_by_name("admin_department2") workbench_name = wbp.get_workbench_name() # 查找并点击所有展开元素 wbp.find_and_click_open_element() # 解决用户部门变更后不能及时刷新的问题 wbp.click_company_contacts() ecp = EnterpriseContactsPage() ecp.wait_for_page_load() if ecp.is_exist_department_by_name(workbench_name): ecp.click_corporate_by_name(workbench_name) time.sleep(2) ecp.click_back() sccp = SelectCompanyContactsPage() time.sleep(2) if sccp.is_exist_department_name(): ecp.click_back() wbp.wait_for_workbench_page_load() wbp.click_group_messenger() n = 1 # 解决工作台不稳定问题 while not wbp.page_should_contain_text2("新建短信"): wbp.click_group_messenger() n += 1 if n > 20: break return except: fail_time += 1