def test_save_new_btn_case(self): '''保存并新建按钮''' menu3 = '按钮控件_保存并复制和新建' self.open_menu3(menu3) lp = ListViewPage(self.driver) if 0 != lp.get_rows_total(): lp.clear_all_data() btn = ButtonPage(self.driver) btn.click_button(btn.new_btn) #点击新建按钮 lp.wait_loading_hide() # 等待loading消失 ip = InputPage(self.driver, '单行文本') ip.element.send_keys('保存') btn.click_button(btn.save_new) #点击保存并新建按钮 self.assertEqual('[保存成功]', lp.get_msg(), msg='保存并新建按钮检验不通过') lp.wait_loading_hide() #等待loading消失 time.sleep(10) ip2 = InputPage(self.driver, '单行文本') ip2.element.send_keys('保存') btn.click_button(btn.save) lp.wait_loading_hide() # 等待loading消失 time.sleep(10) btn.click_button(btn.to_return) if (lp.is_alert_present()): lp.accept_alert() lp.wait_loading_hide() #等待loading消失 self.assertEqual(2, lp.get_rows_total(), msg='保存并新建按钮检验不通过') lp.clear_all_data()
def test_number_case(self): '''类型数字''' name = '单行文本_类型数字' comp = InputPage(self.driver, name) self.assertEqual('', comp.send_keys_get_value('aaaa'), msg=name + '检验不通过')
def test_not_null_case(self): '''非空校验''' name = '单行文本_非空校验' comp = InputPage(self.driver, name) self.assertIn("'单行文本_非空校验'必须填写", comp.set_val_save_get_msg(''), msg=name + '检验不通过')
def test_email_case(self): '''email校验''' name = '单行文本_邮箱校验' comp = InputPage(self.driver, name) self.assertIn("'单行文本_邮箱校验'格式错误", comp.set_val_save_get_msg('aaaaa'), msg=name + '检验不通过')
def test_refresh_calculate_case(self): '''刷新_重计算''' name = '计算脚本_重计算' comp = CalculatePage(self.driver) input = InputPage(self.driver, '计算脚本_单行文本刷新') input.send_keys_trigger_refresh('refresh_calculate') self.assertTrue(comp.has_the_text('refresh_calculate生效'), msg=name + '检验不通过')
def test_desription_case(self): '''描述''' name = '单行文本_描述' comp = InputPage(self.driver, name) self.assertEqual('单行文本_描述描述', comp.get_attr('discript'), msg=name + '检验不通过')
def test_phone_number_case(self): '''手机号电话校验''' # self.scroll_to('800') name = '单行文本_手机号电话校验' comp = InputPage(self.driver, name) self.assertIn("'单行文本_手机号电话校验'格式错误", comp.set_val_save_get_msg('aaa'), msg=name + '检验不通过')
def test_only_case(self): '''数据唯一校验''' # self.scroll_to('800') name = '单行文本_数据唯一校验' comp = InputPage(self.driver, name) self.assertIn("'单行文本_数据唯一校验'不能重复", comp.set_val_save_get_msg('aaa'), msg=name + '检验不通过')
def test_refresh_calculate_case(self): '''刷新_重计算''' name = '计算脚本_重计算' comp = CalculatePhonePage(self.driver) input = InputPage(self.driver, '计算脚本_单行文本刷新') input.send_keys_trigger_refresh('refresh_calculate') self.assertIn('refresh_calculate生效', comp.get_curpage_span(), msg=name + '检验不通过')
def test_recaculate_case(self): '''重计算''' # self.scroll_to('0') reflesh_name = '只读刷新' name = '树形部门选择框_重计算' comp = InputPage(self.driver, reflesh_name) comp.send_keys_trigger_refresh('只读') comp2 = TreeDepartmentPage(self.driver, name) self.assertTrue(comp2.span_is_displayed(), msg=name + '检验不通过')
def test_refresh_calculate_case(self): '''刷新_重计算''' name = 'html编辑器_重计算' comp = HtmlPage(self.driver, name) self.assertIsNotNone(comp.get_the_div(), msg=name + '检验不通过') self.assertIsNotNone(comp.get_the_div_iframe(), msg=name + '检验不通过') input = InputPage(self.driver, '单行文本刷新') input.send_keys_trigger_refresh('hide') self.assertIsNone(comp.get_the_div(), msg=name + '检验不通过') self.assertIsNone(comp.get_the_div_iframe(), msg=name + '检验不通过')
def test_edit_not(self): '''是否可编辑脚本_否''' menu3 = '表单_是否可编辑脚本_否' self.open_menu3(menu3) lp = ListViewPage(self.driver) lp.click_row() btn = ButtonPage(self.driver) comp = InputPage(self.driver, '文本一') self.assertTrue(comp.readonly_test(), msg='是否可编辑脚本_否检验不通过')
def test_refresh_case(self): '''刷新''' # self.scroll_to('0') name = '树形部门选择框_刷新' cmpname = '已选部门数' comp = TreeDepartmentPage(self.driver, name) depts = comp.select_dept() print("depts=========%s" % depts) comp2 = InputPage(self.driver, cmpname) self.assertEqual("已刷新", comp2.get_attr('value'), msg=name + '检验不通过')
def test_refresh_calculate_case(self): '''刷新_重计算''' name = '二维码_重计算' comp = QrcodePage(self.driver, name) self.assertIsNotNone(comp.find_elem('input[name="' + name + '"] + div > canvas'), msg=name + '检验不通过') input = InputPage(self.driver, '二维码_单行文本刷新') input.send_keys_trigger_refresh('hide') self.assertTrue(comp.is_elem_invisibility('input[name="' + name + '"] + div > canvas'), msg=name + '检验不通过')
def test_refresh_calculate_case(self): '''刷新_重计算''' name = '调查问卷_重计算' comp = SurveyPage(self.driver, name) self.assertNotEqual('none', comp.get_the_div(), msg=name + '检验不通过') self.assertIn('羽毛球', comp.get_the_div_text(), msg=name + '检验不通过') input = InputPage(self.driver, '单行文本刷新') input.send_keys_trigger_refresh('hide') self.assertEqual('none', comp.find_element_by_css_selector('input[name="' + name + '"]'), msg=name + '检验不通过')
def test_refresh_calculate_case(self): '''刷新_重计算''' name = '二维码_重计算' comp = QrcodePhonePage(self.driver, name) self.assertNotEqual('none', comp.find_element('input[name="' + name + '"] + div canvas'), msg=name + '检验不通过') input = InputPage(self.driver, '二维码_单行文本刷新') input.send_keys_trigger_refresh('hide') self.assertIsNone(comp.find_element('input[name="' + name + '"] + div canvas'), msg=name + '检验不通过')
def test_button_self_print_case(self): '''自定义打印按钮''' menu3 = '按钮控件_打印导出下载等' self.open_menu3(menu3) comp = InputPage(self.driver, '单行文本') btn = ButtonPage(self.driver) btn.open_and_switch_to_self_print_page() self.assertNotEqual('none', comp.find_element_by_css_selector('#MyappsReport'), msg='自定义打印按钮检验不通过') self.driver.close() mp = MainPage(self.driver) mp.switch_to_current_window()
def test_card_case(self): '''身份证校验''' name = '单行文本_身份证校验' comp = InputPage(self.driver, name) self.assertIn('身份证号码位数不对', comp.set_val_save_get_msg('aaa'), msg=name + '检验不通过') self.assertIn('身份证号码出生日期超出范围或含有非法字符', comp.set_val_save_get_msg('441421111101010012'), msg=name + '检验不通过') self.assertNotIn('身份证号码输入不合法', comp.set_val_save_get_msg('441421199001010022'), msg=name + '检验不通过')
def test_show_when_print_case(self): '''打印隐藏时显示值''' # self.scroll_to('1000') name = '单行文本_打印隐藏时显示值' comp = InputPage(self.driver, '') comp.open_and_switch_to_print_page() #time.sleep(0.5) comp.window_scroll_to('1000') self.assertEqual('none', comp.find_element_by_css_selector('input[name="' + name + '"]'), msg=name + '检验不通过') self.assertTrue(comp.show_when_print('打印隐藏时显示值'), msg=name + '检验不通过') comp.close_currentwindow()
def test_refresh_calculate_case(self): '''刷新_重计算''' name = '地图_重计算' comp = MapPage(self.driver, name) iframe = comp.get_the_map_iframe() comp.switch_to_the_iframe(iframe) self.assertTrue(comp.is_map_page(), msg=name + '检验不通过') mp = MainPage(self.driver) mp.switch_to_parent() mp.switch_to_iframe() input = InputPage(self.driver, '单行文本刷新') input.send_keys_trigger_refresh('hide') self.assertFalse(comp.is_element_visible('input[name="' + name + '"]'), msg=name + '检验不通过')
def test_collapse_hide_case(self): '''选项卡折叠视图刷新隐藏''' menu3 = '选项卡_折叠重计算' self.open_menu3(menu3) tabpage = TabPage(self.driver) #验证只读时,列表视图的按钮是否可见 input_page = InputPage(self.driver,"重计算") input_page.send_keys_trigger_refresh("隐藏") tabpage = TabPage(self.driver) #展开第二个折叠项 collapse=['1','2','3'] for collapseone in collapse: collapse1 = tabpage.find_tab_collapse(collapseone) dispaly = collapse1.get_attribute("style") self.assertIn("display: none;",dispaly,msg=collapseone+'选项卡折叠刷新隐藏检验不通过')
def test_delete_case(self): '''删除按钮''' menu3 = '按钮_case001' self.open_menu3(menu3) #打开菜单 lp = ListViewPage(self.driver) if 0 != lp.get_rows_total(): lp.clear_all_data() #清空所有数据 #新建一条数据 btn = ButtonPage(self.driver) btn.click_button(btn.new_btn) #time.sleep(0.5) ip = InputPage(self.driver, '单行文本') ip.element.send_keys('保存') btn.click_button(btn.save_start) lp.wait_Tabloading_show_then_hide() #等待loading消失 btn.click_button(btn.to_return) lp.wait_loading_hide() #表单中 lp.wait_loading_hide() #视图中 #确定已经有一条数据 self.assertEqual(1, lp.get_rows_total(), msg='删除按钮检验不通过') lp.click_select_all() #点击全选 btn.click_button(btn.del_btn) #点击删除 lp.click_alert_accept() #确定确认框 lp.wait_loading_hide() # 等待loading消失 #确定数据条数为0 self.assertEqual(0, lp.get_rows_total(), msg='删除按钮检验不通过')
def test_flow_start_user_appoint_btn(self): '''流程启动用户指定按钮''' menu3 = '表单按钮_流程相关' Process_approver = ProcessApproverPage(self.driver) Process_approver.close_message() self.open_menu3(menu3) #清数据 lp = ListViewPage(self.driver) if 0 != lp.get_rows_total(): lp.clear_all_data() #新建记录 btn = ButtonPage(self.driver) btn.click_button(btn.new_btn) #time.sleep(0.5) ip = InputPage(self.driver, '单行文本') ip.element.send_keys('保存') #点击流程启动用户指定按钮 btn.click_button(btn.flow_start) #time.sleep(0.5) mp = MainPage(self.driver) #切到iframe mp.switch_to_div_iframe() #在启动流程界面指定流程并确定 btn.appoint_flow() mp.switch_to_parent() mp.switch_to_iframe() #time.sleep(0.5) msgtitle = lp.is_test_in_msg('成功保存并开启流程') self.assertTrue(msgtitle, msg='流程启动用户指定按钮检验不通过') btn.click_button(btn.to_return) lp.wait_loading_hide() #表单中 if 0 != lp.get_rows_total(): lp.clear_all_data()
def test_refresh_calculate_case(self): '''刷新_重计算''' name = '在线拍照_重计算' comp = TakephotoPage(self.driver, name) self.assertEqual('OnLineTakePhotoField', comp.get_attr('fieldtype'), msg=name + '检验不通过') self.assertEqual('/resource/image/photo.png', comp.get_attr('value'), msg=name + '检验不通过') self.assertTrue(comp.check_img(), msg=name + '检验不通过') input = InputPage(self.driver, '单行文本刷新') input.send_keys_trigger_refresh('hide') self.assertEqual('none', comp.find_element_by_css_selector('input[name="' + name + '"]'), msg=name + '检验不通过')
def single_input(self): '''单行文本框查询''' ip = InputPage(self.driver, '单行文本框') ip.element.send_keys('') self.find_elem('.comSearchBtn').click() # 点击查询按钮 self.wait_loading_hide() #time.sleep(0.5) sis = self.find_elems('#dataTable .listDataTr td:nth-child(2)') return self.judge_search_content_inlist(sis, '')
def test_refresh_calculate_case(self): '''刷新_重计算''' name = 'word控件_重计算' comp = WordPage(self.driver, name) self.assertNotEqual('none', comp.get_the_div(), msg=name + '检验不通过') self.assertNotEqual('none', comp.get_the_div_hide(), msg=name + '检验不通过') self.assertNotEqual('none', comp.get_the_div_img(), msg=name + '检验不通过') self.assertIn('/share/images/view/genericword.jpg', comp.get_the_div_img_src(), msg=name + '检验不通过') input = InputPage(self.driver, '单行文本刷新') input.send_keys_trigger_refresh('hide') self.assertEqual('none', comp.find_element_by_css_selector('input[name="' + name + '"]'), msg=name + '检验不通过')
def single_input(self): '''单行文本框查询''' ip = InputPage(self.driver, '单行文本框') ip.element.send_keys('test1') # 输入文本 self.find_elem('.comSearchBtn').click() # 点击查询按钮 self.wait_query_fload() # 等待查询头折叠 self.wait_loading_hide() # 等待视图的loading消失 sis = self.find_elems( '#dataTable .listDataTr td:nth-child(2)') # 获取搜索后的单行文本列值 return self.judge_search_content_inlist(sis, 'test1')
def test_refresh_calculate_case(self): '''刷新_重计算''' name = '单行文本_刷新_重计算' comp = InputPage(self.driver, name) comp.send_keys_trigger_refresh('refresh') comp = InputPage(self.driver, name) self.assertEqual('refresh end', comp.get_attr('value'), msg=name + '检验不通过')
def add_one_row(self): '''新建一条数据''' bp = ButtonPage(self.driver) bp.click_button(bp.new_btn) bp.wait_Tabloading_show_then_hide() ip = InputPage(self.driver, '列表视图_单行文本框') ip.element.send_keys(20) bp.click_button(bp.save_start) #点击流程启动按钮 bp.wait_Tabloading_show_then_hide() bp.click_button(bp.to_return) #点击返回按钮 bp.wait_loading_hide() #表单中
def single_input(self): '''单行文本框查询''' ip = InputPage(self.driver, '单行文本框') ip.element.send_keys('test4') self.view_scroll_to('400') #time.sleep(0.5) self.find_elem('#searchFormTable .btn-primary').click() self.wait_query_fload() # 等待查询头折叠 #time.sleep(0.5) self.wait_loading_hide() dv = self.find_elem('#cal14') return dv.text == '14'