def test_default_value(self): '''测试单行文本默认值''' qiqiao.public(self.driver).clickButtonInTitle("添加") default = qiqiao.public(self.driver).getAttribute( readXml("single_line_text", "sendValue").format(name="默认"), "title") self.assertEqual(default, "道一七巧测试")
def test_search_by_datetime(self): '''通过日期时间筛选页面数据''' qiqiao.public(self.driver).clickExpand() qiqiao.dateTime(self.driver).searchData("日期时间","2020-09-15 00:00 至 2020-09-16 00:00") time.sleep(1) title = qiqiao.public(self.driver).getText("xpath=>//span[@class='el-pagination__total']") self.assertIn("1",title)
def test_search_by_address(self): '''通过地址选择筛选页面数据''' qiqiao.public(self.driver).clickExpand() qiqiao.address(self.driver).searchData("地址选择器","河南省","郑州市","中原区") time.sleep(1) title = qiqiao.public(self.driver).getText("xpath=>//span[@class='el-pagination__total']") self.assertIn("1",title)
def test_form_only_check(self): '''测试表单唯一校验''' qiqiao.public(self.driver).clickButtonInTitle("添加") qiqiao.singleLineText(self.driver).sendValue("单行文本","测试数据") qiqiao.public(self.driver).clickSubmit() msg = qiqiao.public(self.driver).getText("xpath=>//p[@class='el-message__content']") self.assertEqual(msg,"单行文本必须唯一!!!")
def setUpClass(cls) -> None: cls.driver = webdriver.Chrome( "D:\Projects\MagicAutoTestFranmework\\ui\driver\chromedriver.exe") url = readYaml("qa.yaml", "qa", "singlechoice") usename = readYaml("qa.yaml", "qa", "username") password = readYaml("qa.yaml", "qa", "password") qiqiao.public(cls.driver).loginRuntime(url, usename, password)
def test_search_by_department(self): '''通过部门选择筛选页面数据''' qiqiao.public(self.driver).clickExpand() qiqiao.departSelector(self.driver).searchData("部门单选","产","创新技术中心->产品研发二部") qiqiao.public(self.driver).clickSearchBtn() time.sleep(1) title = qiqiao.public(self.driver).getText("xpath=>//span[@class='el-pagination__total']") self.assertIn("1",title)
def test_search_by_multiple_choice(self): '''通过多项选择筛选页面数据''' qiqiao.public(self.driver).clickExpand() qiqiao.multipleChoice(self.driver).searchData("多项选择","奥迪") time.sleep(1) title = qiqiao.public(self.driver).getText("xpath=>//span[@class='el-pagination__total']") self.assertIn("1", title)
def test_search_by_number(self): '''通过数字筛选页面数据''' qiqiao.number(self.driver).searchData("数字",15) qiqiao.public(self.driver).clickSearchBtn() time.sleep(1) title = qiqiao.public(self.driver).getText("xpath=>//span[@class='el-pagination__total']") self.assertIn("1",title)
def test_search_by_score(self): '''通过评分字段筛选页面数据''' qiqiao.public(self.driver).clickExpand() qiqiao.score(self.driver).searchData("评分",5) qiqiao.public(self.driver).clickSearchBtn() time.sleep(1) title = qiqiao.public(self.driver).getText("xpath=>//span[@class='el-pagination__total']") self.assertIn("1",title)
def test_upload_pic(self): '''测试图片上传''' qiqiao.public(self.driver).clickButtonInTitle("添加") qiqiao.uploadPic(self.driver).uploadPicture("图片上传","ceshi.png") time.sleep(1) qiqiao.public(self.driver).clickSubmit() html = self.driver.page_source self.assertIn("ceshi.png",html)
def setUpClass(cls) -> None: # options = webdriver.ChromeOptions() # options.add_argument('--headless') url = readYaml("prod.yaml","prod","pc_business") usename = readYaml("prod.yaml","prod","username") password = readYaml("prod.yaml","prod","password") cls.driver = webdriver.Chrome(executable_path="D:\Projects\MagicAutoTestFranmework\\ui\driver\chromedriver.exe") qiqiao.public(cls.driver).loginRuntime(url,usename,password)
def test_required(self): '''测试单项选择必填''' qiqiao.public(self.driver).clickButtonInTitle("添加") time.sleep(1) qiqiao.public(self.driver).clickSubmit() error_msg = qiqiao.public( self.driver).getText("xpath=>//div[@class='el-form-item__error']") self.assertEqual(error_msg, "不能为空")
def test_data_linkage(self): '''测试数字组件数据联动''' qiqiao.public(self.driver).clickButtonInTitle("添加") qiqiao.number(self.driver).sendValue("必填唯一", 50) time.sleep(1) link_value = qiqiao.public(self.driver).getAttribute( readXml("number", "sendValue").format(name="数据联动"), "title") self.assertEqual(link_value, "20.00")
def test_upload_file(self): '''测试上传文件''' qiqiao.public(self.driver).clickButtonInTitle("添加") qiqiao.uploadFile(self.driver).uploadFile("文件上传","动画图片.gif") time.sleep(2) qiqiao.public(self.driver).clickSubmit() html = self.driver.page_source self.assertIn("动画图片.gif",html)
def test_search_by_editdate(self): '''通过修改日期筛选页面数据''' qiqiao.public(self.driver).clickExpand() qiqiao.date(self.driver).searchData("修改时间","2020-09-13","2020-09-14") qiqiao.public(self.driver).clickSearchBtn() time.sleep(1) title = qiqiao.public(self.driver).getText("xpath=>//span[@class='el-pagination__total']") self.assertIn("0",title)
def test_search_by_multiline_text(self): '''通过多行文本筛选页面数据''' qiqiao.multilineText(self.driver).searchData("多行文本","哈哈哈") qiqiao.public(self.driver).clickSearchBtn() time.sleep(1) title = qiqiao.public(self.driver).getText("xpath=>//span[@class='el-pagination__total']") self.assertIn("1",title)
def test_search_by_time(self): '''通过时间筛选页面数据''' qiqiao.public(self.driver).clickExpand() qiqiao.time(self.driver).searchData("时间","11:30","12:00") time.sleep(10) qiqiao.public(self.driver).clickSearchBtn() time.sleep(1) title = qiqiao.public(self.driver).getText("xpath=>//span[@class='el-pagination__total']") self.assertIn("1",title)
def test_data_linkage(self): '''测试单行文本数据联动''' qiqiao.public(self.driver).clickButtonInTitle("添加") qiqiao.singleLineText(self.driver).sendValue("必填_唯一", "测试") time.sleep(1) link_value = qiqiao.public(self.driver).getAttribute( readXml("single_line_text", "sendValue").format(name="数据联动"), "title") self.assertEqual(link_value, "20")
def test_search_by_creaperson(self): '''通过创建人筛选页面数据''' qiqiao.public(self.driver).clickExpand() qiqiao.personSelector(self.driver).searchData("创建人","刁惠云") qiqiao.public(self.driver).clickSearchBtn() time.sleep(1) title = qiqiao.public(self.driver).getText("xpath=>//span[@class='el-pagination__total']") self.assertIn("0",title)
def test_search_by_single_choice(self): '''通过单项选择筛选页面数''' qiqiao.public(self.driver).clickExpand() qiqiao.singleChoice(self.driver).searchData("单项选择","日本") qiqiao.public(self.driver).clickSearchBtn() time.sleep(1) title = qiqiao.public(self.driver).getText("xpath=>//span[@class='el-pagination__total']") self.assertIn("1",title)
def test_onlyone(self): '''测试单行文本唯一校验''' qiqiao.public(self.driver).clickButtonInTitle("添加") qiqiao.singleLineText(self.driver).sendValue("必填_唯一", "测试") time.sleep(1) qiqiao.public(self.driver).clickSubmit() msg = qiqiao.public( self.driver).getText("xpath=>//p[@class='el-message__content']") self.assertEqual(msg, "[必填_唯一]值必须唯一")
def test_english_length_limit(self): '''测试单行文本输入英文并限制长度''' qiqiao.public(self.driver).clickButtonInTitle("添加") qiqiao.singleLineText(self.driver).sendValue("必填_唯一", "测试") qiqiao.singleLineText(self.driver).sendValue("英文5到10", "Donn") time.sleep(1) qiqiao.public(self.driver).clickSubmit() msg = qiqiao.public( self.driver).getText("xpath=>//div[@class='el-form-item__error']") self.assertEqual(msg, "字符长度必须在5和10之间")
def test_limit_size(self): '''测试数字组件限制范围''' qiqiao.public(self.driver).clickButtonInTitle("添加") qiqiao.number(self.driver).sendValue("必填唯一", 100) qiqiao.number(self.driver).sendValue("整数100到200", 20) time.sleep(0.5) qiqiao.public(self.driver).clickSubmit() msg = qiqiao.public( self.driver).getText("xpath=>//div[@class='el-form-item__error']") self.assertEqual(msg, "整数100到200的值必须在100和200之间")
def test_input_number_or_english(self): '''测试单行文本输入英文或数字''' qiqiao.public(self.driver).clickButtonInTitle("添加") qiqiao.singleLineText(self.driver).sendValue("必填_唯一", "测试") qiqiao.singleLineText(self.driver).sendValue("数字或英文2到10", "道一") time.sleep(1) qiqiao.public(self.driver).clickSubmit() msg = qiqiao.public( self.driver).getText("xpath=>//div[@class='el-form-item__error']") self.assertEqual(msg, "请输入数字或英文")
def test_combination_search(self): '''测试组合筛选页面数据''' qiqiao.public(self.driver).clickExpand() qiqiao.date(self.driver).searchData("修改时间","2020-09-13","2020-09-14") qiqiao.personSelector(self.driver).searchData("创建人", "刁惠云") qiqiao.departSelector(self.driver).searchData("部门单选","产","创新技术中心->产品研发二部") qiqiao.public(self.driver).clickSearchBtn() time.sleep(1) title = qiqiao.public(self.driver).getText("xpath=>//span[@class='el-pagination__total']") self.assertIn("0",title)
def test_onlyone(self): '''测试数字组件唯一''' qiqiao.public(self.driver).clickButtonInTitle("添加") qiqiao.number(self.driver).sendValue("必填唯一", 100) qiqiao.number(self.driver).sendValue("整数100到200", 120) time.sleep(1) qiqiao.public(self.driver).clickSubmit() msg = qiqiao.public( self.driver).getText("xpath=>//p[@class='el-message__content']") self.assertEqual(msg, "[必填唯一]值必须唯一")
def test_required(self): '''测试数字组件必填''' qiqiao.public(self.driver).clickButtonInTitle("添加") qiqiao.number(self.driver).sendValue("整数100到200", 120) time.sleep(0.5) qiqiao.public(self.driver).clickSubmit() msg = qiqiao.public( self.driver).getText("xpath=>//div[@class='el-form-item__error']") self.assertEqual(msg, "不能为空")
def test_comment_requried(self): '''测试表单评论必填''' qiqiao.public(self.driver).clickButtonInForm("详情", 1) qiqiao.public(self.driver).submitComment() msg = qiqiao.public(self.driver).getText("xpath=>//p[@class='el-message__content']") self.assertEqual(msg, "评论内容为必填") try: qiqiao.public(self.driver).F5() qiqiao.public(self.driver).acceptAlert() except NoAlertPresentException: pass
def test_comment_upload_file(self): '''测试评论上传文件''' qiqiao.public(self.driver).clickButtonInForm("详情", 1) filename = time.strftime("%Y-%m-%d_%H-%M_%S", time.localtime(time.time()))+".png" file_path = "D:\Projects\MagicAutoTestFranmework\\ui\screenshot\\"+filename qiqiao.public(self.driver).getScreenshot(file_path) qiqiao.public(self.driver).commentUploadFile(file_path) time.sleep(1) html = self.driver.page_source self.assertIn(filename,html) try: qiqiao.public(self.driver).F5() qiqiao.public(self.driver).acceptAlert() except NoAlertPresentException: pass
def test_search_by_line_text(self): '''通过单行文本筛选页面数据''' qiqiao.singleLineText(self.driver).searchData("单行文本","测试数据") time.sleep(1) title = qiqiao.public(self.driver).getText("xpath=>//span[@class='el-pagination__total']") self.assertIn("1",title)