def toubiao(): con = Bankunion_proc() biao_id = con.back_biaoid(bankname=domain, bidstatus=16, value_way=2, product_type=1) login_bank.login_bank(self, username, password, domain) driver.get(base_url + '/bid/content/' + str(biao_id)) #跳转到标详情页面 elements = bank_page.woyaotouzi_tzlb(self) #投标前投标人数 toubiao_num_before = int( driver.find_element_by_css_selector( "h3.bright span#count").text) elements.get("toubiaojine").send_keys("100") elements.get("lijitoubiao").click() driver.find_element_by_css_selector( "div.aui_buttons button.aui_state_highlight[type='button']" ).click() time.sleep(2) #投标后人投标人数 toubiao_num_after = int( driver.find_element_by_css_selector( "h3.bright span#count").text) self.assertEqual(toubiao_num_before + 1, toubiao_num_after, u"投标记录未增加")
def test_toubiaochaoe(self): u"""测试超额投标""" driver = self.driver con = Bankunion_proc() def toubiao(): con = Bankunion_proc() biao_id = con.back_biaoid(bankname=domain, bidstatus=16, value_way=2, product_type=1) login_bank.login_bank(self, username, password, domain) driver.get(base_url + '/bid/content/' + str(biao_id)) #跳转到标详情页面 elements = bank_page.woyaotouzi_tzlb(self) #已超额,请重新输入! jine = int(return_bidconf('borrowamount')) * 10000 + 100 elements.get("toubiaojine").send_keys("%s" % jine) elements.get("lijitoubiao").click() time.sleep(2) chaoetishi = driver.find_element_by_css_selector( "table.aui_dialog tbody tr td.aui_main div.aui_content").text self.assertEqual(u"已超额,请重新输入!", chaoetishi, u"超额投标失败") time.sleep(1) biao_id = con.back_biaoid(bankname=domain, bidstatus=16, value_way=2, product_type=1) if biao_id: toubiao() else: yicixingjinjian.public_yicixing(self) toubiao()
def test_toubiao_2(self): u"""测试投标后投标人次增加""" driver=self.driver con=Bankunion_proc() def toubiao(): con=Bankunion_proc() biao_id=con.back_biaoid(bankname=domain,bidstatus=16,value_way=2,product_type=1) login_bank.login_bank(self,username,password,domain) driver.get(base_url+'/bid/content/'+str(biao_id)) #跳转到标详情页面 elements=bank_page.woyaotouzi_tzlb(self) #投标前投标人数 toubiao_num_before=int(driver.find_element_by_css_selector("h3.bright span#count").text) elements.get("toubiaojine").send_keys("100") elements.get("lijitoubiao").click() driver.find_element_by_css_selector("div.aui_buttons button.aui_state_highlight[type='button']").click() time.sleep(2) #投标后人投标人数 toubiao_num_after=int(driver.find_element_by_css_selector("h3.bright span#count").text) self.assertEqual(toubiao_num_before+1,toubiao_num_after,u"投标记录未增加") biao_id=con.back_biaoid(bankname=domain,bidstatus=16,value_way=2,product_type=1) if biao_id: toubiao() else: yicixingjinjian.public_yicixing(self) toubiao()
def test_toubiaochaoe(self): u"""测试超额投标""" driver=self.driver con=Bankunion_proc() def toubiao(): con=Bankunion_proc() biao_id=con.back_biaoid(bankname=domain,bidstatus=16,value_way=2,product_type=1) login_bank.login_bank(self,username,password,domain) driver.get(base_url+'/bid/content/'+str(biao_id)) #跳转到标详情页面 elements=bank_page.woyaotouzi_tzlb(self) #已超额,请重新输入! jine=int(return_bidconf('borrowamount'))*10000+100 elements.get("toubiaojine").send_keys("%s"%jine) elements.get("lijitoubiao").click() time.sleep(2) chaoetishi = driver.find_element_by_css_selector("table.aui_dialog tbody tr td.aui_main div.aui_content").text self.assertEqual(u"已超额,请重新输入!", chaoetishi, u"超额投标失败") time.sleep(1) biao_id=con.back_biaoid(bankname=domain,bidstatus=16,value_way=2,product_type=1) if biao_id: toubiao() else: yicixingjinjian.public_yicixing(self) toubiao()
def test_toubiao_1(self): u"""测试投标后金额减少""" driver=self.driver con=Bankunion_proc() def toubiao(): con=Bankunion_proc() biao_id=con.back_biaoid(bankname=domain,bidstatus=16,value_way=2,product_type=1) login_bank.login_bank(self,username,password,domain) driver.get(base_url+'/bid/content/'+str(biao_id)) elements=bank_page.woyaotouzi_tzlb(self) wodeyue=elements.get("wodeyue").get_attribute("num") print u"投标前余额",wodeyue elements.get("toubiaojine").send_keys("100") elements.get("lijitoubiao").click() driver.find_element_by_css_selector("div.aui_buttons button.aui_state_highlight[type='button']").click() time.sleep(2) now_yue=driver.find_element_by_css_selector(" span#yi span#memberyue").get_attribute("num") #now_yue_e=WebDriverWait(driver,10).until(lambda x:x.find_element_by_css_selector(" span#yi span#memberyue")) print u"投标后余额",now_yue toubiaojine=float(wodeyue)-float(now_yue) self.assertEqual(toubiaojine, 100.0, u"用户余额未减少") biao_id=con.back_biaoid(bankname=domain,bidstatus=16,value_way=2,product_type=1) if biao_id: toubiao() else: yicixingjinjian.public_yicixing(self) toubiao()
def test_toubiao_1(self): u"""测试投标后金额减少""" driver = self.driver con = Bankunion_proc() def toubiao(): con = Bankunion_proc() biao_id = con.back_biaoid(bankname=domain, bidstatus=16, value_way=2, product_type=1) login_bank.login_bank(self, username, password, domain) driver.get(base_url + '/bid/content/' + str(biao_id)) elements = bank_page.woyaotouzi_tzlb(self) wodeyue = elements.get("wodeyue").get_attribute("num") print u"投标前余额", wodeyue elements.get("toubiaojine").send_keys("100") elements.get("lijitoubiao").click() driver.find_element_by_css_selector( "div.aui_buttons button.aui_state_highlight[type='button']" ).click() time.sleep(2) now_yue = driver.find_element_by_css_selector( " span#yi span#memberyue").get_attribute("num") #now_yue_e=WebDriverWait(driver,10).until(lambda x:x.find_element_by_css_selector(" span#yi span#memberyue")) print u"投标后余额", now_yue toubiaojine = float(wodeyue) - float(now_yue) self.assertEqual(toubiaojine, 100.0, u"用户余额未减少") biao_id = con.back_biaoid(bankname=domain, bidstatus=16, value_way=2, product_type=1) if biao_id: toubiao() else: yicixingjinjian.public_yicixing(self) toubiao()
def test_jzguding_date(self): u'''晋中信贷固定起息日前端和投标是否正确''' def jinjiantoubiaotest(): driver = self.driver #查找发售中标id login_bank.login_bank(self, username, password, 'jzbank') driver.get(bank_url + '/bid/content/' + str(biao_id)) time.sleep(1) bid_dates = driver.find_element_by_css_selector( 'div.module-box div#box1.content-area span.interest-period' ).text date_list = re.findall('\d{4}-\d{2}-\d{2}', bid_dates) start_date, enddate = con.back_date(biao_id) if self.assertEqual(start_date, date_list[0], u'起息日错误'): print u'起息日正确' if self.assertEqual(enddate, date_list[1], u'到期日错误'): print u'到期日正确' #标详情页面元素list elements = bank_page.woyaotouzi_tzlb(self) #投标前投标人数 toubiao_num_before = int( driver.find_element_by_css_selector( "h3.bright span#count").text) elements.get("toubiaojine").send_keys("100") elements.get("lijitoubiao").click() time.sleep(2) driver.find_element_by_css_selector( "div.aui_buttons button.aui_state_highlight[type='button']" ).click() time.sleep(2) #投标后人投标人数 toubiao_num_after = int( driver.find_element_by_css_selector( "h3.bright span#count").text) self.assertEqual(toubiao_num_before + 1, toubiao_num_after, u"投标记录未增加") con = Bankunion_proc() #获取发售中标,如果没有标调用进件方法 biao_id = con.back_biaoid(bankname='jzbank', bidstatus=16, value_way=1, product_type=1) if biao_id: jinjiantoubiaotest() else: self.test_jzxindaigudingjinjian() con = Bankunion_proc() biao_id = con.back_biaoid(bankname='jzbank', bidstatus=16, value_way=1, product_type=1) print 'biaoid', biao_id jinjiantoubiaotest()
def test_woyaojiekuan(self): u"""我要借款""" driver=self.driver login_bank.login_bank(self) elements_home=bank_page.home_page(self) elements_home.get("woyaojiekuan").click() elements_jiekuan=bank_page.woyaojiekuan(self) elements_jiekuan.get("tongyi").click() elements_jiekuan.get("huoquyanzhengma").click() time.sleep(5) yanzhengma=Bankunion_proc().back_random_code(username_input) elements_jiekuan.get("yanzhengma").send_keys(yanzhengma) elements_jiekuan.get("suozaidiqu").send_keys(u"北京") elements_jiekuan.get("daikuanjine").send_keys("1") elements_jiekuan.get("yueshu").click() elements_jiekuan.get("sangeyue").click() elements_jiekuan.get("tijiaoshenqing").click() time.sleep(2) chenggong=driver.find_element_by_css_selector("tbody tr td.aui_main div.aui_content").text self.assertEqual(chenggong, u"成功!", u"借款失败") driver.find_element_by_css_selector(" button.aui_state_highlight").click() time.sleep(2)
def test_geren_yicixing(self): u"""个人进件一次性""" print 'yicixing' refundway = 1 driver=self.driver #driver.get(self.base_url) login_oms.login(self) #交易管理 time.sleep(2) jiaoyiguanli_ele="ul#menu.nav li.menu:nth-child(2) a.menu" driver.find_element_by_css_selector(jiaoyiguanli_ele).click() #默认为进件录入,直接切换iframe #driver.switch_to_frame("mainFrame") #定位进件渠道 time.sleep(2) elements=jiaoyiguanli.jinjianluru(self) time.sleep(2) jinjianqudao="div.controls select#borrowSource.input-medium" driver.find_element_by_css_selector(jinjianqudao).find_element_by_css_selector("select#borrowSource.input-medium option[value='%s']"%domain).click() #点击公司or个人 driver.find_element_by_css_selector("div.control-group div.controls input[value='person']").click() elements[0][1].send_keys(u"自动化测试") elements[0][2].send_keys('320701197905145687') elements[0][3].send_keys("15300000000") elements[0][4].send_keys(u"测试") #点击实名认证按钮 driver.find_element_by_css_selector("div.controls input#btnCheckIdCard.btn").click() time.sleep(3) driver.switch_to_alert().accept() #借款信息 biaoti_display=driver.find_element_by_css_selector("div#borrowTitleInputDiv div#borrowTitlePreDiv").is_displayed() if not biaoti_display: driver.find_element_by_css_selector(" div.control-group div.controls div#borrowTitleEditDiv a").click() driver.find_element_by_css_selector("input#borrowTitlePre.input-medium").clear() driver.find_element_by_css_selector("input#borrowTitlePre.input-medium").send_keys(u"一次性还本息") driver.find_element_by_css_selector("div#borrowTitleBtnDiv input#borrowTitleOkBtn.btn").click() driver.find_element_by_css_selector('input#borrowTitleSeq.input-medium').clear() driver.find_element_by_css_selector('input#borrowTitleSeq.input-medium').send_keys(1) else: driver.find_element_by_css_selector("input#borrowTitlePre.input-medium").send_keys(u"一次性还本息") driver.find_element_by_css_selector("div#borrowTitleBtnDiv input#borrowTitleOkBtn.btn").click() driver.find_element_by_css_selector('input#borrowTitleSeq.input-medium').send_keys(1) #借款金额 elements[1].send_keys(return_bidconf('borrowamount')) #起息方式 driver.find_element_by_css_selector('div.controls select#valueWay.input-mini').find_element_by_css_selector("option[value='2']").click() #借款期限 driver.find_element_by_css_selector(' div.controls select#borrowPeriodUnit.input-mini').find_element_by_css_selector("option[value='%s']"%return_bidconf('borrowunit')).click() elements[2].send_keys(return_bidconf('borrowlimit_yici')) #筹标期限 elements[3].send_keys(7) #还款方式 huankuanfangshi=driver.find_element_by_css_selector("div.control-group div.controls select#refundWay.input-mini") #还款方式 一次性还本息 huankuanfangshi.find_element_by_css_selector("option[value='%s']"%refundway).click() #借款总成本 driver.find_element_by_css_selector("div.controls input#borrowDegression.input-medium").send_keys(str(return_bidconf('borrowdegression'))) #筹款利率 driver.find_element_by_css_selector("div.controls input#borrowRate.input-medium").send_keys(str(return_bidconf('borrowRate'))) time.sleep(1) driver.find_element_by_css_selector("input#btnNextStep.btn").click() time.sleep(10) #终定选择页面 #table#contentTable.table tbody tr td a.status[bid='309'] con=Bankunion_proc() biao_id=con.back_biaoid(bankname=domain,bidstatus=10) if biao_id is None: time.sleep(5) con=Bankunion_proc() biao_id=con.back_biaoid(bankname=domain,bidstatus=10) while 1: try: zhongding=driver.find_element_by_css_selector("table#contentTable.table tbody tr td a.status[bid='%s']"%biao_id) break except NoSuchElementException: time.sleep(3) zhongding.click() time.sleep(1) refundwayname=driver.find_element_by_xpath("/html/body/form/table[2]/thead/tr[4]/th[2]").text self.assertEqual(u"一次性还本息", refundwayname, u"还款方式错误") #点击批核按钮 driver.find_element_by_css_selector("form#inputForm.form-horizontal div input[type='radio'][value='1']").click() #点击保存按钮 driver.find_element_by_css_selector("div.form-actions input#btnSubmit.btn").click() #driver.switch_to_frame("") driver.switch_to_default_content() time.sleep(2) ntime=0 while 1: try: driver.find_element_by_css_selector("div#jbox-state-state0.jbox-state div.jbox-button-panel button.jbox-button[value='ok']").click() break except NoSuchElementException: time.sleep(2) ntime+=2 if ntime>10: break time.sleep(2)
def ready_db(): con=Bankunion_proc() #实例化一个类 con.create_proc() con.clear_and_createdata()
def public_yicixing(self): u"""个人进件一次性""" print 'yicixing' refundway = 1 driver=self.driver #driver.get(self.base_url) login_oms.login(self) #交易管理 time.sleep(2) jiaoyiguanli_ele="ul#menu.nav li.menu:nth-child(2) a.menu" driver.find_element_by_css_selector(jiaoyiguanli_ele).click() #默认为进件录入,直接切换iframe #driver.switch_to_frame("mainFrame") #定位进件渠道 time.sleep(2) elements=jiaoyiguanli.jinjianluru(self) time.sleep(2) jinjianqudao="div.controls select#borrowSource.input-medium" driver.find_element_by_css_selector(jinjianqudao).find_element_by_css_selector("select#borrowSource.input-medium option[value='%s']"%domain).click() #点击公司or个人 driver.find_element_by_css_selector("div.control-group div.controls input[value='person']").click() elements[0][1].send_keys(u"自动化测试") elements[0][2].send_keys('320701197905145687') elements[0][3].send_keys("15300000000") elements[0][4].send_keys(u"测试") #点击实名认证按钮 driver.find_element_by_css_selector("div.controls input#btnCheckIdCard.btn").click() time.sleep(3) driver.switch_to_alert().accept() #借款信息 biaoti_display=driver.find_element_by_css_selector("div#borrowTitleInputDiv div#borrowTitlePreDiv").is_displayed() if not biaoti_display: driver.find_element_by_css_selector(" div.control-group div.controls div#borrowTitleEditDiv a").click() driver.find_element_by_css_selector("input#borrowTitlePre.input-medium").clear() driver.find_element_by_css_selector("input#borrowTitlePre.input-medium").send_keys(u"一次性还本息") driver.find_element_by_css_selector("div#borrowTitleBtnDiv input#borrowTitleOkBtn.btn").click() driver.find_element_by_css_selector('input#borrowTitleSeq.input-medium').clear() driver.find_element_by_css_selector('input#borrowTitleSeq.input-medium').send_keys(1) else: driver.find_element_by_css_selector("input#borrowTitlePre.input-medium").send_keys(u"一次性还本息") driver.find_element_by_css_selector("div#borrowTitleBtnDiv input#borrowTitleOkBtn.btn").click() driver.find_element_by_css_selector('input#borrowTitleSeq.input-medium').send_keys(1) #借款金额 elements[1].send_keys(return_bidconf('borrowamount')) #起息方式 driver.find_element_by_css_selector('div.controls select#valueWay.input-mini').find_element_by_css_selector("option[value='2']").click() #借款期限 driver.find_element_by_css_selector(' div.controls select#borrowPeriodUnit.input-mini').find_element_by_css_selector("option[value='%s']"%return_bidconf('borrowunit')).click() elements[2].send_keys(return_bidconf('borrowlimit_yici')) #筹标期限 elements[3].send_keys(7) #还款方式 huankuanfangshi=driver.find_element_by_css_selector("div.control-group div.controls select#refundWay.input-mini") #还款方式 一次性还本息 huankuanfangshi.find_element_by_css_selector("option[value='%s']"%refundway).click() #借款总成本 driver.find_element_by_css_selector("div.controls input#borrowDegression.input-medium").send_keys(str(return_bidconf('borrowdegression'))) #筹款利率 driver.find_element_by_css_selector("div.controls input#borrowRate.input-medium").send_keys(str(return_bidconf('borrowRate'))) time.sleep(1) driver.find_element_by_css_selector("input#btnNextStep.btn").click() time.sleep(10) #终定选择页面 #table#contentTable.table tbody tr td a.status[bid='309'] con=Bankunion_proc() biao_id=con.back_biaoid(bankname=domain,bidstatus=10) if biao_id is None: time.sleep(5) con=Bankunion_proc() biao_id=con.back_biaoid(bankname=domain,bidstatus=10) while 1: try: zhongding=driver.find_element_by_css_selector("table#contentTable.table tbody tr td a.status[bid='%s']"%biao_id) break except NoSuchElementException: time.sleep(3) zhongding.click() time.sleep(1) refundwayname=driver.find_element_by_xpath("/html/body/form/table[2]/thead/tr[4]/th[2]").text self.assertEqual(u"一次性还本息", refundwayname, u"还款方式错误") #点击批核按钮 driver.find_element_by_css_selector("form#inputForm.form-horizontal div input[type='radio'][value='1']").click() #点击保存按钮 driver.find_element_by_css_selector("div.form-actions input#btnSubmit.btn").click() #driver.switch_to_frame("") driver.switch_to_default_content() time.sleep(2) ntime=0 while 1: try: driver.find_element_by_css_selector("div#jbox-state-state0.jbox-state div.jbox-button-panel button.jbox-button[value='ok']").click() break except NoSuchElementException: time.sleep(2) ntime+=2 if ntime>10: break time.sleep(2)
def fullbid(): con = Bankunion_proc() biao_id = con.back_biaoid(bankname='jzbank', bidstatus=16, value_way=1, product_type=1) loginurl = "%s/ajaxlogin" % bank_url logindata = { 'username': '******' % username, 'password': '******', 'showcode': '' } s = requests.Session() s.post(url=loginurl, data=logindata, verify=False) fullbidurl = '%s/memberBidInfo/memberRequestBid' % bank_url #需要满标的标id bid_enter_amount, approved_amount = con.back_bid_money( bid=biao_id, domain='jzbank') toubiaojine = approved_amount - bid_enter_amount postdata = { 'id': '%s' % biao_id, 'money': int(toubiaojine), 'showCode': '0', 'resmoney': int(toubiaojine), 'number1': "0.2342342342323" } r = s.post(url=fullbidurl, data=postdata) print r.text self.assertEquals('ok', r.text, u'投满标失败') time.sleep(2) #oms #login_oms.login(self) driver.get(baseoms_url) #交易管理 time.sleep(2) driver.switch_to_default_content() #driver.switch_to_frame("mainFrame") jiaoyiguanli_ele = "ul#menu.nav li.menu:nth-child(2) a.menu" time.sleep(1) driver.find_element_by_css_selector(jiaoyiguanli_ele).click() driver.switch_to_frame("menuFrame") time.sleep(3) #点击借款管理 driver.find_element_by_xpath( "/html/body/div[3]/div[2]/div/a").click() time.sleep(1) driver.find_element_by_css_selector( ' div#collapse169.accordion-body div.accordion-inner ul.nav li:nth-child(3) a.lh001' ).click() driver.switch_to_default_content() time.sleep(1) driver.switch_to_frame("mainFrame") time.sleep(2) #点击筹标复核 driver.find_element_by_css_selector( "table#contentTable.table tbody tr td a[href='/hdb/memberBidInfo/toFullScaleReview?id=%s']" % biao_id).click() #点击审核通过 driver.find_element_by_css_selector( "div form#inputForm.form-horizontal span label[for='isApproved1']" ).click() driver.find_element_by_css_selector( "html body div form#inputForm.form-horizontal textarea#bidRecheckRemark.valid" ).send_keys('dsafasdasddf') #点击投标复核保存 driver.find_element_by_css_selector( "html body div form#inputForm.form-horizontal input#btnSubmit.btn" ).click() time.sleep(2) driver.switch_to_default_content() time.sleep(1) driver.switch_to_frame("menuFrame") time.sleep(2) driver.find_element_by_xpath( '/html/body/div[3]/div[3]/div/a').click() time.sleep(1) #点击还款总表 driver.find_element_by_css_selector( 'div#collapse230.accordion-body div.accordion-inner ul.nav li:nth-child(1) a.lh001' ).click() driver.switch_to_default_content() time.sleep(1) driver.switch_to_frame("mainFrame") #定位到对应的标,点击查看 driver.find_element_by_css_selector( 'table#contentTable.table tbody tr td a[href="/hdb/memberRefundInfo/detail?bid=%s&flag=1"]' % biao_id).click() #获取实际还款日 huankuanri = driver.find_element_by_xpath( '/html/body/div[3]/table/tbody/tr/td[6]').text start_date, enddate = con.back_date(biao_id) self.assertEqual(enddate, huankuanri, u'还款日错误')
def test_jzxintuo(self): u"""个人晋中信托进件""" refundway = 1 driver = self.driver login_oms.login(self) #交易管理 time.sleep(1) jiaoyiguanli_ele = "ul#menu.nav li.menu:nth-child(2) a.menu" driver.find_element_by_css_selector(jiaoyiguanli_ele).click() #默认为进件录入,login_omse #driver.switch_to_frame("mainFrame") #定位进件渠道 time.sleep(2) elements = jiaoyiguanli.jinjianluru(self) time.sleep(2) jinjianqudao = "div.controls select#borrowSource.input-medium" driver.find_element_by_css_selector( jinjianqudao).find_element_by_css_selector( "select#borrowSource.input-medium option[value='%s']" % 'jzbank').click() #点击公司or个人 driver.find_element_by_css_selector( "div.control-group div.controls input[value='person']").click() elements[0][1].send_keys(u"自动化测试") elements[0][2].send_keys('320701197905145687') elements[0][3].send_keys("15300000000") elements[0][4].send_keys(u"测试") #点击实名认证按钮 driver.find_element_by_css_selector( "div.controls input#btnCheckIdCard.btn").click() time.sleep(3) driver.switch_to_alert().accept() #借款信息 biaoti_display = driver.find_element_by_css_selector( "div#borrowTitleInputDiv div#borrowTitlePreDiv").is_displayed() if not biaoti_display: driver.find_element_by_css_selector( " div.control-group div.controls div#borrowTitleEditDiv a" ).click() driver.find_element_by_css_selector( "input#borrowTitlePre.input-medium").clear() driver.find_element_by_css_selector( "input#borrowTitlePre.input-medium").send_keys(u"晋中信贷") driver.find_element_by_css_selector( "div#borrowTitleBtnDiv input#borrowTitleOkBtn.btn").click() driver.find_element_by_css_selector( 'input#borrowTitleSeq.input-medium').clear() driver.find_element_by_css_selector( 'input#borrowTitleSeq.input-medium').send_keys(1) else: driver.find_element_by_css_selector( "input#borrowTitlePre.input-medium").send_keys(u"晋中信贷") driver.find_element_by_css_selector( "div#borrowTitleBtnDiv input#borrowTitleOkBtn.btn").click() driver.find_element_by_css_selector( 'input#borrowTitleSeq.input-medium').send_keys(1) time.sleep(3) #借款金额 elements[1].send_keys(return_bidconf('borrowamount')) #借款产品类型 driver.find_element_by_css_selector( " div.control-group div.controls select#productType.input-mini" ).find_element_by_css_selector("option[value='4']").click() js1 = 'document.getElementById("valueDate").removeAttribute("readonly")' js2 = 'document.getElementById("toDate").removeAttribute("readonly")' driver.execute_script(js1) time.sleep(1) driver.execute_script(js2) time.sleep(5) #起息日期为当前日期加两天 driver.find_element_by_css_selector( 'div div.controls input#valueDate.input-small').send_keys( '%s' % valueDate) #到期日期 driver.find_element_by_css_selector( 'div div.controls input#toDate.input-small').send_keys('%s' % toDate) #借款期限 driver.find_element_by_css_selector( 'div.controls input#borrowLimitTjs.input-medium').click() #筹标期限 elements[3].send_keys(7) #还款方式 huankuanfangshi = driver.find_element_by_css_selector( "div.control-group div.controls select#refundWay.input-mini") #还款方式 一次性还本息 huankuanfangshi.find_element_by_css_selector("option[value='%s']" % refundway).click() #借款总成本 driver.find_element_by_css_selector( "div.controls input#borrowDegression.input-medium").send_keys( str(return_bidconf('borrowdegression'))) time.sleep(2) #筹款利率 driver.find_element_by_css_selector( "div.controls input#borrowRate.input-medium").send_keys( str(return_bidconf('borrowRate'))) time.sleep(1) driver.find_element_by_css_selector("input#btnNextStep.btn").click() time.sleep(10) #终定选择页面 #table#contentTable.table tbody tr td a.status[bid='309'] con = Bankunion_proc() biao_id = con.back_biaoid(bankname='jzbank', bidstatus=10) ntime = 0 while 1: try: zhongding = driver.find_element_by_css_selector( "table#contentTable.table tbody tr td a.status[bid='%s']" % biao_id) except NoSuchElementException: time.sleep(2) ntime += 2 if ntime > 9: break zhongding.click() time.sleep(1) #refundwayname=driver.find_element_by_xpath("/html/body/form/table[2]/thead/tr[4]/th[2]").text #self.assertEqual(u"按月付息到期还本", refundwayname, u"还款方式错误") refundwayname = driver.find_element_by_xpath( "/html/body/form/table[2]/thead/tr[4]/th[2]").text self.assertEqual(u"一次性还本息", refundwayname, u"还款方式错误") #点击批核按钮 driver.find_element_by_css_selector( "form#inputForm.form-horizontal div input[type='radio'][value='1']" ).click() #点击保存按钮 driver.find_element_by_css_selector( "div.form-actions input#btnSubmit.btn").click() time.sleep(1) driver.switch_to_default_content() time.sleep(1) ntime = 0 while 1: try: driver.find_element_by_css_selector( "div#jbox-state-state0.jbox-state div.jbox-button-panel button.jbox-button[value='ok']" ).click() break except NoSuchElementException: time.sleep(2) ntime += 2 if ntime > 10: break time.sleep(2)
def test_tjsbid(self): u"""天交所票据进件及终定""" str_json = '''{"productDescription":"【产品说明】本产品为天津金融资产交易所挂牌的收益权转让产品,您在购买时需要先注册成为天津金融资产交易所的会员或注册投资者。本产品起购金额为5000元,购买前请认真阅读《产品合约》、《产品说明书》等相关文件,当您“确认付款”则表示您已确认并同意《产品合约》、《产品说明书》等相关文件中的内容。","no":"3", "monetaryUnit":"156","productRiskI":"【风险提示】 本产品为约定收益产品,投资有风险,详情请您参考《产品说明书》。","productType":"SCP_ZQSYQ", "productContractID":"SFH(JZ)(HHJZ)201500201001_contract.html","issuerCType":"1","issuerBankA":"77230154740007480","riskAssessmentTables":"", "underDate":"%(underDate)s","productBreathDay":"%(productBreathDay)s","productEIn":"【收益说明】本产品约定年化收益率为6.5。本产品根据投资人持有产品的实 际天数计算收益, 产品到期日不计息。本产品认购期间内认购资金不享受收益。 ", "productBNRiskRating":"1","productQAgeUpperL":"","lowestRiskAScore":"24","issuer":"天津智通慧达资产管理有限公司", "fileName":"/home/testspace/bank_ticket/tjs/splitTxt/CPGP-XXXX-20150801-2.txt","productRiskLevel":"M","minRaiseSuccessAmount":"75000", "productRDocuments5":"","productQAgeLowerL":"","linesAFRate":"","registerDate":"%(registerDate)s","issuerCity":"天津市","guaranteedAIRate":"%(guaranteedAIRate)s", "issuerInstitution":"TJFAE_888888","unitPriceAmount":"%(unitPriceAmount)s","issuerASign":"1","reserved4":"","productDueDate":"%(productDueDate)s", "reserved2":"","reserved3":"","reserved1":"","productDeadline":"64","productCode":"SFH(JZ)(HHJZ)201500201","earningsCountType":"1", "expectedAYield":"%(expectedAYield)s","issuerCe":"30057952-8","salesAmount":"%(salesAmount)s","productCodeSon":"001","raiseAmount":"%(raiseAmount)s","productRDocuments3":"", "productName":"天津金融资产交易所“京诚宝”2015年第2期第1款002号集合债权支持类收益分享合约产品","productsToHonour":"%(productsToHonour)s", "productRDocuments4":"","issuerAOBank":"上海浦东发展银行天津科技支行","allowsSecMarketTrading":"1","productRDocuments1":"","earningsType":"1", "issuerProvince":"天津","productTermUnit":"D","productRDocuments2":""}''' % { 'underDate': '20160310-240000', 'registerDate': '20160308-162000', 'productDueDate': '20160409', 'productsToHonour': '20160412', 'productBreathDay': '20160312', 'unitPriceAmount': '2000', 'salesAmount': '5000', 'raiseAmount': '80000', 'guaranteedAIRate': '0.67000', 'expectedAYield': '0.67000' } url = 'http://%s:6005/hdb/autoSuperScript/save' % dbhost headers = {'content-type': 'application/json'} r = requests.post(url, data=str_json, headers=headers) self.assertEqual(r.text, '00000000', "tjs_bid_post_success") #进入oms终定审核tjs标 driver = self.driver login_oms.login(self) time.sleep(2) jiaoyiguanli_ele = "ul#menu.nav li.menu:nth-child(2) a.menu" driver.find_element_by_css_selector(jiaoyiguanli_ele).click() driver.switch_to_frame("menuFrame") time.sleep(3) #点击借款管理 driver.find_element_by_xpath("/html/body/div[3]/div[2]/div/a").click() time.sleep(1) driver.find_element_by_css_selector( "div#collapse169.accordion-body div.accordion-inner ul.nav li:nth-child(2) a.lh001" ).click() time.sleep(2) con = Bankunion_proc() biao_id = con.back_biaoid('lccb') if biao_id is None: time.sleep(5) con = Bankunion_proc() biao_id = con.back_biaoid('lccb') driver.switch_to_default_content() driver.switch_to_frame("mainFrame") while 1: try: zhongding = driver.find_element_by_css_selector( "table#contentTable.table tbody tr td a.status[bid='%s']" % biao_id) break except NoSuchElementException: time.sleep(3) break zhongding.click() time.sleep(1) refundwayname = driver.find_element_by_xpath( "/html/body/form/table[2]/thead/tr[4]/th[2]").text self.assertEqual(u"到期一次性还本付息", refundwayname, u"还款方式错误") #点击批核按钮 driver.find_element_by_css_selector( "form#inputForm.form-horizontal div input[type='radio'][value='1']" ).click() #点击保存按钮 driver.find_element_by_css_selector( "div.form-actions input#btnSubmit.btn").click() #driver.switch_to_frame("") driver.switch_to_default_content() time.sleep(2) ntime = 0 while 1: try: driver.find_element_by_css_selector( "div#jbox-state-state0.jbox-state div.jbox-button-panel button.jbox-button[value='ok']" ).click() break except NoSuchElementException: time.sleep(2) ntime += 2 if ntime > 10: break time.sleep(3)
def test_gerenyi_xinshoubiao(self): u"""个人进件晋中新手标""" refundway = 1 driver=self.driver #driver.get(self.base_url) login_oms.login(self) #交易管理 time.sleep(1) jiaoyiguanli_ele="ul#menu.nav li.menu:nth-child(2) a.menu" driver.find_element_by_css_selector(jiaoyiguanli_ele).click() #默认为进件录入,直接切换iframe #driver.switch_to_frame("mainFrame") #定位进件渠道 time.sleep(2) elements=jiaoyiguanli.jinjianluru(self) time.sleep(2) jinjianqudao="div.controls select#borrowSource.input-medium" driver.find_element_by_css_selector(jinjianqudao).find_element_by_css_selector("select#borrowSource.input-medium option[value='%s']"%'jzbank').click() #点击公司or个人 driver.find_element_by_css_selector("div.control-group div.controls input[value='person']").click() elements[0][1].send_keys(u"自动化测试") elements[0][2].send_keys('320701197905145687') elements[0][3].send_keys("15300000000") elements[0][4].send_keys(u"测试") #点击实名认证按钮 driver.find_element_by_css_selector("div.controls input#btnCheckIdCard.btn").click() time.sleep(3) driver.switch_to_alert().accept() #借款信息 biaoti_display=driver.find_element_by_css_selector("div#borrowTitleInputDiv div#borrowTitlePreDiv").is_displayed() if not biaoti_display: driver.find_element_by_css_selector(" div.control-group div.controls div#borrowTitleEditDiv a").click() driver.find_element_by_css_selector("input#borrowTitlePre.input-medium").clear() driver.find_element_by_css_selector("input#borrowTitlePre.input-medium").send_keys(u"晋中新手标") driver.find_element_by_css_selector("div#borrowTitleBtnDiv input#borrowTitleOkBtn.btn").click() driver.find_element_by_css_selector('input#borrowTitleSeq.input-medium').clear() driver.find_element_by_css_selector('input#borrowTitleSeq.input-medium').send_keys(1) else: driver.find_element_by_css_selector("input#borrowTitlePre.input-medium").send_keys(u"晋中新手标") driver.find_element_by_css_selector("div#borrowTitleBtnDiv input#borrowTitleOkBtn.btn").click() driver.find_element_by_css_selector('input#borrowTitleSeq.input-medium').send_keys(1) time.sleep(3) #借款金额 elements[1].send_keys(borrowamount) #借款产品类型 driver.find_element_by_css_selector(" div.control-group div.controls select#productType.input-mini").find_element_by_css_selector("option[value='2']").click() #借款期限 driver.find_element_by_css_selector(' div.controls select#borrowPeriodUnit.input-mini').find_element_by_css_selector("option[value='1']").click() elements[2].send_keys(borrowlimit_yici) #筹标期限 elements[3].send_keys(7) #还款方式 huankuanfangshi=driver.find_element_by_css_selector("div.control-group div.controls select#refundWay.input-mini") #还款方式 一次性还本息 huankuanfangshi.find_element_by_css_selector("option[value='%s']"%refundway).click() #借款总成本 driver.find_element_by_css_selector("div.controls input#borrowDegression.input-medium").send_keys(str(borrowdegression)) #筹款利率 driver.find_element_by_css_selector("div.controls input#borrowRate.input-medium").send_keys(str(borrowRate)) time.sleep(1) driver.find_element_by_css_selector("input#btnNextStep.btn").click() time.sleep(5) #终定选择页面 #table#contentTable.table tbody tr td a.status[bid='309'] con=Bankunion_proc() biao_id=con.back_biaoid('jzbank') while 1: try: zhongding=driver.find_element_by_css_selector("table#contentTable.table tbody tr td a.status[bid='%s']"%biao_id) break except NoSuchElementException: time.sleep(3) break zhongding.click() time.sleep(1) refundwayname=driver.find_element_by_xpath("/html/body/form/table[2]/thead/tr[4]/th[2]").text self.assertEqual(u"一次性还本息", refundwayname, u"还款方式错误") #点击批核按钮 driver.find_element_by_css_selector("form#inputForm.form-horizontal div input[type='radio'][value='1']").click() #js清除readonly属性 #js='document.getElementById("publishDate").removeAttribute("readonly");' #driver.execute_script(js) #time.sleep(2) #上线时间 #onlinetime=datetime.datetime.now()+ datetime.timedelta(hours = 1) #onlinetime=onlinetime.strftime('%Y-%m-%d %H:%M:%S') #driver.find_element_by_css_selector("div.controls input#publishDate.input-medium").send_keys("%s"%onlinetime) #点击保存按钮 driver.find_element_by_css_selector("div.form-actions input#btnSubmit.btn").click() time.sleep(1) driver.switch_to_default_content() time.sleep(1) ntime=0 while 1: try: driver.find_element_by_css_selector("div#jbox-state-state0.jbox-state div.jbox-button-panel button.jbox-button[value='ok']").click() break except NoSuchElementException: time.sleep(2) ntime+=2 if ntime>10: break time.sleep(2)
def test_gerenyi_xinshoubiao(self): u"""个人进件晋中新手标""" refundway = 1 driver = self.driver #driver.get(self.base_url) login_oms.login(self) #交易管理 time.sleep(1) jiaoyiguanli_ele = "ul#menu.nav li.menu:nth-child(2) a.menu" driver.find_element_by_css_selector(jiaoyiguanli_ele).click() #默认为进件录入,直接切换iframe #driver.switch_to_frame("mainFrame") #定位进件渠道 time.sleep(2) elements = jiaoyiguanli.jinjianluru(self) time.sleep(2) jinjianqudao = "div.controls select#borrowSource.input-medium" driver.find_element_by_css_selector( jinjianqudao).find_element_by_css_selector( "select#borrowSource.input-medium option[value='%s']" % 'jzbank').click() #点击公司or个人 driver.find_element_by_css_selector( "div.control-group div.controls input[value='person']").click() elements[0][1].send_keys(u"自动化测试") elements[0][2].send_keys('320701197905145687') elements[0][3].send_keys("15300000000") elements[0][4].send_keys(u"测试") #点击实名认证按钮 driver.find_element_by_css_selector( "div.controls input#btnCheckIdCard.btn").click() time.sleep(3) driver.switch_to_alert().accept() #借款信息 biaoti_display = driver.find_element_by_css_selector( "div#borrowTitleInputDiv div#borrowTitlePreDiv").is_displayed() if not biaoti_display: driver.find_element_by_css_selector( " div.control-group div.controls div#borrowTitleEditDiv a" ).click() driver.find_element_by_css_selector( "input#borrowTitlePre.input-medium").clear() driver.find_element_by_css_selector( "input#borrowTitlePre.input-medium").send_keys(u"晋中新手标") driver.find_element_by_css_selector( "div#borrowTitleBtnDiv input#borrowTitleOkBtn.btn").click() driver.find_element_by_css_selector( 'input#borrowTitleSeq.input-medium').clear() driver.find_element_by_css_selector( 'input#borrowTitleSeq.input-medium').send_keys(1) else: driver.find_element_by_css_selector( "input#borrowTitlePre.input-medium").send_keys(u"晋中新手标") driver.find_element_by_css_selector( "div#borrowTitleBtnDiv input#borrowTitleOkBtn.btn").click() driver.find_element_by_css_selector( 'input#borrowTitleSeq.input-medium').send_keys(1) time.sleep(3) #借款金额 elements[1].send_keys(borrowamount) #借款产品类型 driver.find_element_by_css_selector( " div.control-group div.controls select#productType.input-mini" ).find_element_by_css_selector("option[value='2']").click() #借款期限 driver.find_element_by_css_selector( ' div.controls select#borrowPeriodUnit.input-mini' ).find_element_by_css_selector("option[value='1']").click() elements[2].send_keys(borrowlimit_yici) #筹标期限 elements[3].send_keys(7) #还款方式 huankuanfangshi = driver.find_element_by_css_selector( "div.control-group div.controls select#refundWay.input-mini") #还款方式 一次性还本息 huankuanfangshi.find_element_by_css_selector("option[value='%s']" % refundway).click() #借款总成本 driver.find_element_by_css_selector( "div.controls input#borrowDegression.input-medium").send_keys( str(borrowdegression)) #筹款利率 driver.find_element_by_css_selector( "div.controls input#borrowRate.input-medium").send_keys( str(borrowRate)) time.sleep(1) driver.find_element_by_css_selector("input#btnNextStep.btn").click() time.sleep(5) #终定选择页面 #table#contentTable.table tbody tr td a.status[bid='309'] con = Bankunion_proc() biao_id = con.back_biaoid('jzbank') while 1: try: zhongding = driver.find_element_by_css_selector( "table#contentTable.table tbody tr td a.status[bid='%s']" % biao_id) break except NoSuchElementException: time.sleep(3) break zhongding.click() time.sleep(1) refundwayname = driver.find_element_by_xpath( "/html/body/form/table[2]/thead/tr[4]/th[2]").text self.assertEqual(u"一次性还本息", refundwayname, u"还款方式错误") #点击批核按钮 driver.find_element_by_css_selector( "form#inputForm.form-horizontal div input[type='radio'][value='1']" ).click() #js清除readonly属性 #js='document.getElementById("publishDate").removeAttribute("readonly");' #driver.execute_script(js) #time.sleep(2) #上线时间 #onlinetime=datetime.datetime.now()+ datetime.timedelta(hours = 1) #onlinetime=onlinetime.strftime('%Y-%m-%d %H:%M:%S') #driver.find_element_by_css_selector("div.controls input#publishDate.input-medium").send_keys("%s"%onlinetime) #点击保存按钮 driver.find_element_by_css_selector( "div.form-actions input#btnSubmit.btn").click() time.sleep(1) driver.switch_to_default_content() time.sleep(1) ntime = 0 while 1: try: driver.find_element_by_css_selector( "div#jbox-state-state0.jbox-state div.jbox-button-panel button.jbox-button[value='ok']" ).click() break except NoSuchElementException: time.sleep(2) ntime += 2 if ntime > 10: break time.sleep(2)
def test_tjsbid(self): u"""天交所票据进件及终定""" #起息日 productBreathDay = (datetime.datetime.now() + datetime.timedelta(days = 3)).strftime('%Y%m%d') #兑付日 productsToHonour = (datetime.datetime.now() + datetime.timedelta(days = 32)).strftime('%Y%m%d') #到期日 productDueDate = (datetime.datetime.now() + datetime.timedelta(days = 31)).strftime('%Y%m%d') #下架日期 underDate = '%s-240000'%(datetime.datetime.now() + datetime.timedelta(days = 1)).strftime('%Y%m%d') #上架日期 registerDate = '%s-010000'%datetime.datetime.now().strftime('%Y%m%d') str_json='''{"productDescription":"【产品说明】本产品为天津金融资产交易所挂牌的收益权转让产品,您在购买时需要先注册成为天津金融资产交易所的会员或注册投资者。本产品起购金额为5000元,购买前请认真阅读《产品合约》、《产品说明书》等相关文件,当您“确认付款”则表示您已确认并同意《产品合约》、《产品说明书》等相关文件中的内容。","no":"3", "monetaryUnit":"156","productRiskI":"【风险提示】 本产品为约定收益产品,投资有风险,详情请您参考《产品说明书》。","productType":"SCP_ZQSYQ", "sumAmount":"2251165","productContractID":"SFH(JZ)(HHJZ)201500201001_contract.html","issuerCType":"1","issuerBankA":"77230154740007480","riskAssessmentTables":"", "underDate":"%(underDate)s","productBreathDay":"%(productBreathDay)s","productEIn":"【收益说明】本产品约定年化收益率为6.5。本产品根据投资人持有产品的实 际天数计算收益, 产品到期日不计息。本产品认购期间内认购资金不享受收益。 ", "productBNRiskRating":"1","productQAgeUpperL":"","lowestRiskAScore":"24","issuer":"天津智通慧达资产管理有限公司", "fileName":"/home/testspace/bank_ticket/tjs/splitTxt/CPGP-XXXX-20150801-2.txt","productRiskLevel":"M","minRaiseSuccessAmount":"75000", "productRDocuments5":"","productQAgeLowerL":"","linesAFRate":"","registerDate":"%(registerDate)s","issuerCity":"天津市","guaranteedAIRate":"%(guaranteedAIRate)s", "issuerInstitution":"TJFAE_888888","unitPriceAmount":"%(unitPriceAmount)s","issuerASign":"1","reserved4":"","productDueDate":"%(productDueDate)s", "reserved2":"","reserved3":"","reserved1":"","productDeadline":"64","productCode":"SFH(JZ)(HHJZ)201500201","earningsCountType":"1", "expectedAYield":"%(expectedAYield)s","issuerCe":"30057952-8","salesAmount":"%(salesAmount)s","productCodeSon":"001","raiseAmount":"%(raiseAmount)s","productRDocuments3":"", "productName":"天津金融资产交易所“京诚宝”2015年第2期第1款002号集合债权支持类收益分享合约产品","productsToHonour":"%(productsToHonour)s", "productRDocuments4":"","issuerAOBank":"上海浦东发展银行天津科技支行","allowsSecMarketTrading":"1","productRDocuments1":"","earningsType":"1", "issuerProvince":"天津","productTermUnit":"D","productRDocuments2":""}''' % {'underDate':underDate,'registerDate':registerDate, 'productDueDate':productDueDate,'productsToHonour':productsToHonour,'productBreathDay':productBreathDay,'unitPriceAmount':'2000','salesAmount':'5000', 'raiseAmount':'81234','guaranteedAIRate':'0.067000','expectedAYield':'0.067000'} url = 'http://%s:6005/hdb/autoSuperScript/save'%DBHOST headers = {'content-type': 'application/json'} r = requests.post(url, data=str_json, headers=headers) print r.text self.assertEqual(r.text, '00000000', "tjs_bid_post_success") #进入oms终定审核tjs标 driver=self.driver login_oms.login(self) # time.sleep(2) # driver.switch_to_default_content() time.sleep(3) jiaoyiguanli_ele="ul#men u.nav li.menu:nth-child(2) a.menu" driver.find_element_by_css_selector(jiaoyiguanli_ele).click() driver.switch_to_frame("menuFrame") time.sleep(3) #点击借款管理 driver.find_element_by_xpath("/html/body/div[3]/div[2]/div/a").click() time.sleep(1) driver.find_element_by_css_selector("div#collapse169.accordion-body div.accordion-inner ul.nav li:nth-child(2) a.lh001").click() time.sleep(2) con=Bankunion_proc() biao_id=con.back_biaoid(bankname='lccb',bidstatus=10) if biao_id is None: time.sleep(5) con=Bankunion_proc() biao_id=con.back_biaoid(bankname='lccb',bidstatus=10) driver.switch_to_default_content() driver.switch_to_frame("mainFrame") while 1: try: zhongding=driver.find_element_by_css_selector("table#contentTable.table tbody tr td a.status[bid='%s']"%biao_id) break except NoSuchElementException: time.sleep(3) break zhongding.click() time.sleep(1) refundwayname=driver.find_element_by_xpath("/html/body/form/table[2]/thead/tr[4]/th[2]").text self.assertEqual(u"到期一次性还本付息", refundwayname, u"还款方式错误") #点击批核按钮 driver.find_element_by_css_selector("form#inputForm.form-horizontal div input[type='radio'][value='1']").click() #点击保存按钮 driver.find_element_by_css_selector("div.form-actions input#btnSubmit.btn").click() #driver.switch_to_frame("") driver.switch_to_default_content() time.sleep(2) ntime=0 while 1: try: driver.find_element_by_css_selector("div#jbox-state-state0.jbox-state div.jbox-button-panel button.jbox-button[value='ok']").click() break except NoSuchElementException: time.sleep(2) ntime+=2 if ntime>10: break time.sleep(3)