def setUpClass(self): self.dr = webdriver.Chrome() self.dr.maximize_window() project_id = create_data.createdata(self.dr) self.proinfo_p = ProjetInfo(self.dr) self.dr.get(self.proinfo_p.url + project_id) #self.dr.get("http://192.168.3.105/licai/60232") time.sleep(10) self.create_p = CreateNew(self.dr)
class LoanUserInfoTest(unittest.TestCase): @classmethod def setUpClass(self): self.dr = webdriver.Chrome() self.dr.maximize_window() self.dr.implicitly_wait(10) # 后台需先登录 self.login_p = LoginPage(self.dr) self.login_p.open() self.login_p.login() # 创建新标 self.createpro_p = CreateNew(self.dr) self.createpro_p.open() self.createpro_p.createnewproject() self.loanuserinfo_p = self.createpro_p.loanuserinfo() self.loanuserinfo_p.submitform() self.LU = LoanUserInfo(self.dr) @parameterized.expand([ ('test_nativeProvince', 'get_nativeProvince', 'nativeProvince'), ('test_companyEntryTime', 'get_companyEntryTime', 'companyEntryTime'), ('test_currentAddress', 'get_currentAddress', 'currentAddress'), ('test_ethnic', 'get_ethnic', 'ethnic'), ('test_educationLevel', 'get_educationLevel', 'educationLevel'), ('test_maritalStatus', 'get_maritalStatus', 'maritalStatus'), ('test_yearOfService', 'get_yearOfService', 'yearOfService'), ('test_get_quarters', 'get_quarters', 'quarters'), ('test_natureOfCompany', 'get_natureOfCompany', 'natureOfCompany'), ('test_get_industry', 'get_industry', 'industry'), ('test_get_wage', 'get_wage', 'wage'), ('test_get_province', 'get_province', 'province'), ('test_get_city', 'get_city', 'city'), ]) def test_loanuserinfo(self, name, method, data): """借款人信息保存成功""" self.assertEqual(self.LU.get_all_loanuserinfo(method), GetData[data].value) # def test_companyEntryTime(self): # self.assertEqual(self.LU.get_companyEntryTime(), GetData.companyEntryTime.value) # self.assertEqual(self.LU.get_currentAddress(), GetData.currentAddress.value) # self.assertEqual(self.LU.get_ethnic(), GetData.ethnic.value) # self.assertEqual(self.LU.get_educationLevel(), GetData.educationLevel.value) # self.assertEqual(self.LU.get_maritalStatus(), GetData.maritalStatus.value) # self.assertEqual(self.LU.get_yearOfService(), GetData.yearOfService.value) # self.assertEqual(self.LU.get_quarters(), GetData.quarters.value) # self.assertEqual(self.LU.get_natureOfCompany(), GetData.natureOfCompany.value) # self.assertEqual(self.LU.get_industry(), GetData.industry.value) # self.assertEqual(self.LU.get_wage(), GetData.wage.value) # self.assertEqual(self.LU.get_province(), GetData.province.value) # self.assertEqual(self.LU.get_city(), GetData.city.value) @classmethod def tearDownClass(self): self.dr.quit()
def createdata(driver): login_p = LoginPage(driver) create_p = CreateNew(driver) # 登录操作 login_p.open() login_p.login() # 创建标的 create_p.open() # create_p.createnewproject(project_name="接口测试信3",financingMaturity="1",project_category="企易融", # contractType="企易融_企易融协议",userName="******") create_p.createnewproject(project_name="接口测试信3", financingMaturity="12") # 填写借款人信息 loanuser_p = create_p.loanuserinfo() loanuser_p.submitform() # 上传图片 upload_p = create_p.uploadimgb() upload_p.uploadimage() # 改变项目状态 prosta_p = create_p.projectstatus() prosta_p.changeprosta_yianpai() prosta_p.changeprosta_kaifang() # 获取标id url = driver.current_url project_id = url.split("/")[-1] return project_id
def setUp(self): self.dr = webdriver.Chrome() self.dr.maximize_window() self.dr.implicitly_wait(10) # 后台需先登录 self.login_p = LoginPage(self.dr) self.login_p.open() self.login_p.login() # 创建新标 self.createpro_p = CreateNew(self.dr) self.createpro_p.open() self.createpro_p.createnewproject()
def setUpClass(self): self.dr = webdriver.Chrome() self.dr.maximize_window() self.dr.implicitly_wait(10) # 后台需先登录 self.login_p = LoginPage(self.dr) self.login_p.open() self.login_p.login() # 创建新标 self.createpro_p = CreateNew(self.dr) self.createpro_p.open() self.createpro_p.createnewproject() self.loanuserinfo_p = self.createpro_p.loanuserinfo() self.loanuserinfo_p.submitform() self.LU = LoanUserInfo(self.dr)
class UploadImgTest(unittest.TestCase): def setUp(self): self.dr = webdriver.Chrome() self.dr.maximize_window() self.dr.implicitly_wait(10) # 后台需先登录 self.login_p = LoginPage(self.dr) self.login_p.open() self.login_p.login() # 创建新标 self.createpro_p = CreateNew(self.dr) self.createpro_p.open() self.createpro_p.createnewproject() def test_uploadimg(self): self.upload_p = self.createpro_p.uploadimgb() self.upload_p.uploadimage() def tearDown(self): self.dr.quit()
class ProStatusTest(unittest.TestCase): def setUp(self): self.dr = webdriver.Chrome() self.dr.maximize_window() self.dr.implicitly_wait(10) # 后台需先登录 self.login_p = LoginPage(self.dr) self.login_p.open() self.login_p.login() # 创建新标 self.createpro_p = CreateNew(self.dr) self.createpro_p.open() self.createpro_p.createnewproject() def test_prostatus(self): self.prostat_p = self.createpro_p.projectstatus() self.prostat_p.changeprosta_yianpai() self.prostat_p.changeprosta_kaifang() def tearDown(self): #self.dr.quit() print("end")
class ProjectInfoTest(unittest.TestCase): """测试前台项目详情""" @classmethod def setUpClass(self): self.dr = webdriver.Chrome() self.dr.maximize_window() project_id = create_data.createdata(self.dr) self.proinfo_p = ProjetInfo(self.dr) self.dr.get(self.proinfo_p.url + project_id) #self.dr.get("http://192.168.3.105/licai/60232") time.sleep(10) self.create_p = CreateNew(self.dr) # 前台项目信息填写成功 def test1_projecttype_success(self): """项目类型前后台一致""" pt = self.proinfo_p.project_type().text self.assertEqual(pt, u'信易融') def test2_prodeadline_success(self): """借款期限一致""" pd = self.proinfo_p.project_deadline().text self.assertEqual(pd, u'12个月') def test3_proamount_success(self): """借款金额一致""" pa = self.proinfo_p.project_amount().text self.assertEqual(pa, '5000.00') def test4_prouse_success(self): """借款用途一致""" pu = self.proinfo_p.project_use().text self.assertEqual(pu, u'资金用途测试') def test5_proAddr_success(self): """签约地点一致""" pA = self.proinfo_p.project_Addr().text self.assertEqual(pA, u'签约地址测试') def test6_prosartt_success(self): """募集开始时间一致""" ps = self.proinfo_p.project_sartt().text self.st = self.create_p.start_time() self.assertIn(ps, self.st) def test7_valuedate_success(self): """起息日""" vd = self.proinfo_p.value_date().text vt = self.st + timedelta(days=1) self.assertIn(vd, vt) def test8_bidamount_success(self): """最小出借金额一致""" ba = int(self.proinfo_p.bid_amount().text) self.assertIn(100, ba) def test9_repaytype_success(self): """还款方式一致""" rt = self.proinfo_p.repayment_type().text self.assertIn(u'等额本息', rt) def test10_repayorigin_success(self): """还款来源一致""" ro = self.proinfo_p.repayment_origin().text self.assertEqual(ro, u'还款来源测试') def test11_repayassurance_success(self): """还款保障措施一致""" ra = self.proinfo_p.repayment_assurance().text self.assertEqual(ra, u'还款保障措施测试') def test12_riskrating_success(self): """项目风险评估级别一致""" rr = self.proinfo_p.risk_rating().text self.assertIn('AAA', rr) def test13_edubackground(self): """借款人学历一致""" eb = self.proinfo_p.education_background().text self.assertEqual(eb, u'本科') def test14_marriagestatus_success(self): """借款人婚姻状况一致""" ms = self.proinfo_p.marriage_status().text self.assertEqual(ms, u'未婚') def test15_industryinfo_success(self): """从事行业一致""" ii = self.proinfo_p.industry_info().text self.assertEqual(ii, u'创造业') def test16_enterproperty_success(self): """企业性质一致""" ep = self.proinfo_p.enterprise_property().text self.assertEqual(ep, u'国有企业') def test17_positioninfo_success(self): """岗位职务一致""" pi = self.proinfo_p.position_info().text self.assertEqual(pi, u'股东') def test18_incomemonthly_success(self): """月收入一致""" im = self.proinfo_p.income_monthly().text self.assertEqual(im, u'30000元以上') def test19_houseRadios_success(self): """是否有房一致""" hR = self.proinfo_p.house_Radios().text self.assertEqual(hR, u'有') def test20_houseloan_success(self): """是否有房贷一致""" hl = self.proinfo_p.house_loan().text self.assertEqual(hl, u'有') def test21_carRadios_success(self): """是否有车一致""" cR = self.proinfo_p.car_Radios().text self.assertEqual(cR, u'有') def test22_carloan_success(self): """是否有车贷一致""" cl = self.proinfo_p.car_loan().text self.assertEqual(cl, u'有') def test23_livingcity_success(self): """与后台-详细信息-签约地址一致""" lc = self.proinfo_p.living_city().text self.assertEqual(lc, u'签约地址测试') @classmethod def tearDownClass(self): self.dr.quit()