def defineclicksubmitagain(self,num): revisemerchantname = self.activeweb.findElementByXpathAndReturnValueNum(num,self.testpage.brandnameinput,"value") self.activeweb.findElementByXpathAndScriptClickNum(num,self.testpage.merchantinfo) self.activeweb.findElementByXpathAndScriptClickNum(num,self.testpage.submitagainbutton) #断言是否有“Success” self.defineasserttextnum(num,AddMerchantSuccessPage().successindividu,AddMerchantSuccessPage().successtext) self.activeweb.findElementByXpathAndClickNum(num,AddMerchantSuccessPage().okbuttonindividu) #断言是否有“Done” self.defineasserttextnum(num, AddMerchantDonePage().done, AddMerchantDonePage().donetext) # 断言是否有“Waiting for approval” self.defineasserttextnum(num, AddMerchantDonePage().waitingforapproval, AddMerchantDonePage().waitingforapprovaltext) # 断言是否有brandnameinputtext(添加的商户名) self.defineasserttextnum(num, AddMerchantDonePage().merchantnamevalue, revisemerchantname) self.activeweb.findElementByXpathAndClickNum(num,AddMerchantDonePage().merchantlistbutton) # #断言商户列表中是否有新增加的商户名 # self.defineisintable(num,MerchantListPage().searchtableresult,revisemerchantname,1) #断言商户列表中Revise的商户的状态发生变化,右Revise变成Details revisemerchantname = "test_individu_20190415141440" self.definesearch(num, MerchantListPage().keywordselectxpath, MerchantListPage().keywordoption_merchantname_xpath, MerchantListPage().keywordselectinputxpath, revisemerchantname, True, 6, "Details")
def setUp(self): # 每条用例执行测试之前都要执行此方法 # self.jsonfile = '../../../cookiejson/cookieagent.json' # self.operationjson = OperationJson(file_path=self.jsonfile) #实例化 # self.cookie = self.operationjson.get_all_data() # print("self.cookie:%s" % self.cookie) self.activeweb = ActiveWeb() # 实例化 self.loginurl = LoginPage().pageurl self.activeweb.getUrl(self.loginurl) # 打开网址 self.activeweb.findElementByXpathAndInput(LoginPage().account, AGENT_LOGIN_ACCOUNT) self.activeweb.findElementByXpathAndInput(LoginPage().password, AGENT_LOGIN_PASSWORD) self.activeweb.findElementByXpathAndClick(LoginPage().loginbutton) self.activeweb.delayTime(3) self.testpageurl = MerchantListPage().pageurl #测试页面url self.testpagesearchbutton = MerchantListPage().searchbutton #测试页面搜索按钮 self.testpagesearchresultxpathtrue = MerchantListPage( ).searchtableresult #测试页面找到相应数据结果xpath路径 self.testpagesearchresultxpathfalse = MerchantListPage( ).searchtableresult2 #测试页面没有找到相应数据结果xpath路径
def setUpClass(cls): cls.activeweb = ActiveWeb() # 实例化 cls.loginurl = LoginPage().pageurl cls.activeweb.getUrl(cls.loginurl) # 打开网址 cls.activeweb.findElementByXpathAndInput(LoginPage().account,AGENT_LOGIN_ACCOUNT) cls.activeweb.findElementByXpathAndInput(LoginPage().password,AGENT_LOGIN_PASSWORD) cls.activeweb.findElementByXpathAndClick(LoginPage().loginbutton) cls.activeweb.delayTime(3) cls.testpage = MerchantListPage() cls.testpageurl =cls.testpage.pageurl #测试页面url cls.activeweb.getUrl(cls.testpageurl) cls.activeweb.delayTime(3)
def definesearch(self,num,selectxpath=None,selectoptiontextxpath=None,selectinputxpath=None,selectinputtext=None,isfind=False,colnum=None,checktext=None): if selectxpath !=None and selectoptiontextxpath !=None: self.activeweb.findElementByXpathAndScriptClick(selectxpath) self.activeweb.findElementByXpathAndScriptClick(selectoptiontextxpath) if selectinputxpath != None and selectinputtext !=None: self.activeweb.findElementByXpathAndInput(selectinputxpath,str(selectinputtext)) self.activeweb.findElementByXpathAndClick(MerchantListPage().searchbutton) self.activeweb.delayTime(5) if isfind: tabledic = self.activeweb.findElementByXpathAndReturnTableNum(num,MerchantListPage().searchtableresult) else: tabledic = self.activeweb.findElementByXpathAndReturnTableNum(num, MerchantListPage().searchtableresult2) for value in tabledic.values(): if str(checktext).lower() in value[int(colnum)].lower(): self.assertTrue(True) self.activeweb.outPutMyLog("在%s中存在文本信息:%s"% (value[int(colnum)],checktext)) break else: self.activeweb.outPutMyLog("在%s不存在文本信息:%s"% (value[int(colnum)],checktext)) self.assertTrue(False)
def defineaddmerchantcompany( self, num, isfictitious=False, brandnameinputtext=None, emailinputtext=None, contactnumberinputtext=None, #添加公司商户 merchanttypeselectoptionxpath=None, categoryselectoptionxpath=None, criteriaselectoptionxpath=None, siupinputtext=None, provinceselectoptionxpath=None, cityselectoptionxpath=None, districtinputtext=None, villageinputtext=None, postcodeinputtext=None, addressinputtext=None, companynameinputtext=None, officialwebsiteinputtext=None, npwptaxidinputtext=None, #新加 photosiupimagefilepath=None, photonpwpcompanyimagefilepath=None, phototdpimagefilepath=None, #更换xpath nameinputtext=None, positioninputtext=None, #新加 # npwpinputtext=None, typeidselectoptionxpath=None, #去掉 # identitynumberinputtext=None, address2inputtext=None, nationalityselectoptionxpath=None, #去掉 phoneinputtext=None, email2inputtext=None, photofullfacebustimagefilepath=None, #更换 locationphotoimagefilepath=None, photoofthecashiersdeskimagefilepath=None, otherphotoimagefilepath=None, bankselectoptionxpath=None, accountnameinputtext=None, accountnumberinputtext=None, qrindoaccountinputtext=None): # self.activeweb.writerCookies(self.cookie, LoginPage().pageurl,MerchantListPage().pageurl) if isfictitious: self.writexunicookie() self.activeweb.getUrl(self.testpageurl) self.activeweb.delayTime(3) #添加个人商户和公司商户 self.activeweb.findElementByXpathAndInputNum( num, self.testpagebrandnameinput, brandnameinputtext) #输入Brand name self.activeweb.findElementByXpathAndInputNum(num, self.testpageemailinput, emailinputtext) #输入Email self.activeweb.findElementByXpathAndInputNum( num, self.testpagecontactnumberinput, contactnumberinputtext) #输入Contact number self.activeweb.findElementByXpathAndClickOptionXpathNum( num, self.testpagemerchanttypeselect, merchanttypeselectoptionxpath) # 选择Merchant type self.activeweb.findElementByXpathAndClickOptionXpathNum( num, self.testpagecategoryselect, categoryselectoptionxpath) # 选择Category self.activeweb.findElementByXpathAndClickOptionXpathNum( num, self.testpagecriteriaselect, criteriaselectoptionxpath) # 选择Criteria self.activeweb.findElementByXpathAndInputNum(num, self.testpagesiupinput, siupinputtext) # 输入SIUP self.activeweb.findElementByXpathAndClickOptionXpathNum( num, self.testpageprovinceselect, provinceselectoptionxpath) # 选择Province self.activeweb.findElementByXpathAndClickOptionXpathNum( num, self.testpagecityselect, cityselectoptionxpath) # 选择City self.activeweb.findElementByXpathAndInputNum( num, self.testpagedistrictinput, districtinputtext) # 输入District self.activeweb.findElementByXpathAndInputNum( num, self.testpagevillageinput, villageinputtext) # 输入Village self.activeweb.findElementByXpathAndInputNum( num, self.testpagepostcodeinput, postcodeinputtext) # 输入Postcode self.activeweb.findElementByXpathAndInputNum( num, self.testpageaddressinput, addressinputtext) # 输入Address self.activeweb.findElementByXpathAndInputNum( num, self.testpagecompanynameinput, companynameinputtext) # 输入Company name #新加 self.activeweb.findElementByXpathAndInputNum( num, self.testpageofficialwebsiteinput, officialwebsiteinputtext) # 输入Official Website #新加 self.activeweb.findElementByXpathAndInputNum( num, self.testpagenpwptaxidinput, npwptaxidinputtext) # 输入NPWP/TAX ID #新加 self.activeweb.findElementByXpathAndAndFileNumVue( num, self.testpagephotosiupimage, photosiupimagefilepath) #添加Photo SIUP图片 #更换 self.activeweb.findElementByXpathAndAndFileNumVue( num, self.testpagephotonpwpcompanyimage, photonpwpcompanyimagefilepath) # 添加Photo NPWP Company图片 #更换 self.activeweb.findElementByXpathAndAndFileNumVue( num, self.testpagephototdpimage, phototdpimagefilepath) # 添加Photo TDP图片 #更换 self.activeweb.findElementByXpathAndScriptClickNum( num, self.testpagemerchantinfo) #点击Merchant info self.activeweb.findElementByXpathAndScriptClickNum( num, self.testpageownerpersoninchargeinfo ) # 点击Owner / Person in Charge info self.activeweb.findElementByXpathAndInputNum(num, self.testpagenameinput, nameinputtext) # 输入Name self.activeweb.findElementByXpathAndInputNum( num, self.testpagepositioninput, positioninputtext) # 输入Position #新加 # self.activeweb.findElementByXpathAndInputNum(num,self.testpagenpwpinput, npwpinputtext) # 输入NPWP #去掉 # self.activeweb.findElementByXpathAndClickOptionXpathNum(num,self.testpagetypeidselect,typeidselectoptionxpath) # 选择Type ID #去掉 # self.activeweb.findElementByXpathAndInputNum(num,self.testpageidentitynumberinput, identitynumberinputtext) # 输入Identity number #去掉 # self.activeweb.findElementByXpathAndInputNum(num,self.testpageaddress2input, address2inputtext) # 输入Address #去掉 # self.activeweb.findElementByXpathAndClickOptionXpathNum(num,self.testpagenationalityselect,nationalityselectoptionxpath) # 选择Nationality #去掉 self.activeweb.findElementByXpathAndInputNum( num, self.testpagephoneinput, phoneinputtext) # 输入Phone #更换 self.activeweb.findElementByXpathAndInputNum( num, self.testpageemail2input, email2inputtext) # 输入Email #更换 self.activeweb.findElementByXpathAndAndFileNumVue( num, self.testpagephotofullfacebustimage, photofullfacebustimagefilepath) # 添加Photo Full-faceBust图片 #更换 self.activeweb.findElementByXpathAndScriptClickNum( num, self.testpageownerpersoninchargeinfo ) # 点击Owner / Person in Charge info self.activeweb.findElementByXpathAndScriptClickNum( num, self.testpageprofilephotos) # 点击Profile Photos self.activeweb.findElementByXpathAndAndFileNumVue( num, self.testpagelocationphotoimage, locationphotoimagefilepath) # 添加Location Photo图片 self.activeweb.findElementByXpathAndAndFileNumVue( num, self.testpagephotoofthecashiersdeskimage, photoofthecashiersdeskimagefilepath ) # 添加Photo of the cashiers desk图片 self.activeweb.findElementByXpathAndAndFileNumVue( num, self.testpageotherphotoimage, otherphotoimagefilepath) # 添加Other Photo图片 self.activeweb.findElementByXpathAndScriptClickNum( num, self.testpageprofilephotos) # 点击Profile Photos self.activeweb.findElementByXpathAndScriptClickNum( num, self.testpagebankaccount) # 点击Bank account self.activeweb.findElementByXpathAndClickOptionXpathNum( num, self.testpagebankselect, bankselectoptionxpath) # 选择Bank self.activeweb.findElementByXpathAndInputNum( num, self.testpageaccountnameinput, accountnameinputtext) # 输入Account name self.activeweb.findElementByXpathAndInputNum( num, self.testpageaccountnumberinput, accountnumberinputtext) # 输入Account number self.activeweb.findElementByXpathAndScriptClickNum( num, self.testpagebankaccount) # 点击Bank account self.activeweb.findElementByXpathAndScriptClickNum( num, self.testpageqrindoaccount) # 点击QRindo account self.activeweb.findElementByXpathAndInputNum( num, self.testpageqrindoaccountinput, AGENT_LOGIN_ACCOUNT) # 输入QRindo account self.activeweb.findElementByXpathAndClickNum( num, self.testpagecheckbutton) #点击check按钮 self.activeweb.findElementByXpathAndClickNum( num, self.testpagesubmitbutton) # 点击submit按钮 # self.activeweb.delayTime(1000) #断言是否有“Success” # self.defineasserttextnum(num,AddMerchantSuccessPage().success,AddMerchantSuccessPage().successtext) # self.activeweb.findElementByXpathAndClickNum(num,AddMerchantSuccessPage().okbutton) #断言是否有“Done” self.defineasserttextnum(num, AddMerchantDonePage().done, AddMerchantDonePage().donetext) # 断言是否有“Waiting for approval” self.defineasserttextnum(num, AddMerchantDonePage().waitingforapproval, AddMerchantDonePage().waitingforapprovaltext) # 断言是否有brandnameinputtext(添加的商户名) self.defineasserttextnum(num, AddMerchantDonePage().merchantnamevalue, brandnameinputtext) self.activeweb.findElementByXpathAndClickNum( num, AddMerchantDonePage().merchantlistbutton) #断言商户列表中是否有新增加的商户名 self.defineisintable(num, MerchantListPage().searchtableresult, brandnameinputtext, 1)
# ---------------------------------------------------------------------- import os, django os.environ.setdefault("DJANGO_SETTINGS_MODULE", "webtestdata.settings") django.setup() # ---------------------------------------------------------------------- #独运行某一个py文件时会出现如下错误:django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.,以上内容可以解决此问题,加载django中的App import ddt from TestCaseFunction.base.activebase import ActiveWeb from TestCaseFunction.util.operation_json import OperationJson from TestCaseFunction.util.gettimestr import GetTimeStr from TestCaseFunction.autotest.config.page.agent.loginPage import LoginPage from TestCaseFunction.autotest.config.page.agent.merchantListPage import MerchantListPage merchantlist = MerchantListPage() testdata = ( (merchantlist.keyword,merchantlist.keywordtext), #-----------筛选字段-----------# (merchantlist.status_shaixuan, merchantlist.status_shaixuan_text), (merchantlist.merchantnameid,merchantlist.merchantnameidtext), #-----------表格title内容-----------# (merchantlist.loginaccount, merchantlist.loginaccounttext), (merchantlist.category,merchantlist.categorytext), (merchantlist.registrationtime, merchantlist.registrationtimetext), (merchantlist.status, merchantlist.statustext), (merchantlist.operation, merchantlist.operationtext), ) testdatatwo = ( (merchantlist.keywordtext,merchantlist.keywordselectxpath,merchantlist.keyword_merchantname,merchantlist.keyword_merchantname_text), # -----------筛选字段keyword选项内容-----------# (merchantlist.keywordtext,merchantlist.keywordselectxpath, merchantlist.keyword_merchantid, merchantlist.keyword_merchantid_text),