def setUp(self): self.driver = Driver().get_driver() enterCompany = EnterCompany(self.driver) enterCompany.goToCompany() transaction_page = TransactionPage(self.driver, 'income') transaction_page.goToTransactionModule(BaseUrl) transaction_page.goToTransactionPage('记收入')
def setUp(self): self.driver = Driver().get_driver() enterCompany = EnterCompany(self.driver) enterCompany.goToCompany() self.transaction_page = TransactionPage(self.driver, 'accounttransfers') self.transaction_page.goToTransactionModule(BaseUrl) self.transaction_page.goToTransactionPage('记账户互转')
class AccountDashbaordSPec(unittest.TestCase): '''会计首页测试''' def setUp(self): self.driver = Driver().get_driver() enterCompany = EnterCompany(self.driver) enterCompany.goToCompany() def tearDown(self): self.driver.quit() def test1(self): '''结转''' dashboardPage = AccountDashbaordPage(self.driver) dashboardPage.clickDropDown(0) dashboardPage.clickIKnowButton() self.assertIn(BaseUrl + '/app/home-page/accounting', self.driver.current_url) def test2(self): '''过账''' dashboardPage = AccountDashbaordPage(self.driver) dashboardPage.clickDropDown(2) dashboardPage.clickPostButton() self.assertIn(BaseUrl + '/app/home-page/assist', self.driver.current_url) def test3(self): '''导入员工''' dashboardPage = AssistantDashbaordPage(self.driver) dashboardPage.goAssistanDashbaordPage(BaseUrl) dashboardPage.clickImportStaffButton() importFile = ImportStaffFile(self.driver) importFile.importStaffFile( 'F:\\autoTest_workspace\\python_code\\e2e-test\\test_data\\导入员工.xlsx' ) self.assertEqual(BaseUrl + '/app/salary/stuff-list', self.driver.current_url) def test4(self): '''提交审核''' dashboardPage = AssistantDashbaordPage(self.driver) dashboardPage.goAssistanDashbaordPage(BaseUrl) dashboardPage.clickSubmit() self.assertEqual(BaseUrl + '/app/home-page/accounting', self.driver.current_url)
class RecordIncomePageSpec(unittest.TestCase): '''记收入页面测试''' @classmethod def setUpClass(self): self.driver = Driver().get_driver() enterCompany = EnterCompany(self.driver) enterCompany.goToCompany() self.transaction_page = TransactionPage(self.driver, 'income') self.transaction_page.recordIncomeUrl(BaseUrl) @classmethod def tearDownClass(self): self.driver.quit() def test1(self): '''不填写信息点-击保存并更新按钮''' self.transaction_page.clickSaveAndAddButton() alertInfo = self.driver.find_element_by_xpath( '//*[@id="body"]/detail/income/div/div[1]/alert/div').text[-8:] self.assertEqual('请填写交易账户!', alertInfo) def test2(self): '''不填写信息-点击保存按钮''' self.transaction_page.clickSaveButton() alertInfo = self.driver.find_element_by_xpath( '//*[@id="body"]/detail/income/div/div[1]/alert/div').text[-8:] self.assertEqual('请填写交易账户!', alertInfo) def test3(self): '''填写交易账户-点击保存按钮''' self.transaction_page.setAccount('现金') self.transaction_page.clickSaveButton() sleep(2) alertInfo = self.driver.find_element_by_xpath( '//*[@id="body"]/detail/income/div/div[1]/alert/div').text[-7:] self.assertEqual('金额不能为0!', alertInfo) def test4(self): '''填写类别-点击保存按钮''' self.transaction_page.setCategory(['1', '1']) self.transaction_page.clickSaveButton() alertInfo = self.driver.find_element_by_xpath( '//*[@id="body"]/detail/income/div/div[1]/alert/div').text[-7:] self.assertEqual('金额不能为0!', alertInfo) def test5(self): '''填写金额为0-点击保存按钮''' self.transaction_page.setMoney('0') self.transaction_page.clickSaveButton() sleep(2) alertInfo = self.driver.find_element_by_xpath( '//*[@id="body"]/detail/income/div/div[1]/alert/div').text[-7:] self.assertEqual('金额不能为0!', alertInfo) def test6(self): '''填写备注-点击保存按钮''' pass
def setUp(self): self.driver = Driver().get_driver() enterCompany = EnterCompany(self.driver) enterCompany.goToCompany() invoice_page = InvoicePage(self.driver, 'output') invoice_page.goToInvoice(BaseUrl)
class RecordOutputInvoiceSpec(unittest.TestCase): ''' 记开票测试 ''' def setUp(self): self.driver = Driver().get_driver() enterCompany = EnterCompany(self.driver) enterCompany.goToCompany() invoice_page = InvoicePage(self.driver, 'output') invoice_page.goToInvoice(BaseUrl) def test1(self): '''成功记录一笔开票-普票''' outputInvoicePublic = ['1', '普票', '税控自开', '(个)内部代表'] outputInvoiceNum = self.invoiceNum() outputInvoiceItems = [['1', '1'], '管理部门', '5%', '41111', '普票-税控自开-商品销售-5%-管理部门41111'] invoice_page = InvoicePage(self.driver, 'output') invoice_page.recordOutputInvoice(outputInvoicePublic, outputInvoiceNum, outputInvoiceItems) def test2(self): '''成功记录多笔开票记录测试''' invoice_page = InvoicePage(self.driver, 'output') invoiceNumList = [] for i in range(0, 12): invoiceNumList.append(self.invoiceNum()) wb = xlrd.open_workbook( os.path.dirname(__file__) + '/' + '../../test_data/' + '发票.xlsx') sh = wb.sheet_by_name(u'记开票测试数据') for i, invoiceNum in zip(range(1, sh.nrows), invoiceNumList): sourceRowList = sh.row_values(i) targetList = CategoryMap().outputInvoiceCategeoryMapList( sourceRowList) invoice_page.recordOutputInvoice(targetList[:4], invoiceNum, targetList[4:]) invoice_page.goToInvoiceList(BaseUrl) self.assertEqual(BaseUrl + '/app/invoice/output-invoice', self.driver.current_url) # def test2(self): # '''记所有类别的收票-专票''' # invoice_page = InvoicePage(self.driver,'input') # specialPublicInvoice = ['1','专票','内部代表'] # invoiceNumList = [] # for i in range(0,33): # invoiceNumList.append(self.invoiceNum()) # for specialItems,invoiceNum in zip(RecordSpecialIncomeInvoiceData,invoiceNumList): # invoice_page.recordSpecialIncomeInvoice(specialPublicInvoice,invoiceNum,specialItems) # invoice_page.goToInvoiceList(BaseUrl) # self.assertEqual(BaseUrl + '/app/invoice/input-invoice',self.driver.current_url) #生成8位随机整数 def invoiceNum(self): invoiceNum = '' for i in range(0, 8): invoiceNum = invoiceNum + str(random.randint(0, 9)) return invoiceNum def tearDown(self): self.driver.quit()
class RecordIncomeSpec(unittest.TestCase): ''' 记收入测试 ''' def setUp(self): self.driver = Driver().get_driver() enterCompany = EnterCompany(self.driver) enterCompany.goToCompany() transaction_page = TransactionPage(self.driver, 'income') transaction_page.goToTransactionModule(BaseUrl) transaction_page.goToTransactionPage('记收入') def test1(self): '''全空校验''' transaction_page = TransactionPage(self.driver, 'income') transaction_page.clickSaveButton() self.assertEqual( '请填写交易账户!', self.driver.find_element_by_xpath( '//*[@id="body"]/detail/income/div/div[1]/alert/div').text[-8:] ) def test2(self): '''交易账户-空校验''' transaction_page = TransactionPage(self.driver, 'income') transaction_page.setCategory(['1', '1']) transaction_page.setMoney('123') transaction_page.clickSaveButton() self.assertEqual( '请填写交易账户!', self.driver.find_element_by_xpath( '//*[@id="body"]/detail/income/div/div[1]/alert/div').text[-8:] ) def test3(self): '''类别-空校验''' transaction_page = TransactionPage(self.driver, 'income') transaction_page.setAccount('现金') transaction_page.setMoney('111') transaction_page.clickSaveButton() self.assertEqual( '请填写完整!', self.driver.find_element_by_xpath( '//*[@id="body"]/detail/income/div/div[1]/alert/div').text[-6:] ) def test4(self): '''金额-空校验''' transaction_page = TransactionPage(self.driver, 'income') transaction_page.setCategory(['1', '1']) transaction_page.setAccount('现金') transaction_page.clickSaveButton() self.assertEqual( '金额不能为0!', self.driver.find_element_by_xpath( '//*[@id="body"]/detail/income/div/div[1]/alert/div').text[-7:] ) # self.assertEqual('请填写完整!',self.driver.find_element_by_xpath('//*[@id="body"]/detail/income/div/div[1]/alert/div').text[-6:]) def test5(self): '''金额为0测试''' transaction_page = TransactionPage(self.driver, 'income') transaction_page.setCategory(['1', '1']) transaction_page.setAccount('现金') transaction_page.setMoney('0') transaction_page.clickSaveButton() self.assertEqual( '金额不能为0!', self.driver.find_element_by_xpath( '//*[@id="body"]/detail/income/div/div[1]/alert/div').text[-7:] ) def test6(self): '''成功记一笔收入测试''' transaction_page = TransactionPage(self.driver, 'income') transaction = ['1', '现金', '(个)内部代表'] items1 = [['1', '1'], '111', '利息收入'] transaction_page.recordTransaction(transaction, items1) self.assertEqual( '保存成功', self.driver.find_element_by_xpath( '//*[@id="body"]/detail/income/div/div[1]/alert/div').text[-4:] ) def test7(self): '''成功记两笔明细收入测试''' transaction_page = TransactionPage(self.driver, 'income') publicTransaction = ['1', '现金', '内部代表'] items1 = [['1', '1'], '111', '利息收入'] items2 = [['2', '1'], '121', '资金往来'] transaction_page.setPublicTransaction(publicTransaction) transaction_page.setTransactionItems(items1) transaction_page.clickAddItems() transaction_page.setItemsNumber('2') transaction_page.setTransactionItems(items2) transaction_page.clickSaveButton() self.assertEqual(BaseUrl + '/app/transaction/list', self.driver.current_url) def test8(self): '''成功记所有类别收入测试''' transaction_page = TransactionPage(self.driver, 'income') wb = xlrd.open_workbook( os.path.dirname(__file__) + '/' + '../../test_data/' + '收支.xlsx') sh = wb.sheet_by_name(u'记收入测试数据') for i in range(1, sh.nrows): sourceRowList = sh.row_values(i) targetList = CategoryMap().incomeCategoryMapList(sourceRowList) transaction_page.recordTransaction(targetList[:3], targetList[3:]) transaction_page.goToTransactionModule(BaseUrl) self.assertEqual(BaseUrl + '/app/transaction/list', self.driver.current_url) def tearDown(self): self.driver.quit()
class RecordTransterSpec(unittest.TestCase): ''' 记账户互转测试 ''' def setUp(self): self.driver = Driver().get_driver() enterCompany = EnterCompany(self.driver) enterCompany.goToCompany() self.transaction_page = TransactionPage(self.driver, 'accounttransfers') self.transaction_page.goToTransactionModule(BaseUrl) self.transaction_page.goToTransactionPage('记账户互转') def test1(self): '''全空校验''' self.transaction_page.transferClickSaveButton() self.assertEqual( '账户不能为空', self.driver.find_element_by_xpath( '//*[@id="body"]/detail/accounttransfers/div/div[1]/alert/div' ).text[-6:]) def test2(self): '''记账日期空校验''' self.transaction_page.setFundFlow('现金', '招商银行') self.transaction_page.setTransferMoney('111') self.transaction_page.deleteDate() self.transaction_page.transferClickSaveButton() self.assertEqual( '请填写记账日期!', self.driver.find_element_by_xpath( '//*[@id="body"]/detail/accounttransfers/div/div[1]/alert/div' ).text[-8:]) def test3(self): '''转出账户-空校验''' self.transaction_page.setTransferIn('招商银行') self.transaction_page.setTransferMoney('123') self.transaction_page.transferClickSaveButton() self.assertEqual( '账户不能为空', self.driver.find_element_by_xpath( '//*[@id="body"]/detail/accounttransfers/div/div[1]/alert/div' ).text[-6:]) def test4(self): '''转入账户-空校验''' self.transaction_page.setTransferOut('招商银行') self.transaction_page.setTransferMoney('123') self.transaction_page.transferClickSaveButton() self.assertEqual( '账户不能为空', self.driver.find_element_by_xpath( '//*[@id="body"]/detail/accounttransfers/div/div[1]/alert/div' ).text[-6:]) def test5(self): '''资金流向账户不能相同测试''' self.transaction_page.setFundFlow('现金', '现金') self.transaction_page.setTransferMoney('123') self.transaction_page.transferClickSaveButton() self.assertEqual( '账户不能相同', self.driver.find_element_by_xpath( '//*[@id="body"]/detail/accounttransfers/div/div[1]/alert/div' ).text[-6:]) def test6(self): '''金额-空校验''' self.transaction_page.setFundFlow('招商银行', '现金') self.transaction_page.transferClickSaveButton() self.assertEqual( '金额不能为0', self.driver.find_element_by_xpath( '//*[@id="body"]/detail/accounttransfers/div/div[1]/alert/div' ).text[-6:]) def test7(self): '''成功记一笔账户互转测试''' transferPara = ['1', '现金', '招商银行', '1', '现金-招商银行1'] self.transaction_page.recordTransfer(transferPara) self.assertEqual( '保存成功', self.driver.find_element_by_xpath( '//*[@id="body"]/detail/accounttransfers/div/div[1]/alert/div' ).text[-4:]) def test8(self): '''成功12笔账户互转测试[现金,银行,微信,支付宝]''' wb = xlrd.open_workbook( os.path.dirname(__file__) + '/' + '../../test_data/' + '收支.xlsx') sh = wb.sheet_by_name(u'记账户互转测试数据') for i in range(1, sh.nrows): sourceRowList = sh.row_values(i) self.transaction_page.recordTransfer(sourceRowList) self.transaction_page.goToTransactionModule(BaseUrl) self.assertEqual(BaseUrl + '/app/transaction/list', self.driver.current_url) def tearDown(self): self.driver.quit()
def setUp(self): self.driver = Driver().get_driver() enterCompany = EnterCompany(self.driver) enterCompany.goToCompany()
class AssistantDashbaordSPec(unittest.TestCase): '''助理首页测试''' # @classmethod # def setUpClass(self): # self.driver = Driver # # self.driver = webdriver.Chrome() # wb = xlrd.open_workbook(os.path.dirname(__file__) + '/../../test_data/' + '创建公司.xlsx') # loginSh = wb.sheet_by_name(u'登陆账号') # loginData = loginSh.row_values(1) # wb1 = load_workbook('写入数据.xlsx') # sheet = wb1.get_sheet_by_name('已创建的公司') # companyName = sheet['A2'].value # loginData.append(companyName) # EnterCompany(self.driver,[BaseUrl,loginData]) # @classmethod # def tearDownClass(self): # self.driver.quit() def setUp(self): self.driver = Driver().get_driver() enterCompany = EnterCompany(self.driver) enterCompany.goToCompany() def tearDown(self): self.driver.quit() def test1(self): '''导入开票''' dashboardPage = AssistantDashbaordPage(self.driver) dashboardPage.clickImportOutputInvoiceButton() importFile = ImportOutputInvoiceFile(self.driver) importFile.importOutputInvoiceFile( 'F:\\autoTest_workspace\\python_code\\e2e-test\\test_data\\一般纳税人开票导入.xlsx' ) self.assertEqual(BaseUrl + '/app/invoice/output-invoice', self.driver.current_url) def test2(self): '''导入对账单''' dashboardPage = AssistantDashbaordPage(self.driver) dashboardPage.goAssistanDashbaordPage(BaseUrl) dashboardPage.clickChooseAccountImport() importFile = ImportBankBillFile(self.driver) importFile.importMapping( 'F:\\autoTest_workspace\\python_code\\e2e-test\\test_data\\导入招商银行对账单.xlsx' ) self.assertIn(BaseUrl + '/app/reconcile/detail/history', self.driver.current_url) def test3(self): '''导入员工''' dashboardPage = AssistantDashbaordPage(self.driver) dashboardPage.goAssistanDashbaordPage(BaseUrl) dashboardPage.clickImportStaffButton() importFile = ImportStaffFile(self.driver) importFile.importStaffFile( 'F:\\autoTest_workspace\\python_code\\e2e-test\\test_data\\导入员工.xlsx' ) self.assertEqual(BaseUrl + '/app/salary/stuff-list', self.driver.current_url) def test4(self): '''提交审核''' dashboardPage = AssistantDashbaordPage(self.driver) dashboardPage.goAssistanDashbaordPage(BaseUrl) dashboardPage.clickSubmit() self.assertEqual(BaseUrl + '/app/home-page/accounting', self.driver.current_url)
def setUp(self): self.driver = Driver().get_driver() enterCompany = EnterCompany(self.driver) enterCompany.goToCompany() fixedassets_page = FixedassetsPage(self.driver, 'fixed') fixedassets_page.goToRecordFixedassetsPage(BaseUrl)
class RecordFixedSpec(unittest.TestCase): ''' 记固定资产测试 ''' def setUp(self): self.driver = Driver().get_driver() enterCompany = EnterCompany(self.driver) enterCompany.goToCompany() fixedassets_page = FixedassetsPage(self.driver, 'fixed') fixedassets_page.goToRecordFixedassetsPage(BaseUrl) def tearDown(self): self.driver.quit() # @classmethod # def setUpClass(self): # # self.driver = Driver # self.driver = webdriver.Chrome() # EnterCompany(self.driver,Environment) # fixedassets_page = FixedassetsPage(self.driver,'fixed') # fixedassets_page.goToRecordFixedassetsPage(BaseUrl) # @classmethod # def tearDownClass(self): # self.driver.quit() def test1(self): '''成功记一笔固定资产-普票''' fixedassets_page = FixedassetsPage(self.driver, 'fixed') fixedParaPublic = ['1', '普票', '管理部门', '(个)内部代表'] fixedParaItems = [ 'iphoneX', '电子设备', '1', '6888', '固定-普票-管理部门-内部代表-电子设备' ] fixedassets_page.recordFixedassetsComm( [fixedParaPublic, fixedParaItems]) fixedassets_page.goToFixedassetsList(BaseUrl) self.assertEqual(BaseUrl + '/app/fixed-assets/list', self.driver.current_url) def test2(self): '''成功记一笔固定资产-专票''' fixedassets_page = FixedassetsPage(self.driver, 'fixed') fixedParaPublic = ['1', '专票', '管理部门', '(个)内部代表', '17%', '固定资产'] fixedParaItems = [ 'iphone8', '电子设备', '1', '6800', '固定-普票-管理部门-内部代表-电子设备' ] fixedassets_page.recordFixedassetsSpec( [fixedParaPublic, fixedParaItems], self.invoiceNum()) fixedassets_page.goToFixedassetsList(BaseUrl) self.assertEqual(BaseUrl + '/app/fixed-assets/list', self.driver.current_url) def test3(self): '''成功记录多笔固定资产-普票记录测试''' fixedassets_page = FixedassetsPage(self.driver, 'fixed') wb = xlrd.open_workbook( os.path.dirname(__file__) + '/' + '../../test_data/' + '固定资产.xlsx') sh = wb.sheet_by_name(u'记固定资产普票测试数据') for i in range(1, sh.nrows): sourceRowList = sh.row_values(i) targetPara = [sourceRowList[:4], sourceRowList[4:]] fixedassets_page.recordFixedassetsComm(targetPara) fixedassets_page.goToFixedassetsList(BaseUrl) self.assertEqual(BaseUrl + '/app/fixed-assets/list', self.driver.current_url) def test4(self): '''成功记录多笔固定资产-专票记录测试''' fixedassets_page = FixedassetsPage(self.driver, 'fixed') fixedassets_page.goToRecordFixedassetsPage(BaseUrl) invoiceNumList = [] for i in range(0, 10): invoiceNumList.append(self.invoiceNum()) wb = xlrd.open_workbook( os.path.dirname(__file__) + '/' + '../../test_data/' + '固定资产.xlsx') sh = wb.sheet_by_name(u'记固定资产专票测试数据') for i, invoiceNum in zip(range(1, sh.nrows), invoiceNumList): sourceRowList = sh.row_values(i) targetPara = [sourceRowList[:5], sourceRowList[5:]] fixedassets_page.recordFixedassetsSpec(targetPara, invoiceNum) fixedassets_page.goToFixedassetsList(BaseUrl) self.assertEqual(BaseUrl + '/app/fixed-assets/list', self.driver.current_url) #生成8位随机整数 def invoiceNum(self): invoiceNum = '' for i in range(0, 8): invoiceNum = invoiceNum + str(random.randint(0, 9)) return invoiceNum
def setUpClass(self): self.driver = Driver().get_driver() enterCompany = EnterCompany(self.driver) enterCompany.goToCompany() self.transaction_page = TransactionPage(self.driver, 'income') self.transaction_page.recordIncomeUrl(BaseUrl)
class RecordIntangibleSpec(unittest.TestCase): ''' 记无形资产测试 ''' def setUp(self): self.driver = Driver().get_driver() enterCompany = EnterCompany(self.driver) enterCompany.goToCompany() fixedassets_page = FixedassetsPage(self.driver,'intangible') fixedassets_page.goToRecordFixedassetsPage(BaseUrl) def test1(self): '''成功记一笔无形资产-普票''' fixedassets_page = FixedassetsPage(self.driver,'intangible') fixedParaPublic = ['1','普票','管理部门','(个)内部代表'] fixedParaItems = ['管有账','软件','1','888','无形-普票-管理部门-内部代表-软件'] fixedassets_page.recordFixedassetsComm([fixedParaPublic,fixedParaItems]) fixedassets_page.goToFixedassetsList(BaseUrl) self.assertEqual(BaseUrl + '/app/fixed-assets/intangible-list',self.driver.current_url) def test2(self): '''成功记一笔无形资产-专票''' fixedassets_page = FixedassetsPage(self.driver,'intangible') fixedParaPublic = ['1','专票','管理部门','(个)内部代表','17%','无形资产'] fixedParaItems = ['智商','知识产权(IP)','1','88','无形-专票-管理部门-内部代表-知识产权(IP)'] fixedassets_page.recordFixedassetsSpec([fixedParaPublic,fixedParaItems],self.invoiceNum()) fixedassets_page.goToFixedassetsList(BaseUrl) self.assertEqual(BaseUrl + '/app/fixed-assets/intangible-list',self.driver.current_url) def test3(self): '''成功记录多笔无形资产-普票记录测试''' fixedassets_page = FixedassetsPage(self.driver,'intangible') wb = xlrd.open_workbook(os.path.dirname(__file__) + '/' + '../../test_data/' + '固定资产.xlsx') sh = wb.sheet_by_name(u'记无形资产普票测试数据') for i in range(1,sh.nrows): sourceRowList = sh.row_values(i) targetPara = [sourceRowList[:4],sourceRowList[4:]] fixedassets_page.recordFixedassetsComm(targetPara) fixedassets_page.goToFixedassetsList(BaseUrl) self.assertEqual(BaseUrl + '/app/fixed-assets/intangible-list',self.driver.current_url) def test4(self): '''成功记录多笔无形资产-专票记录测试''' fixedassets_page = FixedassetsPage(self.driver,'intangible') invoiceNumList = [] for i in range(0,10): invoiceNumList.append(self.invoiceNum()) wb = xlrd.open_workbook(os.path.dirname(__file__) + '/' + '../../test_data/' + '固定资产.xlsx') sh = wb.sheet_by_name(u'记无形资产专票测试数据') for i,invoiceNum in zip(range(1,sh.nrows),invoiceNumList): sourceRowList = sh.row_values(i) targetPara = [sourceRowList[:5],sourceRowList[5:]] fixedassets_page.recordFixedassetsSpec(targetPara,invoiceNum) fixedassets_page.goToFixedassetsList(BaseUrl) self.assertEqual(BaseUrl + '/app/fixed-assets/intangible-list',self.driver.current_url) #生成8位随机整数 def invoiceNum(self): invoiceNum = '' for i in range(0,8) : invoiceNum = invoiceNum + str(random.randint(0,9)) return invoiceNum def tearDown(self): self.driver.quit()