def add_portrait(self, portrait, confirm=True): """ 添加指定人像 参数: portrait: 人像类实例 confirm: 是否确认,默认为确认 """ PortraitPage.click_add_portrait_button(self) PortraitPage.upload_portrait_image(self, '添加人像', portrait.image_path) PortraitPage.input_portrait_name(self, '添加人像', portrait.name) PortraitPage.input_portrait_alias(self, '添加人像', portrait.alias) PortraitPage.input_portrait_id_number(self, '添加人像', portrait.id_number) PortraitPage.select_portrait_databases(self, '添加人像', portrait.portrait_databases) PortraitPage.set_gender_by_name(self, '添加人像', portrait.gender) PortraitPage.input_portrait_age(self, '添加人像', portrait.age) PortraitPage.input_portrait_company(self, '添加人像', portrait.company) PortraitPage.input_portrait_department(self, '添加人像', portrait.department) PortraitPage.input_portrait_contact(self, '添加人像', portrait.contact) PortraitPage.input_portrait_license_plate(self, '添加人像', portrait.license_plate) PortraitPage.input_portrait_address(self, '添加人像', portrait.address) PortraitPage.set_portrait_activation_time(self, '添加人像', portrait.activation_time) PortraitPage.set_portrait_expiration_time(self, '添加人像', portrait.expiration_time) PortraitPage.click_enable_status_switch(self, '添加人像') if confirm: Dialog.click_dialog_footer_button_by_text(self, '添加人像', '确定') else: Dialog.click_dialog_footer_button_by_text(self, '添加人像', '取消') self.sleep(3)
def add_portrait_database_by_name(self, name, type='白名单', is_frontend=False, confirm=True): """ 添加指定命名和类型的人像库 参数: name: 人像库名称 type: 人像库类型,默认为白名单,可选重点人员 is_frontend: confirm: 是否确认,默认为确认 """ GroupTree.click_group_menu_by_name(self, type, "创建下一级") GROUP_TYPE_XDROPDOWN = '//div[@class="el-dialog__body"]//input[@placeholder="请选择"]' GROUP_TYPE_XOPTION = f'//div[@class="el-scrollbar"][1]//span[text()="{type}"]' GROUP_IS_FRONTEND_XSWITCH = '//div[@class="el-dialog__body"]//div[@class="el-switch"]' self.click(GROUP_TYPE_XDROPDOWN) self.slow_click(GROUP_TYPE_XOPTION) PortraitPage.input_portrait_database_name(self, name) if is_frontend: self.click(GROUP_IS_FRONTEND_XSWITCH, delay=1) if confirm: Dialog.click_dialog_footer_button_by_text(self, '创建下一级', '确定') else: Dialog.click_dialog_footer_button_by_text(self, '创建下一级', '取消')
def test_edit_invalid_portrait_image( sb, login, setup_portrait_with_portrait_database_and_delete_portrait_database, image_path, alert_message): TableList.click_edit_button_by_name( sb, setup_portrait_with_portrait_database_and_delete_portrait_database[ 'name']) PortraitPage.upload_portrait_image(sb, '编辑', os.getcwd() + image_path) Dialog.click_dialog_footer_button_by_text(sb, '编辑', '取消')
def test_required_fields_when_adding_portrait(sb, login, setup_portrait_name): PortraitPage.click_add_portrait_button(sb) Dialog.click_dialog_footer_button_by_text(sb, '添加人像', '确定') sb.is_element_visible( '//div[@class="el-form-item__error" and contains(text(), "请上传本地人像照片")]' ) sb.is_element_visible( '//div[@class="el-form-item__error" and contains(text(), "请输入姓名")]') sb.is_element_visible( '//div[@class="el-form-item__error" and contains(text(), "请输入No.")]') sb.is_element_visible( '//div[@class="el-form-item__error" and contains(text(), "请选择人像库")]') sb.is_element_visible( '//div[@class="el-form-item__error" and contains(text(), "请选择时间")]')
def view_portrait_database_by_name(self, name, confirm=True): """ 查看指定命名人像库 参数: name: 人像库名称 confirm: 是否确认,默认为确认 """ PortraitPage.search_portrait_database_by_name(self, name) GroupTree.click_group_menu_by_name(self, name, menu='详情') if confirm: Dialog.click_dialog_footer_button_by_text(self, '详情', '确定') else: Dialog.click_dialog_footer_button_by_text(self, '详情', '取消')
def rename_portrait_database_by_name(self, old_name, new_name, confirm=True): """ 重命名指定命名人像库 参数: old_name: 原人像库名称 new_name: 新人像库名称 confirm: 是否确认,默认为确认 """ PortraitPage.search_portrait_database_by_name(self, old_name) GroupTree.click_group_menu_by_name(self, old_name, menu='重命名') PortraitPage.input_portrait_database_name(self, new_name) if confirm: Dialog.click_dialog_footer_button_by_text(self, '编辑', '确定') else: Dialog.click_dialog_footer_button_by_text(self, '编辑', '取消')
def edit_task_name(self, name, newName, confirm=True): """ 更新指定命名任务名称 参数: name: 任务名称 newName: 新的任务名称 created by yuan xiaolu on 15th,Apr 2020 """ TASK_EDIT_XBUTTON = f'//div[text()="{name}"]/parent::*/following-sibling::td//i[contains(@class, "iconfont icon-edit")]' TaskPage.search_task_by_name(self, name) self.click(TASK_EDIT_XBUTTON, 3) self.sleep(5) TaskPage.input_task_name(self, name=newName) TASK_EDIT_CONFIRM_BUTTON = Dialog.get_dialog_footer_button_element( self, title="编辑") TASK_EDIT_CANCEL_BUTTON = Dialog.get_dialog_footer_button_element( self, title="编辑", confirm=False) if confirm: self.slow_click(TASK_EDIT_CONFIRM_BUTTON) TaskPage.search_task_by_name(self, newName) else: self.slow_click(TASK_EDIT_CANCEL_BUTTON)
def delete_portrait_by_name(self, name, from_current_group=False, confirm=True): """ 删除指定人像 参数: name: 人像姓名 from_current_group: 默认从总库中删除,可选True,从当前人像库中删除 confirm: 是否确认,默认为确认 """ TableList.click_delete_button_by_name(self, name) if from_current_group and confirm: Dialog.click_dialog_footer_button_by_text(self, '删除', '仅从分组删除') elif not from_current_group and confirm: Dialog.click_dialog_footer_button_by_text(self, '删除', '从人像库删除') else: Dialog.click_dialog_footer_button_by_text(self, '删除', '取消')
def test_rename_existing_portrait_database_with_invalid_name( sb, login, name, setup_portrait_database_and_delete_portrait_database): PortraitPage.rename_portrait_database_by_name( sb, setup_portrait_database_and_delete_portrait_database['name'], name) PortraitPage.assert_element_text(sb, '.tips > span', '请输入分组名称') Dialog.click_dialog_footer_button_by_text(sb, '编辑', '取消')