def test_ZZJG_0023(self): """断网提示""" # 1、打开客户端 # 2、进入工作台组织架构”图标 # 4、断开网络 # 5、点击其他元素 osp = OrganizationStructurePage() time.sleep(2) osp.wait_for_page_load() current_mobile().back() workbench = WorkbenchPage() workbench.wait_for_page_load() workbench.set_network_status(0) time.sleep(8) workbench.click_organization() time.sleep(2) if not osp.is_text_present("网络出错,轻触屏幕重新加载"): raise AssertionError("没有出现‘网络出错,轻触屏幕重新加载’") osp.click_text("网络出错,轻触屏幕重新加载") if not osp.is_toast_exist("网络不可用,请检查网络设置"): raise AssertionError("没有出现‘网络不可用,请检查网络设置’toast提示") time.sleep(2) current_mobile().back() workbench.set_network_status(6) time.sleep(8) workbench.click_organization() time.sleep(2) osp.wait_for_page_load() workbench.set_network_status(0) time.sleep(8) osp.click_text("添加联系人") time.sleep(1) osp.click_text("手动输入添加") if not osp.is_toast_exist("无网络,请稍候重试"): raise AssertionError("没有‘无网络,请稍候重试’toast提示")
def test_ZZJG_0011(self): """成功批量删除部门中成员信息""" # 1、点击“更多” # 2、点击“批量删除成员” # 3、勾选需要删除的成员 # 4、点击“确定” osp = OrganizationStructurePage() osp.wait_for_page_load() osp.click_text("更多") time.sleep(1) osp.click_text("批量删除成员") osp.wait_for_delete_contacts_page_load() time.sleep(3) els = osp.get_contacts_in_organization() if els: for el in els: el.click() else: raise AssertionError("当前组织没有成员,请添加") time.sleep(1) osp.click_text("确定") if not osp.is_toast_exist("成功"): raise AssertionError("没有删除成功") current_mobile().back() osp.wait_for_page_load()
def test_ZZJG_0007(self): """点击邀请小伙伴正常跳转到邀请成员页面""" # 1、点击“组织架构”应用 # 2、点击“添加联系人” # 3、点击“邀请小伙伴” # 4、操作页面的各个按钮 # 5、点返回 osp = OrganizationStructurePage() osp.wait_for_page_load() osp.click_text("添加联系人") time.sleep(1) osp.click_text("扫描二维码邀请") osp.wait_for_invite_page_load() osp.click_invite_mode_switch() time.sleep(2) if not osp.is_text_present("加入企业后仅可见自己"): raise AssertionError("访客模式开关不可用") time.sleep(2) osp.click_invite_save() if not osp.is_toast_exist("保存图片成功"): raise AssertionError("保存二维码按钮不可用") time.sleep(1) osp.click_invite_share() time.sleep(1) if not osp.is_exist_element_by_locatorname("点击右上角即可分享"): raise AssertionError("分享按钮不可用") current_mobile().back() current_mobile().back() osp.wait_for_page_load()
def create_department_and_add_member(department_names): """创建企业部门并从手机联系人添加成员""" mp = MessagePage() mp.wait_for_page_load() mp.open_workbench_page() wbp = WorkbenchPage() wbp.wait_for_workbench_page_load() wbp.click_organization() osp = OrganizationStructurePage() n = 1 # 解决工作台不稳定问题 while not osp.page_should_contain_text2("添加联系人"): osp.click_back() wbp.wait_for_workbench_page_load() wbp.click_organization() n += 1 if n > 20: break time.sleep(3) for department_name in department_names: if not osp.is_exist_specify_element_by_name(department_name): osp.click_specify_element_by_name("添加子部门") time.sleep(2) osp.input_sub_department_name(department_name) osp.input_sub_department_sort("1") osp.click_confirm() if osp.is_toast_exist("部门已存在", 2): osp.click_back() osp.wait_for_page_load() osp.click_specify_element_by_name(department_name) time.sleep(2) osp.click_specify_element_by_name("添加联系人") time.sleep(4) osp.click_specify_element_by_name("从手机通讯录添加") slc = SelectLocalContactsPage() # 等待选择联系人页面加载 slc.wait_for_page_load() slc.selecting_local_contacts_by_name("大佬1") slc.selecting_local_contacts_by_name("大佬2") slc.selecting_local_contacts_by_name("大佬3") slc.selecting_local_contacts_by_name("大佬4") slc.click_sure() time.sleep(2) osp.click_back() time.sleep(1) osp.click_back() osp.click_back() wbp.wait_for_workbench_page_load() mp.open_message_page() mp.wait_for_page_load()
def test_ZZJG_0009(self): """成功添加一个子部门""" # 1、点击“组织架构”应用 # 2、点击“添加子部门” # 3、输入部门名称:“测试部” # 4、点击完成 osp = OrganizationStructurePage() osp.wait_for_page_load() osp.click_text("添加子部门") osp.wait_for_sub_department_page_load() osp.input_sub_department_name("哈哈") osp.click_text("完成") if osp.is_toast_exist("部门已存在,请勿重复添加"): current_mobile().back() osp.wait_for_page_load() else: osp.wait_for_page_load()
def test_ZZJG_0004(self): """手动添加联系人""" #1、点击“组织架构”应用 # 2、点击“添加联系人” # 3、点击“手动输入添加” # 4、不输入姓名或主手机号码 # 5、点击“完成” osp = OrganizationStructurePage() osp.wait_for_page_load() osp.click_text("添加联系人") time.sleep(1) osp.click_text("手动输入添加") time.sleep(1) osp.click_text("完成") if not osp.is_toast_exist("请输入姓名"): raise AssertionError("没有出现toast提示") time.sleep(1) current_mobile().back()
def create_sub_department(departmentName): """从消息列表开始创建子部门并添加部门成员""" WorkbenchPreconditions.enter_organization_page() osp = OrganizationStructurePage() osp.wait_for_page_load() osp.click_text("添加子部门") osp.wait_for_sub_department_page_load() osp.input_sub_department_name(departmentName) osp.click_text("完成") if osp.is_toast_exist("部门已存在,请勿重复添加"): current_mobile().back() osp.wait_for_page_load() else: osp.wait_for_page_load() time.sleep(2) osp.click_text(departmentName) osp.click_text("添加联系人") time.sleep(1) osp.click_text("从手机通讯录添加") time.sleep(2) sc = SelectContactsPage() slc = SelectLocalContactsPage() # 选择联系人 names = slc.get_contacts_name_list() time.sleep(2) sc.click_one_contact(names[0]) sc.click_one_contact(names[1]) sc.click_one_contact(names[2]) # slc.click_one_contact("和飞信电话") slc.click_sure() if not slc.is_toast_exist("操作成功"): raise AssertionError("操作不成功") time.sleep(2) current_mobile().back() time.sleep(2) if not osp.is_on_this_page(): raise AssertionError("没有返回上一级") time.sleep(2) current_mobile().back() workbench = WorkbenchPage() workbench.wait_for_page_load() time.sleep(3) current_mobile().back() workbench.open_message_page()
def add_phone_number_to_department(department_name): """添加本机号码到指定部门""" wbp = WorkbenchPage() wbp.wait_for_workbench_page_load() wbp.click_organization() osp = OrganizationStructurePage() n = 1 # 解决工作台不稳定问题 while not osp.page_should_contain_text2("添加联系人"): osp.click_back() wbp.wait_for_workbench_page_load() wbp.click_organization() n += 1 if n > 20: break phone_number = current_mobile().get_cards(CardType.CHINA_MOBILE)[0] time.sleep(3) if not osp.is_exist_specify_element_by_name(department_name): osp.click_specify_element_by_name("添加子部门") time.sleep(2) osp.input_sub_department_name(department_name) osp.input_sub_department_sort("1") osp.click_confirm() if osp.is_toast_exist("部门已存在", 2): osp.click_back() osp.wait_for_page_load() osp.click_specify_element_by_name(department_name) time.sleep(2) osp.click_specify_element_by_name("添加联系人") time.sleep(2) osp.click_specify_element_by_name("手动输入添加") osp.input_contacts_name("admin") osp.input_contacts_number(phone_number) osp.click_confirm() osp.click_close() wbp.wait_for_workbench_page_load()
def test_ZZJG_0003(self): """手动添加联系人""" # 1、点击“组织架构”应用 # 2、点击“添加联系人” # 3、点击“手动输入添加” # 4、输入姓名:测试号 # 5、输入主手机:15220089861 # 6、点击“完成” osp = OrganizationStructurePage() osp.wait_for_page_load() if not osp.swipe_and_find_element("yyx"): osp.click_text("添加联系人") time.sleep(1) osp.click_text("手动输入添加") time.sleep(1) osp.input_contacts_name("yyx") osp.input_contacts_number("18920736596") time.sleep(2) osp.click_text("完成") if not osp.is_toast_exist("成功"): raise AssertionError("手动添加失败") osp.wait_for_page_load() else: print("已存在联系人yyx")