def setUpClass(self): self.driver = browser() self.dr = Basic(self.driver) self.btn = Button(self.dr) self.flow = Flow(self.dr) self.tp = folwType(os.path.join(DATA_PATH, 'yx_flow.xlsx'), sheet=1) self.pact_num = None
def test2_release(self): try: self.dr.click('css', '[spm="cb.yxzx.spfb"]') Button(self.dr).surebtn() except Exception: pass ProductRelease().page(self.dr)
def test3_release(self): for i in range(20): self.dr.refresh() Button(self.dr).surebtn() # self.dr.click('id', 'addBtn') # self.dr.jump_off() time.sleep(1) self.dr.js_scroll_top() ProductRelease().page(self.dr)
def page(self, driver): # 发布能力 driver.click('xpath', '//*[@id="isJoinCloud"]/div[1]/label') driver.click('class', 'cascade-text') driver.click('css', self.Type(random.randint(1, 7))['data-level-1']) driver.click('css', self.Type(random.randint(1, 7))['data-level-2']) # driver.click('css', '[data-id="10302"]') driver.click('css', '[class="cascade-confirm"]') driver.input('name', 'capandproname', '能力' + NOW + random_str(1, 2)) driver.input('name', 'chargeunit', '台') driver.input('name', 'price', random.randint(100, 1000000)) driver.input('name', 'certificate_id1', self.Type(random.randint(1, 7))['certificate_id1']) time.sleep(1) driver.click('id', 'clipBtn') driver.input('id', 'editor', random_str(22, 88)) driver.clear('name', 'address') driver.input('name', 'address', '北京') driver.click('id', 'editor') driver.click('id', 'inq-publish') Button(driver).surebtn()
def setUpClass(self): self.driver = browser() self.dr = Basic(self.driver) self.btn = Button(self.dr) self.flow = Flow(self.dr)
class persen_marketing_share_product(unittest.TestCase): @classmethod def setUpClass(self): self.driver = browser() self.dr = Basic(self.driver) self.btn = Button(self.dr) self.flow = Flow(self.dr) self.tp = folwType(os.path.join(DATA_PATH, 'yx_flow.xlsx'), sheet=1) self.pact_num = None def test1_share_product(self): method = int(self.tp['method']) marketusr = Config().get('MKTUSR') marketpsw = Config().get('MKTPSW') url = Config().get('HOME_URL') self.dr.get_url(url) Login().login(self.dr, marketusr, marketpsw) time.sleep(1) if method == 1: self.flow.team_share_product_flow('航天云网') else: self.flow.share_product_flow('航天云网') globals()['product_url'] = self.dr.get_attribute( 'id', 'firstProduct', 'value') def test2_product_inquiry(self): time.sleep(1) Logout().logout(self.dr) self.dr.get_url(product_url) buyerusr = Config().get('BUSR') buyerpsw = Config().get('BPSW') self.btn.buy() Login().login(self.dr, buyerusr, buyerpsw) while True: if self.dr.current_url() == product_url: break else: self.dr.back() self.btn.product_inquiry() ProductInquiry().page(self.dr) # 获取订单号 globals()['inq_num'] = self.dr.text( 'css', '#htCheck > div:nth-child(1) > ul.content-title.row > li.col-md-11 > span:nth-child(2) > span' ) # 获取询价主题 globals()['inq_them'] = self.dr.text( 'css', '#htCheck > div:nth-child(1) > ul.content-title.row > li.col-md-11 > span:nth-child(1)' ) # 判断是否有云端营销标签 label = self.dr.text('css', '[class="label label-warning"]') self.assertEqual('云端营销', label, label) def test3_product_quote(self): time.sleep(1) Logout().logout(self.dr) url = Config().get('QUOTE_WG_URL') self.dr.get_url(url) sellerusr = Config().get('SUSR') sellerpsw = Config().get('SPSW') Login().login(self.dr, sellerusr, sellerpsw) self.dr.input('id', 'query-1', inq_them) time.sleep(1) self.dr.click('id', 'search-btn') self.dr.click('css', '[class="confirmCash btn btn-primary btn-outline"]') ProductQuote().page(self.dr) def test4_pact_page(self): time.sleep(1) Logout().logout(self.dr) url = Config().get('PACT_GWG_URL') self.dr.get_url(url) buyerusr = Config().get('BUSR') buyerpsw = Config().get('BPSW') Login().login(self.dr, buyerusr, buyerpsw) self.dr.click('link', '我要采购') time.sleep(1) self.dr.click('link', '所有外购需求') time.sleep(1) self.dr.input('id', 'inputText', inq_them) time.sleep(1) self.dr.click( 'css', '[class="btn btn-primary btn-sm btn-outline hidden-xs btnSearch"]') self.flow.youxuan_flow() self.flow.add_buy_product_pact_flow() Pact().page(self.dr, inq_num, '40000', self.tp['pact_name'], self.tp['num']) globals()['pact_id'] = self.dr.get_attribute( 'css', '[class="content-detail row cm"]', 'data-id') def test5_approve_sell_pact(self): time.sleep(1) Logout().logout(self.dr) url = Config().get('PACT_YWG_URL') self.dr.get_url(url) sellerusr = Config().get('SUSR') sellerpsw = Config().get('SPSW') Login().login(self.dr, sellerusr, sellerpsw) time.sleep(1) pact_ID = self.dr.get_attribute('css', '[class="content-detail row cm"]', 'data-id') self.flow.sell_unapprove_flow() if pact_id != pact_ID: print('审批合同不是购买的签单合同,合同编号是:%s' % pact_ID) def test6_approve_buy_pact(self): time.sleep(1) Logout().logout(self.dr) url = Config().get('PACT_GWG_URL') self.dr.get_url(url) buyerusr = Config().get('BUSR') buyerpsw = Config().get('BPSW') Login().login(self.dr, buyerusr, buyerpsw) self.flow.buy_unapprove_unsign_flow() pact_ID = self.dr.get_attribute('css', '[class="content-detail row cm"]', 'data-id') if pact_id != pact_ID: print('审批合同不是购买的签单合同,合同编号是:%s' % pact_ID) def test7_settle(self): self.pact_num = self.dr.text( 'css', '#htTable > div > div:nth-child(1) > ul.content-title.row > li.col-md-11 > span:nth-child(2)' ) self.pact_num = self.pact_num.split(':')[1] globals()['pactNum'] = self.pact_num self.dr.refresh() self.dr.click('link', '结算管理') time.sleep(1) self.btn.enter_wg_payfor() Payfor().page(self.dr, self.pact_num, self.tp['num']) self.btn.enter_wg_settle() self.dr.input('name', 'Q_inquirytheme_SL', self.pact_num) self.dr.click('id', 'searchBtn') Settle().page(self.dr, self.tp['num']) def test8_payment(self): time.sleep(1) Logout().logout(self.dr) url = Config().get('SETTLE_YWG_URL') self.dr.get_url(url) sellerusr = Config().get('SUSR') sellerpsw = Config().get('SPSW') Login().login(self.dr, sellerusr, sellerpsw) self.flow.sure_settle_flow(pactNum, int(self.tp['num'])) self.flow.payment_flow() self.dr.input('name', 'contractCode', pactNum) self.dr.click('id', 'filter') time.sleep(2) # pact_id = "\"" + pactNum + "\"" self.dr.click('css', '[class="ht-table-btn confirmCash"]') self.btn.surebtn() i = self.dr.text('class', 'ht-modal-default-text') self.assertEqual('兑付成功', i, i) globals()['cash_num'] = self.dr.text( 'css', '#htTable > div > div:nth-child(1) > ul.content-detail.row > li.col-md-2.content-other > div > span' ) self.btn.surebtn() def test9_cash(self): time.sleep(1) Logout().logout(self.dr) url = Config().get('CASH_URL') self.dr.get_url(url) sellerusr = Config().get('SUSR') sellerpsw = Config().get('SPSW') Login().login(self.dr, sellerusr, sellerpsw) self.dr.input('name', 'cash-code', cash_num) self.dr.click('id', 'filter') self.dr.click('class', 'confirmCash') self.btn.surebtn() i = self.dr.text('class', 'ht-modal-default-text') self.assertEqual('确认兑付成功', i, i) self.btn.surebtn() @classmethod def tearDownClass(self): self.dr.quit() print('营销员账号:158015900000') print('买家账号:600022_system') print('卖家账号:600606_system')
class persen_marketing_share_product(unittest.TestCase): @classmethod def setUpClass(self): self.driver = browser() self.dr = Basic(self.driver) self.btn = Button(self.dr) self.flow = Flow(self.dr) self.tp = folwType(os.path.join(DATA_PATH, 'yx_flow.xlsx')) self.pact_num = None def test1_share_product(self): method = int(self.tp['method']) marketusr = Config().get('MKTUSR') marketpsw = Config().get('MKTPSW') url = Config().get('HOME_URL') self.dr.get_url(url) Login().login(self.dr, marketusr, marketpsw) time.sleep(1) if method == 1: self.flow.team_share_product_flow('航天云网') else: self.flow.share_product_flow('航天云网') globals()['product_url'] = self.dr.get_attribute( 'id', 'firstProduct', 'value') def test2_product_buy(self): time.sleep(1) Logout().logout(self.dr) self.dr.get_url(product_url) buyerusr = Config().get('BUSR') buyerpsw = Config().get('BPSW') self.btn.buy() Login().login(self.dr, buyerusr, buyerpsw) self.btn.buy() try: self.dr.click('id', 'save') except Exception: pass globals()['product_price'] = self.dr.text('class', 'price') ProductBuy().page(self.dr) def test3_pact_page(self): self.dr.get_url( 'http://test.etpss.casicloud.com/home/ywgzs/gyl/inquiry/WG/dataList.html' ) # 获取订单号 inq_num = self.dr.text( 'css', '#htCheck > div:nth-child(1) > ul.content-title.row > li.col-md-11 > span:nth-child(2) > span' ) # 判断是否有云端营销标签 label = self.dr.text('css', '[class="label label-warning"]') self.assertEqual('云端营销', label, label) self.flow.add_buy_product_pact_flow() Pact().page(self.dr, inq_num, product_price, self.tp['pact_name'], self.tp['num']) globals()['pact_id'] = self.dr.get_attribute( 'css', '[class="content-detail row cm"]', 'data-id') def test4_approve_sell_pact(self): time.sleep(1) Logout().logout(self.dr) url = Config().get('PACT_YWG_URL') self.dr.get_url(url) sellerusr = Config().get('SUSR') sellerpsw = Config().get('SPSW') Login().login(self.dr, sellerusr, sellerpsw) time.sleep(1) pact_ID = self.dr.get_attribute('css', '[class="content-detail row cm"]', 'data-id') self.flow.sell_unapprove_flow() if pact_id != pact_ID: print('审批合同不是购买的签单合同,合同编号是:%s' % pact_ID) def test5_approve_buy_pact(self): time.sleep(1) Logout().logout(self.dr) url = Config().get('PACT_GWG_URL') self.dr.get_url(url) buyerusr = Config().get('BUSR') buyerpsw = Config().get('BPSW') Login().login(self.dr, buyerusr, buyerpsw) self.flow.buy_unapprove_unsign_flow() pact_ID = self.dr.get_attribute('css', '[class="content-detail row cm"]', 'data-id') if pact_id != pact_ID: print('审批合同不是购买的签单合同,合同编号是:%s' % pact_ID) def test6_settle(self): self.pact_num = self.dr.text( 'css', '#htTable > div > div:nth-child(1) > ul.content-title.row > li.col-md-11 > span:nth-child(2)' ) self.pact_num = self.pact_num.split(':')[1] globals()['pactNum'] = self.pact_num self.dr.refresh() self.dr.click('link', '结算管理') time.sleep(1) self.btn.enter_wg_payfor() Payfor().page(self.dr, self.pact_num, self.tp['num']) self.btn.enter_wg_settle() self.dr.input('name', 'Q_inquirytheme_SL', self.pact_num) self.dr.click('id', 'searchBtn') Settle().page(self.dr, self.tp['num']) def test7_payment(self): time.sleep(1) Logout().logout(self.dr) url = Config().get('SETTLE_YWG_URL') self.dr.get_url(url) sellerusr = Config().get('SUSR') sellerpsw = Config().get('SPSW') Login().login(self.dr, sellerusr, sellerpsw) self.flow.sure_settle_flow(pactNum, int(self.tp['num'])) self.flow.payment_flow() self.dr.input('name', 'contractCode', pactNum) self.dr.click('id', 'filter') time.sleep(2) # pact_id = "\"" + self.pact_num + "\"" self.dr.click('css', '[class="ht-table-btn confirmCash"]') self.btn.surebtn() i = self.dr.text('class', 'ht-modal-default-text') self.assertEqual('兑付成功', i, i) globals()['cash_num'] = self.dr.text( 'css', '#htTable > div > div:nth-child(1) > ul.content-detail.row > li.col-md-2.content-other > div > span' ) self.btn.surebtn() def test8_cash(self): time.sleep(1) Logout().logout(self.dr) url = Config().get('CASH_URL') self.dr.get_url(url) sellerusr = Config().get('SUSR') sellerpsw = Config().get('SPSW') Login().login(self.dr, sellerusr, sellerpsw) self.dr.input('name', 'cash-code', cash_num) self.dr.click('id', 'filter') self.dr.click('class', 'confirmCash') self.btn.surebtn() i = self.dr.text('class', 'ht-modal-default-text') self.assertEqual('确认兑付成功', i, i) self.btn.surebtn() @classmethod def tearDownClass(self): self.dr.quit() print('营销员账号:158015900000') print('卖家账号:15801590000') print('买家账号:600022_system')
def __init__(self,driver): self.driver = driver self.btn = Button(self.driver)
class Flow(): def __init__(self,driver): self.driver = driver self.btn = Button(self.driver) def sell_unapprove_flow(self): # 卖家不审批 try: self.driver.click('css','[class="btn-primary btn-outline"]') self.driver.click('css', '[class="btn btn-primary sureBtn"]') self.driver.click('css', '[class="btn btn-primary sureBtn"]') except : print('卖家不审批失败') # self.driver.click_perform('[data-id='+"\""+pact_id+"\""+']', '[class="btn-primary btn-outline"]') def buy_unapprove_unsign_flow(self): # 买家不审批 try: self.driver.click('css', '[class="btn-primary btn-outline"]') self.btn.surebtn() self.btn.surebtn() time.sleep(2) self.driver.click('css', '[class="btn-primary btn-outline"]') self.btn.surebtn() except : print('买家不审批失败') def sure_settle_flow(self,pact_num,num=1): '''确认收款流程''' try: if num == 1: self.driver.input('name', 'Q_inquirytheme_SL', pact_num) time.sleep(1) self.driver.click('id', 'searchBtn') self.driver.click('link', '确认') self.driver.jump_off() self.driver.click('id', 'btnPaymentConfirm') self.btn.surebtn() time.sleep(80) self.btn.surebtn() else: for i in range(int(num) ): self.driver.input('name', 'Q_inquirytheme_SL', pact_num) self.driver.click('id', 'searchBtn') self.driver.click('link', '确认') self.driver.jump_off() self.driver.click('id', 'btnPaymentConfirm') self.btn.surebtn() time.sleep(60) self.btn.surebtn() except: print('确认收款失败') def share_product_flow(self,keyword,address='北京'): # 个人商品分享流程 #self.btn.enter_market(driver) self.person_product_center() self.product_selecet(keyword,address) self.join_shelf() time.sleep(1) self.btn.enter_shelf() self.driver.jump_off() def team_share_product_flow(self, keyword, address='北京'): '''团队商品分享流程''' #self.btn.enter_market() self.team_center() self.product_selecet(keyword,address) self.join_shelf() time.sleep(1) self.btn.enter_shelf() self.driver.jump_off() def share_capacity_flow(self, keyword,address='北京'): '''个人商品分享流程''' #self.btn.enter_market(driver) self.person_product_center() self.product_selecet(keyword,address) time.sleep(1) self.driver.click('css', '#capacity > span') self.join_shelf() self.btn.enter_shelf() self.driver.jump_off() time.sleep(1) self.driver.click('css', '[class="btn btn-white"]') def team_share_capacity_flow(self, keyword,address='北京'): '''个人能力分享流程''' #self.btn.enter_market(driver) self.team_center() self.product_selecet(keyword,address) self.driver.click('id', 'capacity') self.join_shelf() self.btn.enter_shelf() self.driver.jump_off() time.sleep(1) self.driver.click('css', '[class="btn btn-white"]') def add_buy_product_pact_flow(self): '''添加个人商品合同流程''' self.btn.enter_buy_pact() self.btn.add_buy_product_pact() def add_buy_capacity_pact_flow(self): # 添加个人能力合同流程 self.btn.enter_buy_pact() self.btn.add_buy_capacity_pact() def youxuan_flow(self): self.driver.click('link', '优选') self.driver.jump_off() self.driver.click('css', '[class="form-control-radio-icon"]') self.driver.click('id', 'btnConfirm') try: self.btn.surebtn() except Exception: pass self.driver.click('id', 'btnConfirm') self.btn.surebtn() def payment_flow(self): self.driver.click('link', '云端营销') self.driver.click('link', '企业兑付管理') def join_shelf(self): time.sleep(1) try: #点击加入货架 self.driver.click('css','body > div.container-cloud > div.container-main.clearfix.open-sidebar > div.main-content > div > div:nth-child(4) > div > div.store-content.hyzx.container > div > div > div:nth-child(1) > div > div.add-shelf.update_left') time.sleep(1) self.driver.click('css', '[class="btn btn-primary sureBtn"]') self.driver.click('id', 'checkShelf') # self.driver.click('link', '货架管理') except Exception: self.driver.click('css', '[class="btn btn-primary sureBtn"]') self.driver.click('css','body > div.container-cloud > div.container-main.clearfix.open-sidebar > div.main-content > div > div:nth-child(4) > div > div.store-content.hyzx.container > div > div > div:nth-child(1) > div > div.add-shelf.update_left') time.sleep(1) self.driver.click('css', '[class="btn btn-primary sureBtn"]') self.driver.click('id', 'checkShelf') # self.driver.click('link', '货架管理') def person_product_center(self): # 进入货源中心 self.driver.click('link', '货源中心') def team_center(self): self.driver.click('link', '资质申请') time.sleep(1) self.driver.click('id', 'statusImgTeam') self.driver.move_to('class', 'select-text') time.sleep(1) #driver.click('class', 'select-text') #选择团队 self.driver.click('id', 'toHYZX') def product_selecet(self,keyword, address='北京'): # 货源中心搜索 self.driver.click('link', address) self.driver.input('id', 'newKeyword', keyword) self.driver.click('class', 'new_search_btn')
driver.input('name', 'address', '底密尔') driver.click( 'css', '#popup-address > div.filter-attribute > div.filter_confirm > a') try: driver.click('id', 'confirm-btn') time.sleep(40) i = driver.text('class','ht-modal-default-text') assert i == '提交成功' driver.click('css', '[class ="btn btn-primary sureBtn"]') except Exception: driver.save_screenshot(SCREENSHOT_PATH) print('购买失败') if __name__ == '__main__': driver = browser() dr = Basic(driver) btn = Button(dr) url = Config().get('PRODUCT_BUY') dr.get_url(url) buyerusr = Config().get('BUSR') buyerpsw = Config().get('BPSW') btn.buy() Login().login(dr, buyerusr, buyerpsw) btn.buy() try: dr.click('id', 'save') except Exception: pass ProductBuy().page(dr)
class persen_marketing_share_product(unittest.TestCase): @classmethod def setUpClass(self): self.driver = browser() self.dr = Basic(self.driver) self.btn = Button(self.dr) self.flow = Flow(self.dr) self.tp = folwType(os.path.join(DATA_PATH, 'yx_flow.xlsx'), sheet=2) self.pact_num = None def test1_share_product(self): method = int(self.tp['method']) marketusr = Config().get('MKTUSR') marketpsw = Config().get('MKTPSW') url = Config().get('HOME_URL') self.dr.get_url(url) Login().login(self.dr, marketusr, marketpsw) time.sleep(1) if method == 1: self.flow.team_share_capacity_flow('航天云网') else: self.flow.share_capacity_flow('航天云网') globals()['product_url'] = self.dr.get_attribute( 'id', 'firstProduct', 'value') def test2_capacity_inquiry(self): time.sleep(1) Logout().logout(self.dr) globals()['capacity_url'] = capacity_url.replace('www', 'beta2019') self.dr.get_url(capacity_url) buyerusr = Config().get('BUSR') buyerpsw = Config().get('BPSW') self.btn.capacity_inquiry() self.dr.jump_off() Login().login(self.dr, buyerusr, buyerpsw) CapacityInquiry().page(self.dr) # 获取订单号 globals()['inq_num'] = self.dr.text( 'css', '#htCheck > div:nth-child(1) > ul.content-title.row > li.col-md-11 > span:nth-child(2) > span' ) # 获取询价主题 globals()['inq_them'] = self.dr.text( 'css', '#htCheck > div:nth-child(1) > ul.content-title.row > li.col-md-11 > span:nth-child(1)' ) # 判断是否有云端营销标签 label = self.dr.text('css', '[class="label label-warning"]') self.assertEqual('云端营销', label, label) def test3_capacity_quote(self): time.sleep(1) Logout().logout(self.dr) url = Config().get('QUOTE_WX_URL') self.dr.get_url(url) sellerusr = Config().get('SUSR') sellerpsw = Config().get('SPSW') Login().login(self.dr, sellerusr, sellerpsw) self.dr.click('css', '[class="confirmCash btn btn-primary btn-outline"]') CapacityQuote().page(self.dr, 100) def test4_pact_page(self): time.sleep(1) Logout().logout(self.dr) url = Config().get('PACT_GWX_URL') self.dr.get_url(url) buyerusr = Config().get('BUSR') buyerpsw = Config().get('BPSW') Login().login(self.dr, buyerusr, buyerpsw) self.dr.click('link', '我要采购') self.dr.click('link', '所有外协需求') self.dr.jump_off() self.flow.youxuan_flow() self.flow.add_buy_capacity_pact_flow() Pact().page(self.dr, 40000, ' 能力询价') def test5_approve_sell_pact(self): time.sleep(1) Logout().logout(self.dr) url = Config().get('PACT_YWX_URL') self.dr.get_url(url) sellerusr = Config().get('SUSR') sellerpsw = Config().get('SPSW') Login().login(self.dr, sellerusr, sellerpsw) self.flow.sell_unapprove_flow() def test6_approve_buy_pact(self): time.sleep(1) Logout().logout(self.dr) url = Config().get('PACT_GWX_URL') self.dr.get_url(url) buyerusr = Config().get('BUSR') buyerpsw = Config().get('BPSW') Login().login(self.dr, buyerusr, buyerpsw) self.flow.buy_unapprove_unsign_flow() def test7_settle(self): self.dr.click('link', '结算管理') self.btn.enter_wx_payfor() Payfor().page(self.dr) self.btn.enter_wx_settle() Settle().page(self.dr) def test8_payment(self): time.sleep(1) Logout().logout(self.dr) url = Config().get('SETTLE_YWX_URL') self.dr.get_url(url) sellerusr = Config().get('SUSR') sellerpsw = Config().get('SPSW') Login().login(self.dr, sellerusr, sellerpsw) self.flow.sure_settle_flow() self.flow.payment_flow() @classmethod def tearDownClass(cls): print('营销员账号:158015900000') print('买家账号:600022_system') print('卖家账号:600633_system')