def pageStatus(): option = webdriver.ChromeOptions() option.add_argument('disable-infobars') # 不打开浏览器 option.add_argument('--headless') option.add_argument('--disable-gpu') driver = webdriver.Chrome(options=option) driver.implicitly_wait(10) ret = 0 msgError = '' if (login.run(driver)): log.e('登陆失败') ret = 1 msgError = msgError + "crm登陆失败\n" if toThird.run(driver, config.caseCompanyName, config.caseTaxId): log.e('进账簿失败') ret = 1 msgError = msgError + "进账簿失败\n" if loginNew.run(driver): log.e('第三方跳转登陆失败') ret = 1 msgError = msgError + "第三方跳转登录失败\n" return ret, msgError
def runClear(driver): log.d('清空往来单位') try: if toThird.run(driver, config.caseCompanyName, config.caseTaxId): return 1 if commonSelenium.toPage( driver, config.domain + "/cs-third/con/contactsunit/contactsunitlist"): return 1 while 1: dels = driver.find_elements_by_id('deleteContact') if len(dels) == 0: if 'active-kh' in driver.find_element_by_id( 'company').get_attribute('class'): driver.find_element_by_id('people').click() continue else: break dels[0].click() time.sleep(config.ACTION_WAIT_SLEEP_LONG) times = 0 maxTimes = int(config.LOAD_PAGE_TIMEOUT / config.WHILE_WAIT_SLEEP) while times < maxTimes: if driver.find_element_by_class_name( 'bootbox-body').text == '确认删除?': btns = driver.find_elements_by_class_name('btn-primary') for btn in btns: if btn.text == 'OK': btn.click() log.i( "往来单位- 删除", driver.find_element_by_class_name( 'kh-text').text) break if times == maxTimes: log.e("往来单位-删除等待确认超时") return 1 times = times + 1 time.sleep(config.WHILE_WAIT_SLEEP) time.sleep(config.ACTION_WAIT_SLEEP_LONG) log.i("往来单位-删除完成") return 0 except: r = requests.get(driver.current_url, allow_redirects=False) log.exception('往来单位-删除异常', r.status_code) return 1
def run(driver): log.d('期末结转') alert = None try: if toThird.run(driver, config.caseCompanyName, config.caseTaxId): return 1 if commonSelenium.toPage(driver, config.domain + "/cs-third/jz/qmjz/initqmjz"): return 1 driver.find_element_by_class_name('calculationthismonth').click() time.sleep(config.ACTION_WAIT_SLEEP_LONG) driver.find_element_by_class_name('btn-primary').click() time.sleep(config.ACTION_WAIT_SLEEP_LONG) # try: # alert = WebDriverWait(driver, 10, poll_frequency=0.5).until( # lambda x: x.find_element_by_class_name('btn-primary')) # # alert.click() # return 0 # except TimeoutException: # log.w('TimeoutException') # return 1 # except: # log.exception('期末结转异常') # return 1 times = 0 maxTimes = int(config.LOAD_PAGE_TIMEOUT / config.WHILE_WAIT_SLEEP) while times < maxTimes: btn = driver.switch_to.active_element if btn.tag_name == 'button' and btn.text == '确定': btn.click() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) break if times == maxTimes: log.e("期末结转等待确认超时") return 1 times = times + 1 log.i("期末结转完成") return 0 except: r = requests.get(driver.current_url, allow_redirects=False) log.exception('期末结转', r.status_code) return 1
def run(driver): log.d('信息采集') dicts = dict try: if toThird.run(driver, config.caseCompanyName, config.caseTaxId): time.sleep(config.FAIL_WAIT_SLEEP) return 1 if commonSelenium.toPage( driver, config.domain + "/cs-third/fil/fileManagement/fileManagementList"): return 1 driver.find_element_by_id('currentDate').click() time.sleep(config.ACTION_WAIT_SLEEP_LONG) months = driver.find_elements_by_class_name('month') for month in months: if str(config.caseCurrentAccountMonth) + '月' in month.text: ActionChains(driver).move_to_element(month).click().perform() time.sleep(config.ACTION_WAIT_SLEEP_LONG) break time.sleep(config.ACTION_WAIT_SLEEP_LONG) rows = driver.find_elements_by_xpath( "//table[@id='customerTable']/tbody/tr") for i in range(len(rows)): if i < 1: continue tdsSum = rows[i].find_elements_by_tag_name("td") if tdsSum[1].text != '' and tdsSum[1].text != '11': line = tdsSum[1].text log.i('信息采集页面接口对比通过') return 0 except: r = requests.get(driver.current_url, allow_redirects=False) log.exception('信息采集', r.status_code) return 1
def runAdd(driver, partnerName): log.d('新增往来单位') try: if toThird.run(driver, config.caseCompanyName, config.caseTaxId): return 1 if commonSelenium.toPage( driver, config.domain + "/cs-third/con/contactsunit/contactsunitlist"): return 1 # driver.find_element_by_id('company').click() # driver.find_element_by_id('people').click() driver.find_element_by_id('add').click() time.sleep(config.ACTION_WAIT_SLEEP_LONG) driver.find_element_by_id('partnerName').send_keys(partnerName) time.sleep(config.ACTION_WAIT_SLEEP_LONG) driver.find_element_by_id('contactFormBtn').click() time.sleep(config.ACTION_WAIT_SLEEP_LONG) count = 0 while (count < config.LOAD_PAGE_TIMEOUT): names = driver.find_elements_by_class_name('kh-text') deletes = driver.find_elements_by_id('deleteContact') for index in range(len(names)): if names[index].text == partnerName: log.i('新增往来单位成功') return 0 elementsError = driver.find_elements_by_class_name('error') if len(elementsError) == 2 and elementsError[1].text != '': log.e('新增往来单位失败', elementsError[1].text) break count = count + 1 time.sleep(config.WHILE_WAIT_SLEEP) log.e('新增往来单位失败, 添加后未找到') return 1 except: r = requests.get(driver.current_url, allow_redirects=False) log.exception('新增往来单位异常', r.status_code) return 1
def runBack(driver): log.d('反结账') try: if toThird.run(driver, config.caseCompanyName, config.caseTaxId): time.sleep(config.FAIL_WAIT_SLEEP) return 1 if commonSelenium.toPage( driver, config.domain + "/cs-third/st/settle/toSettleAccounts"): return 1 lastSettleDate = driver.find_element_by_class_name('marked_words').text if lastSettleDate == '上次结账: 无数据': log.i(lastSettleDate, '测试会计月:', config.caseCurrentAccountMonth) return 0 lastSettleDate = lastSettleDate.replace('上次结账至:', '') driver.find_element_by_id('dateTime').click() time.sleep(config.ACTION_WAIT_SLEEP_LONG) # years = document[0].year - int(driver.find_elements_by_class_name('datepicker-switch')[1].text) # # if years < 0: # for i in range(-1 * years): # << # ActionChains(driver).move_to_element(driver.find_elements_by_class_name('prev')[1]).click().perform() # time.sleep(ACTION_WAIT_SLEEP_SHORT) # if years > 0: # for i in range(years): # >> # ActionChains(driver).move_to_element(driver.find_elements_by_class_name('next')[1]).click().perform() # time.sleep(ACTION_WAIT_SLEEP_SHORT) lastSettleYear = int(lastSettleDate.split('-')[0]) lastSettleMonth = int(lastSettleDate.split('-')[1]) months = driver.find_elements_by_class_name('month') if config.caseCurrentAccountYear * 100000 + config.caseCurrentAccountMonth <= lastSettleYear * 100000 + lastSettleMonth: for month in months: if str(lastSettleMonth) + '月' in month.text: ActionChains(driver).move_to_element( month).click().perform() times = 0 maxTimes = int(config.LOAD_PAGE_TIMEOUT / config.WHILE_WAIT_SLEEP) while times < maxTimes: time.sleep(config.ACTION_WAIT_SLEEP_LONG) if driver.find_element_by_id('checkBtn').text == '反结账': driver.find_element_by_id('checkBtn').click() time.sleep(config.ACTION_WAIT_SLEEP_LONG) alert = driver.find_element_by_class_name( 'bootbox-body') if alert.text == '反结账成功': log.i("反结账成功", str(lastSettleDate), '月') btns = driver.find_elements_by_class_name( 'btn-primary') for btn in btns: if btn.text == 'OK': btn.click() if runBack(driver) == 0: return 0 else: log.w(driver.find_element_by_id('checkBtn').text) times = times + 1 if times == maxTimes: log.e('反结账月份选择后等待超时') return 1 else: log.w(lastSettleDate, "反结账") return 0 return 1 except: r = requests.get(driver.current_url, allow_redirects=False) log.exception('反结账', r.status_code) return 1
def run(driver): log.d('结账') try: if toThird.run(driver, config.caseCompanyName, config.caseTaxId): time.sleep(config.FAIL_WAIT_SLEEP) return 1 if commonSelenium.toPage( driver, config.domain + "/cs-third/st/settle/toSettleAccounts"): return 1 lastSettleMonth = driver.find_element_by_class_name( 'marked_words').text if lastSettleMonth != '上次结账: 无数据' and int( lastSettleMonth.split('-') [1]) >= config.caseCurrentAccountMonth: log.w(lastSettleMonth, "不需结账") return 0 driver.find_element_by_id('checkBtn').click() times = 0 maxTimes = int(config.LOAD_PAGE_TIMEOUT / config.WHILE_WAIT_SLEEP) while times < maxTimes: time.sleep(config.ACTION_WAIT_SLEEP_LONG) if driver.find_element_by_id('checkBtn').text == '继续结账': driver.find_element_by_id('checkBtn').click() time.sleep(config.ACTION_WAIT_SLEEP_LONG) alert = driver.find_element_by_class_name('bootbox-body') if alert.text == '结账成功': log.i("结账成功") btns = driver.find_elements_by_class_name('btn-primary') for btn in btns: if btn.text == 'OK': btn.click() return 0 else: log.i("结账成功22222", alert.text) elif driver.find_element_by_id('checkBtn').text == '重新检查': log.e("马上检查未通过") lis = driver.find_elements_by_xpath( "//div[@class='ckPannel']/div[3]/div/ul/li") for i in range(len(lis)): li = driver.find_element_by_xpath( "//div[@class='ckPannel']/div[3]/div/ul/li[" + str(i + 1) + "]/i") if li.get_attribute('class') == 'describe_i error': log.w( driver.find_element_by_xpath( "//div[@class='ckPannel']/div[3]/div/ul/li[" + str(i + 1) + "]/span[1]").text, driver.find_element_by_xpath( "//div[@class='ckPannel']/div[3]/div/ul/li[" + str(i + 1) + "]/span[2]").text) return 1 if times == maxTimes: log.e("结账失败-马上检查超时") return 1 times = times + 1 except: r = requests.get(driver.current_url, allow_redirects=False) log.exception('结账', r.status_code) return 1
def run(driver): log.d('余额表') dictsApi = {} try: params = { 'origin': 'zidh', 'taxNo': config.caseTaxId, 'year': config.caseCurrentAccountYear, 'startMonth': config.caseCurrentAccountMonth, 'endMonth': config.caseCurrentAccountMonth } log.i('API 余额表获取', config.domain_api) response = requests.get(config.domain_api + '/api/report/balance', params=params, allow_redirects=False) response.encoding = 'utf-8' if response.status_code == 200: ret = json.loads(response.text) if str(ret['code']) == '200': dicts = ret['data'] for dict in dicts: if dict['beginningBalanceDebit'] == dict['beginningBalanceCrebit'] == dict['currentAmountDebit'] \ == dict['currentAmountCrebit'] == dict['endingBalanceDebit'] == dict[ 'endingBalanceCrebit'] == '0.00': continue km = dict2Kemuyueb(dict) dictsApi[km.accountCode] = km else: log.e('API 余额表获取失败:', response.text) return 1 else: log.e('API 余额表获取失败HTTP:', response.status_code) return 1 log.i('API 余额表获取成功:') if toThird.run(driver, config.caseCompanyName, config.caseTaxId): time.sleep(config.FAIL_WAIT_SLEEP) return 1 if commonSelenium.toPage( driver, config.domain + "/cs-third/cer/balance/balanceList"): return 1 driver.find_element_by_id('startMonth').find_elements_by_tag_name( "option")[config.caseCurrentAccountMonth - 1].click() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) driver.find_element_by_id('endMonth').find_elements_by_tag_name( "option")[config.caseCurrentAccountMonth - 1].click() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) shutil.rmtree(config.FILE_DOWNLOAD) os.mkdir(config.FILE_DOWNLOAD) driver.find_element_by_id('downloadBtn').click() times = 0 maxTimes = int(config.LOAD_PAGE_TIMEOUT / config.WHILE_WAIT_SLEEP) while times < maxTimes: time.sleep(config.ACTION_WAIT_SLEEP_LONG) if '数据导出并下载成功' in driver.find_element_by_class_name( 'bootbox-body').text: driver.find_element_by_class_name('btn-primary').click() break if times == maxTimes: log.e("余额表-余额表下载超时") return 1 times = times + 1 time.sleep(config.ACTION_WAIT_SLEEP_LONG) time.sleep(config.ACTION_WAIT_SLEEP_LONG) retCode, dictsDownload = excelTools.read_balanceList() if retCode != 0: time.sleep(config.FAIL_WAIT_SLEEP) log.e('余额表批量下载失败:') return 1 if len(dictsDownload) - 1 != len(dictsApi): log.e('API余额表数量与下载数量不一致 dictsDownload:', str(len(dictsDownload)), 'listsApi:', str(len(dictsApi))) return 1 time.sleep(config.ACTION_WAIT_SLEEP_LONG) driver.find_element_by_id('doFind').click() time.sleep(config.ACTION_WAIT_SLEEP_LONG) rows = driver.find_elements_by_xpath( "//table[@id='customerTable']/tbody/tr") for i in range(len(rows)): if i < 2: continue tdsSum = rows[i].find_elements_by_tag_name("td") code = tdsSum[0].text name = tdsSum[1].text qcDebit = float('0.00' if ( tdsSum[2].text == '') else tdsSum[2].text.replace(',', '')) qcCrebit = float('0.00' if ( tdsSum[3].text == '') else tdsSum[3].text.replace(',', '')) bqDebit = float('0.00' if ( tdsSum[4].text == '') else tdsSum[4].text.replace(',', '')) bqCrebit = float('0.00' if ( tdsSum[5].text == '') else tdsSum[5].text.replace(',', '')) qmDebit = float('0.00' if ( tdsSum[6].text == '') else tdsSum[6].text.replace(',', '')) qmCrebit = float('0.00' if ( tdsSum[7].text == '') else tdsSum[7].text.replace(',', '')) if i == len(rows) - 1: if qcDebit != qcCrebit or bqDebit != bqCrebit or qmDebit != qmCrebit: log.e('页面合计不平衡', qcDebit, qcCrebit, bqDebit, bqCrebit, qmDebit, qmCrebit) return 1 else: if dictsDownload.get('sum').beginningBalanceDebit != qcDebit \ or dictsDownload.get('sum').beginningBalanceCrebit != qcCrebit \ or dictsDownload.get('sum').currentAmountDebit != bqDebit \ or dictsDownload.get('sum').currentAmountCrebit != bqCrebit \ or dictsDownload.get('sum').endingBalanceDebit != qmDebit \ or dictsDownload.get('sum').endingBalanceCrebit != qmCrebit: log.e('页面与下载文件合计对比失败', '\n', '页面结果:\t', name, qcDebit, qcCrebit, bqDebit, bqCrebit, qmDebit, qmCrebit, '\n', '下载文件:\t', dictsDownload.get('sum').beginningBalanceDebit, dictsDownload.get('sum').beginningBalanceCrebit, dictsDownload.get('sum').currentAmountDebit, dictsDownload.get('sum').currentAmountCrebit, dictsDownload.get('sum').endingBalanceDebit, dictsDownload.get('sum').endingBalanceCrebit) return 1 else: log.i('页面合计', qcDebit, qcCrebit, bqDebit, bqCrebit, qmDebit, qmCrebit) break continue if dictsApi.get(code).beginningBalanceDebit == dictsDownload.get(code).beginningBalanceDebit == qcDebit \ and dictsApi.get(code).beginningBalanceCrebit == dictsDownload.get( code).beginningBalanceCrebit == qcCrebit \ and dictsApi.get(code).currentAmountDebit == dictsDownload.get( code).currentAmountDebit == bqDebit \ and dictsApi.get(code).currentAmountCrebit == dictsDownload.get( code).currentAmountCrebit == bqCrebit \ and dictsApi.get(code).endingBalanceDebit == dictsDownload.get( code).endingBalanceDebit == qmDebit \ and dictsApi.get(code).endingBalanceCrebit == dictsDownload.get( code).endingBalanceCrebit == qmCrebit: log.e('页面接口对比失败', code, '\n', '页面结果:\t', name, qcDebit, qcCrebit, bqDebit, bqCrebit, qmDebit, qmCrebit, '\n', '接口结果:\t', dictsApi.get(code).beginningBalanceDebit, dictsApi.get(code).beginningBalanceCrebit, dictsApi.get(code).currentAmountDebit, dictsApi.get(code).currentAmountCrebit, dictsApi.get(code).endingBalanceDebit, dictsApi.get(code).endingBalanceCrebit, '\n', '下载文件:\t', dictsDownload.get(code).beginningBalanceDebit, dictsDownload.get(code).beginningBalanceCrebit, dictsDownload.get(code).currentAmountDebit, dictsDownload.get(code).currentAmountCrebit, dictsDownload.get(code).endingBalanceDebit, dictsDownload.get(code).endingBalanceCrebit) return 1 # else: # log.d('页面接口对比通过', code, str(i) + '/' + str(len(rows))) log.i('页面接口对比通过') return 0 except: r = requests.get(driver.current_url, allow_redirects=False) log.exception('余额表', r.status_code) return 1
def run(driver): log.d('明细账') try: retCode, listsApi = subsidiaryLedgerListFromApi() if retCode != 0: time.sleep(config.FAIL_WAIT_SLEEP) return 1 if toThird.run(driver, config.caseCompanyName, config.caseTaxId): time.sleep(config.FAIL_WAIT_SLEEP) return 1 if commonSelenium.toPage( driver, config.domain + "/cs-third/cer/subsidiaryLedger/subsidiaryLedgerList"): return 1 driver.find_element_by_id('startMonth').find_elements_by_tag_name( "option")[config.caseCurrentAccountMonth - 1].click() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) driver.find_element_by_id('endMonth').find_elements_by_tag_name( "option")[config.caseCurrentAccountMonth - 1].click() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) shutil.rmtree(config.FILE_DOWNLOAD) os.mkdir(config.FILE_DOWNLOAD) driver.find_element_by_id('downloadBtnAll').click() times = 0 maxTimes = int(config.LOAD_PAGE_TIMEOUT / config.WHILE_WAIT_SLEEP) while times < maxTimes: time.sleep(config.ACTION_WAIT_SLEEP_LONG) if '数据导出并下载成功' in driver.find_element_by_class_name( 'bootbox-body').text: driver.find_element_by_class_name('btn-primary').click() break if times == maxTimes: log.e("明细账-明细账批量下载超时") return 1 times = times + 1 retCode, listsDownload = excelTools.read_subsidiaryLedgerList() if retCode != 0: time.sleep(config.FAIL_WAIT_SLEEP) log.e('明细账批量下载失败:') return 1 if len(listsDownload) != len(listsApi): log.e('API明细账数量与批量下载数量不一致 listsDownload:', str(len(listsDownload)), 'listsApi:', str(len(listsApi))) return 1 time.sleep(config.ACTION_WAIT_SLEEP_SHORT) for subsidiaryLedger in listsDownload: if len(subsidiaryLedger) > 4: continue driver.find_element_by_id('select2-km-container').click() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) driver.find_element_by_class_name( 'select2-search__field').send_keys(subsidiaryLedger) time.sleep(config.ACTION_WAIT_SLEEP_SHORT) while 1: if driver.find_element_by_class_name( 'select2-results__option--highlighted').text.split( ' ')[0] == subsidiaryLedger: driver.find_element_by_class_name( 'select2-search__field').send_keys(Keys.ENTER) break else: driver.find_element_by_class_name( 'select2-search__field').send_keys(Keys.DOWN) time.sleep(config.ACTION_WAIT_SLEEP_SHORT) time.sleep(config.ACTION_WAIT_SLEEP_SHORT) driver.find_element_by_id('doFind').click() time.sleep(config.ACTION_WAIT_SLEEP_LONG) rows = driver.find_elements_by_xpath( "//table[@id='customerTable']/tbody/tr") accountCode = driver.find_element_by_id( 'select2-km-container').text.split(' ')[0] accountName = driver.find_element_by_id( 'select2-km-container').text.split(' ')[1] for i in range(len(rows)): tdsSum = rows[i].find_elements_by_tag_name("td") date = tdsSum[0].text voucherNo = tdsSum[1].text summary = tdsSum[2].text debitAmount = '0.00' if ( tdsSum[3].text == '') else tdsSum[3].text.replace(',', '') creditAmount = '0.00' if ( tdsSum[4].text == '') else tdsSum[4].text.replace(',', '') direction = tdsSum[5].text qmYue = '0.00' if (tdsSum[6].text == '') else tdsSum[6].text.replace(',', '') # sl=SubsidiaryLedger(kmCode, kmName, date, voucherNo, summary, debitAmount, creditAmount, direction, qmYue) # log.d('页面\t', accountCode, accountName, date, voucherNo, summary, debitAmount, creditAmount, direction, qmYue) api = listsApi[accountCode][i] # log.d('API\t', api.accountCode, api.accountName, api.date, api.voucherNo, # api.summary, api.debitAmount, api.creditAmount, api.direction, api.qmYue) excel = listsDownload[accountCode][i] # log.d('excel\t', excel.accountCode, excel.accountName, excel.date, excel.voucherNo, # excel.summary, excel.debitAmount, excel.creditAmount, excel.direction, excel.qmYue) if not (date == excel.date == api.date) or not ( direction == excel.direction == api.direction) or not ( summary == excel.summary == api.summary): log.e('明细账对比失败') return 1 elif not (voucherNo == excel.voucherNo == api.voucherNo): log.e('明细账对比失败 voucherNo') return 1 elif not (float(debitAmount) == excel.debitAmount == api.debitAmount): log.e('明细账对比失败 debitAmount') return 1 elif not (float(creditAmount) == excel.creditAmount == api.creditAmount): log.e('明细账对比失败 creditAmount') return 1 elif not (float(qmYue) == excel.qmYue == api.qmYue): log.e('明细账对比失败 qmYue') return 1 log.i('页面接口对比通过', subsidiaryLedger) log.i('页面接口对比通过') return 0 except: r = requests.get(driver.current_url, allow_redirects=False) log.exception('明细账', r.status_code) return 1
def run(driver): log.d('新增凭证') ret, documents, msg = read_documentAdd() if ret != 0: log.e('加载凭证文件失败', msg) return 1 if len(documents) == 0: log.w('加载凭证文件数量为0') return 1 # if toThird.run(driver, documents[0][0].company_name, documents[0][0].tax_id): if toThird.run(driver, config.caseCompanyName, config.caseTaxId): print('进账簿失败', ret) return 1 if toPage(driver, config.domain + "/cs-third/cer/certificate/toAddCertificate"): return 1 # alertDiv = driver.find_element_by_id('alertDiv') # startX = alertDiv.location['x'] + 100 + 135 # startY = alertDiv.location['y'] + 150 for document in documents: # mouseLeftDoubleClick(driver, startX, startY) # driver.find_element_by_class_name('zy-text').d # driver.find_elements_by_class_name('zy-text')[0]. time.sleep(config.ACTION_WAIT_SLEEP_LONG) ActionChains(driver).move_to_element( driver.find_elements_by_class_name('zy-text') [0]).double_click().perform() time.sleep(config.ACTION_WAIT_SLEEP_LONG) for index in range(len(document)): documentDetail = document[index] clearElement(driver.switch_to.active_element) driver.switch_to.active_element.send_keys(documentDetail.summary) driver.switch_to.active_element.send_keys(Keys.TAB) driver.switch_to.active_element.send_keys( documentDetail.account_code) elements = driver.find_elements_by_class_name( 'select2-results__option') if len(elements) == 0: log.e('科目不存在', documentDetail.account_code) return 1 for element in elements: if element.text.split(' ')[0] == documentDetail.account_code: element.click() # driver.switch_to.active_element.send_keys(Keys.TAB) if documentDetail.partner_name != '\\N': # 往来类型 time.sleep(config.ACTION_WAIT_SLEEP_LONG) # driver.find_element_by_id('select2-wldw-container').click() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) ActionChains(driver).move_to_element( driver.find_element_by_id( 'select2-wldw-container')).click().perform() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) driver.find_element_by_class_name( 'select2-search__field').send_keys( documentDetail.partner_name) elements = driver.find_elements_by_class_name( 'select2-results__option') if len(elements) == 0 or (len(elements) == 1 and elements[0].text == 'No results found'): log.w('往来单位不存在', documentDetail.account_code, documentDetail.partner_name) driver.find_element_by_id('add_wldw').click() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) driver.find_element_by_id('partnerName').send_keys( documentDetail.partner_name) time.sleep(config.ACTION_WAIT_SLEEP_SHORT) driver.find_element_by_id('add_wldw_sub').click() # return 1 else: for element in elements: if element.text == documentDetail.partner_name: element.click() driver.find_element_by_id('wldw_sub').click() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) # driver.switch_to.active_element.send_keys(Keys.TAB) if documentDetail.debit_amount != '\\N': # 钱在借方 elements = driver.find_elements_by_class_name('jf-je-text') time.sleep(config.ACTION_WAIT_SLEEP_SHORT) elements[index].click() clearElement(driver.switch_to.active_element) driver.switch_to.active_element.send_keys( str(documentDetail.debit_amount)) # 如果钱在借方。 tab时直接换行 else: elements = driver.find_elements_by_class_name('df-je-text') time.sleep(config.ACTION_WAIT_SLEEP_SHORT) elements[index].click() # clearElement(driver.switch_to.active_element) # 清空借方默认金额 # driver.switch_to.active_element.send_keys(Keys.TAB) clearElement(driver.switch_to.active_element) driver.switch_to.active_element.send_keys( str(documentDetail.credit_amount)) if (index != len(document) - 1): driver.switch_to.active_element.send_keys(Keys.TAB) time.sleep(config.ACTION_WAIT_SLEEP_SHORT) driver.find_element_by_id('btn_xzpz_add_and_save').send_keys( Keys.ENTER) time.sleep(config.ACTION_WAIT_SLEEP_SHORT) times = 0 maxTimes = int(LOAD_PAGE_TIMEOUT / WHILE_WAIT_SLEEP) while (times < maxTimes): if ('零元整' == driver.find_element_by_id('hjjesx').text): break times = times + 1 if times == maxTimes: log.e('新增凭证保存等待 超时') return 1 time.sleep(WHILE_WAIT_SLEEP) log.i('新增凭证完成') return 0
if __name__ == "__main__": print('main') if (config.hostSource == None): log.e('未设置数据源') else: option = webdriver.ChromeOptions() option.add_argument('disable-infobars') driver = webdriver.Chrome(options=option) driver.set_window_size(config.window_size_w, config.window_size_h) driver.implicitly_wait(5) ret = login.run(driver) if (ret != 0): print('登陆失败') time.sleep(config.FAIL_WAIT_SLEEP) driver.quit() else: if toThird.run(driver, '回归测试2', 'taxidCode000000002'): print('进账簿失败') time.sleep(config.FAIL_WAIT_SLEEP) else: # for i in range(10): # run(driver, random.randint(1, 2)) # time.sleep(3) run(driver, '回归测试2', 'taxidCode000000002', 1) time.sleep(5) driver.quit()
def run(driver, accountSetInfo): log.d('建账') try: driver.get(config.domain + "/#/third/customer") driver.find_element_by_id('btn_company_add').send_keys(Keys.ENTER) driver.find_element_by_name('input_company_name').send_keys(accountSetInfo.companyName) driver.switch_to.active_element.send_keys(Keys.TAB) driver.switch_to.active_element.send_keys(accountSetInfo.taxidCode) time.sleep(config.ACTION_WAIT_SLEEP_SHORT) type = accountSetInfo.taxType if type == 0: driver.find_elements_by_class_name('el-radio')[0].click() # 0小规模 1 一般纳税人 2申报周期 月 3 申报周期 季度 driver.switch_to.active_element.send_keys(Keys.TAB) else: driver.find_elements_by_class_name('el-radio')[1].click() # 0小规模 1 一般纳税人 2申报周期 月 3 申报周期 季度 time.sleep(config.ACTION_WAIT_SLEEP_SHORT) driver.switch_to.active_element.send_keys(Keys.TAB) time.sleep(config.ACTION_WAIT_SLEEP_SHORT) yearStr = driver.find_elements_by_class_name('el-date-picker__header-label')[0].text monthStr = driver.find_elements_by_class_name('el-date-picker__header-label')[1].text year = int(yearStr.split(' ')[0]) month = int(monthStr.split(' ')[0]) lastYear = driver.find_element_by_class_name('el-icon-d-arrow-left') lastMonth = driver.find_elements_by_class_name('el-icon-arrow-left')[1] nextYear = driver.find_element_by_class_name('el-icon-d-arrow-right') nextMonth = driver.find_elements_by_class_name('el-icon-arrow-right')[1] years = accountSetInfo.startDateYear - year if years < 0: for i in range(-1 * years): # << ActionChains(driver).move_to_element(lastYear).click().perform() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) if years > 0: for i in range(years): # >> ActionChains(driver).move_to_element(nextYear).click().perform() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) months = accountSetInfo.startDateMonth - month if months < 0: for i in range(-1 * months): # << ActionChains(driver).move_to_element(lastMonth).click().perform() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) if months > 0: for i in range(months): # >> ActionChains(driver).move_to_element(nextMonth).click().perform() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) driver.switch_to.active_element.send_keys(Keys.ENTER) print("mouseRightClick Over") ActionChains(driver).move_to_element(driver.find_element_by_name("select_account_system")).click().perform() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) accountSystems = driver.find_elements_by_name('li_account_system') for i in range(len(accountSystems)): driver.find_element_by_name("select_account_system").send_keys(Keys.DOWN) if accountSystems[i].text == accountSetInfo.accountSystem: ActionChains(driver).move_to_element(accountSystems[i]).click().perform() break time.sleep(config.ACTION_WAIT_SLEEP_SHORT) ActionChains(driver).move_to_element(driver.find_element_by_name("select_org_id")).click().perform() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) orgs = driver.find_elements_by_name('li_org_id') for i in range(len(orgs)): driver.find_element_by_name("select_org_id").send_keys(Keys.DOWN) if orgs[i].text == accountSetInfo.org: ActionChains(driver).move_to_element(orgs[i]).click().perform() break time.sleep(config.ACTION_WAIT_SLEEP_SHORT) ActionChains(driver).move_to_element(driver.find_element_by_name("select_zx_center")).click().perform() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) zxCenters = driver.find_elements_by_name('li_zx_center') for i in range(len(zxCenters)): driver.find_element_by_name("select_zx_center").send_keys(Keys.DOWN) if zxCenters[i].text == accountSetInfo.zxCenter: ActionChains(driver).move_to_element(zxCenters[i]).click().perform() break time.sleep(config.ACTION_WAIT_SLEEP_SHORT) ActionChains(driver).move_to_element(driver.find_element_by_name("select_zcfzgs")).click().perform() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) zcfzgs = driver.find_elements_by_name('li_zcfzgs') for i in range(len(zcfzgs)): driver.find_element_by_name("select_zcfzgs").send_keys(Keys.DOWN) if zcfzgs[i].text == accountSetInfo.zcfzgs: ActionChains(driver).move_to_element(zcfzgs[i]).click().perform() break time.sleep(config.ACTION_WAIT_SLEEP_SHORT) ActionChains(driver).move_to_element(driver.find_element_by_name("select_auditer_id")).click().perform() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) auditerIds = driver.find_elements_by_name('li_auditer_id') for i in range(len(auditerIds)): driver.find_element_by_name("select_auditer_id").send_keys(Keys.DOWN) if "审核员" in auditerIds[i].text: ActionChains(driver).move_to_element(auditerIds[i]).click().perform() driver.find_element_by_name("select_auditer_id").send_keys(Keys.ESCAPE) break time.sleep(config.ACTION_WAIT_SLEEP_SHORT) ActionChains(driver).move_to_element(driver.find_element_by_name("select_input_user_id")).click().perform() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) inputUserIds = driver.find_elements_by_name('li_input_user_id') for i in range(len(inputUserIds)): driver.find_element_by_name("select_input_user_id").send_keys(Keys.DOWN) if "录入员" in inputUserIds[i].text: ActionChains(driver).move_to_element(inputUserIds[i]).click().perform() driver.find_element_by_name("select_input_user_id").send_keys(Keys.ESCAPE) break time.sleep(config.ACTION_WAIT_SLEEP_SHORT) ActionChains(driver).move_to_element(driver.find_element_by_name("select_information_officer_id")).click().perform() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) informationOfficerIds = driver.find_elements_by_name('li_information_officer_id') ActionChains(driver).move_to_element(informationOfficerIds[0]).click().perform() driver.find_element_by_name("select_information_officer_id").send_keys(Keys.ESCAPE) time.sleep(config.ACTION_WAIT_SLEEP_SHORT) ActionChains(driver).move_to_element(driver.find_element_by_name("select_scanner_id")).click().perform() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) scannerIds = driver.find_elements_by_name('li_scanner_id') ActionChains(driver).move_to_element(scannerIds[0]).click().perform() driver.find_element_by_name("select_scanner_id").send_keys(Keys.ESCAPE) time.sleep(config.ACTION_WAIT_SLEEP_SHORT) ActionChains(driver).move_to_element(driver.find_element_by_name("select_declarer_id")).click().perform() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) declarerIds = driver.find_elements_by_name('li_declarer_id') ActionChains(driver).move_to_element(declarerIds[0]).click().perform() driver.find_element_by_name("select_declarer_id").send_keys(Keys.ESCAPE) time.sleep(config.ACTION_WAIT_SLEEP_SHORT) ActionChains(driver).move_to_element(driver.find_element_by_name("select_info_completion_id")).click().perform() time.sleep(config.ACTION_WAIT_SLEEP_SHORT) infoCompletionIds = driver.find_elements_by_name('li_info_completion_id') ActionChains(driver).move_to_element(infoCompletionIds[0]).click().perform() driver.find_element_by_name("select_info_completion_id").send_keys(Keys.ESCAPE) time.sleep(config.ACTION_WAIT_SLEEP_SHORT) driver.find_element_by_name('input_sb_taxrate').send_keys('22') driver.find_element_by_name('input_sb_stock').send_keys('33') driver.find_element_by_name('input_scanning_date').send_keys('1') driver.find_element_by_name('input_checkout_date').send_keys('28') driver.find_element_by_name('input_sb_stock_proportion1').send_keys('1') driver.find_element_by_name('input_sb_stock_proportion2').send_keys('2') driver.find_element_by_name('input_sb_stock_proportion3').send_keys('3') driver.find_element_by_name('input_sb_stock_proportion4').send_keys('4') driver.find_element_by_name('input_sb_stock_proportion5').send_keys('5') driver.find_element_by_name('btn_save').send_keys(Keys.ENTER) if toThird.run(driver,accountSetInfo.companyName,accountSetInfo.taxidCode): log.e("建账后进账簿失败") return 1 else: log.i("建账成功") return 0 except BaseException as e: r = requests.get(driver.current_url, allow_redirects=False) log.exception('建账异常',r.status_code ) return 1
log.e('未设置数据源') else: ret = run() if (ret != 0): print('失败') else: option = webdriver.ChromeOptions() prefs = { 'profile.default_content_settings.popups': 0, 'download.default_directory': config.FILE_DOWNLOAD } option.add_experimental_option('prefs', prefs) option.add_argument('disable-infobars') driver = webdriver.Chrome(options=option) driver.set_window_size(config.window_size_w, config.window_size_h) driver.implicitly_wait(5) ret = loginNew.run(driver) if (ret != 0): print('登陆失败') time.sleep(config.FAIL_WAIT_SLEEP) driver.quit() else: if toThird.run(driver, config.caseCompanyName, config.caseTaxId): time.sleep(config.FAIL_WAIT_SLEEP) time.sleep(5) driver.quit()
return 1 if __name__ == "__main__": print('main') # config.set_host(config.HOST_SOURCE_PRE) if (config.hostSource == None): log.e('未设置数据源') else: option = webdriver.ChromeOptions() option.add_argument('disable-infobars') driver = webdriver.Chrome(options=option) driver.set_window_size(config.window_size_w, config.window_size_h) driver.implicitly_wait(5) ret = login.run(driver) if (ret != 0): print('登陆失败') time.sleep(config.FAIL_WAIT_SLEEP) driver.quit() else: if toThird.run(driver, '上海明创物流有限公司', '913101167989494335'): print('进账簿失败') time.sleep(config.FAIL_WAIT_SLEEP) else: if run(driver): time.sleep(config.FAIL_WAIT_SLEEP) time.sleep(5) driver.quit()
def run(driver, companyName, taxId, type): ''' :param driver: :param type: 审核 1 取消审核 2 全部删除 3 :return: 成功 0 失败 1 ''' log.d('凭证列表-批量处理', type) if toThird.run(driver, companyName, taxId): print('进账簿失败', ret) return 1 try: if commonSelenium.toPage( driver, config.domain + "/cs-third/cer/certificate/certificateList"): return 1 time.sleep(config.ACTION_WAIT_SLEEP_LONG) if driver.find_element_by_id('span_pz_count') == '0': log.i('没有凭证') return 0 time.sleep(config.ACTION_WAIT_SLEEP_LONG) driver.find_element_by_class_name('getAll').click() time.sleep(config.ACTION_WAIT_SLEEP_LONG) iCheck = driver.find_element_by_class_name('checkAll') time.sleep(config.ACTION_WAIT_SLEEP_LONG) documents = driver.find_elements_by_xpath( "//div[@class='pz-list']/table") documentsCountOnPage = int( driver.find_element_by_class_name('total-pz').text.replace( '共计', '').replace('张凭证', '')) if (len(documents) != documentsCountOnPage + 1): log.i('全部加载失败', len(documents), documentsCountOnPage + 1) return 1 if documentsCountOnPage == 0: log.i('凭证列表-没有凭证需要批量处理') return 0 iCheck.send_keys(Keys.SPACE) if not iCheck.is_selected(): iCheck.send_keys(Keys.SPACE) daishenhe = 0 yishenhe = 0 for i in range(documentsCountOnPage): if driver.find_element_by_xpath( "//div[@class='pz-list']/table[" + str(i + 2) + "]/tbody/tr[1]/td[1]/div/input").is_selected(): if driver.find_element_by_xpath( "//div[@class='pz-list']/table[" + str(i + 2) + "]/tbody/tr[1]/td[2]/span").text == '待审核': daishenhe = daishenhe + 1 else: yishenhe = yishenhe + 1 else: log.e('凭证列表-全选未选中') return 1 if type == 1: if daishenhe == 0: # 批量审核 待审核为0 log.i('批量审核 待审核为0') return 0 else: log.d('批量审核 待审核:', daishenhe) elif type == 2: # 批量取消审核 已审核为0 if yishenhe == 0: log.i('批量取消审核 已审核为0') return 0 else: log.d('批量取消审核 已审核:', daishenhe) time.sleep(config.ACTION_WAIT_SLEEP_LONG) if type == 1: element = driver.find_element_by_class_name('uploadMul') element.click() if waitNotice(driver, element): log.i('凭证列表-批量审核成功') # else: # log.e('凭证列表-批量审核等待超时') return 0 elif type == 2: element = driver.find_element_by_id('qxsh') element.click() if waitNotice(driver, element): log.i('凭证列表-批量取消审核成功') # else: # log.e('凭证列表-批量取消审核等待超时') return 0 elif type == 3: element = driver.find_element_by_class_name('deleteMul') element.click() time.sleep(config.ACTION_WAIT_SLEEP_LONG) btnPrimarys = driver.find_elements_by_class_name('btn-primary') for btn in btnPrimarys: if btn.text == 'OK': btn.click() if waitNotice(driver, element): log.i('凭证列表-批量删除成功') # else: # log.e('凭证列表-批量删除等待超时') return 0 return 1 except: r = requests.get(driver.current_url, allow_redirects=False) log.exception('凭证列表-批量处理异常', type, r.status_code) return 1
def run(driver): log.d('资产负债表') dictsApi = {} try: params = { 'origin': 'zidh', 'taxNo': config.caseTaxId, 'year': config.caseCurrentAccountYear, 'month': config.caseCurrentAccountMonth } log.i('API 资产负债表获取', config.domain_api) response = requests.get(config.domain_api + '/api/report/balancesheet', params=params, allow_redirects=False) response.encoding = 'utf-8' if response.status_code == 200: ret = json.loads(response.text) if str(ret['code']) == '200': dictsApi = ret['data'] else: log.e('API 资产负债表获取失败:', response.text) return 1 else: log.e('API 资产负债表获取失败HTTP:', response.status_code) return 1 log.i('API 资产负债表获取成功') if toThird.run(driver, config.caseCompanyName, config.caseTaxId): time.sleep(config.FAIL_WAIT_SLEEP) return 1 if commonSelenium.toPage( driver, config.domain + "/cs-third/cer/balanceSheet/balanceSheetList"): return 1 driver.find_element_by_id('currentDate').click() time.sleep(config.ACTION_WAIT_SLEEP_LONG) months = driver.find_elements_by_class_name('month') for month in months: if str(config.caseCurrentAccountMonth) + '月' in month.text: ActionChains(driver).move_to_element(month).click().perform() time.sleep(config.ACTION_WAIT_SLEEP_LONG) break time.sleep(config.ACTION_WAIT_SLEEP_SHORT) shutil.rmtree(config.FILE_DOWNLOAD) os.mkdir(config.FILE_DOWNLOAD) driver.find_element_by_id('downloadBtn').click() times = 0 maxTimes = int(config.LOAD_PAGE_TIMEOUT / config.WHILE_WAIT_SLEEP) while times < maxTimes: time.sleep(config.ACTION_WAIT_SLEEP_LONG) if '数据导出并下载成功' in driver.find_element_by_class_name( 'bootbox-body').text: btns = driver.find_elements_by_class_name('btn-primary') for btn in btns: if btn.text == "OK": btn.click() break if times == maxTimes: log.e("资产负债表-资产负债表下载超时") return 1 times = times + 1 log.w("资产负债表-资产负债表下载等待", times) time.sleep(config.ACTION_WAIT_SLEEP_LONG) time.sleep(config.ACTION_WAIT_SLEEP_LONG) retCode, dictsDownload = excelTools.read_balanceSheetList() if retCode != 0: time.sleep(config.FAIL_WAIT_SLEEP) log.e('资产负债表下载失败:') return 1 if len(dictsDownload) != len(dictsApi) - 1: log.e('API资产负债表数量与下载数量不一致 dictsDownload:', str(len(dictsDownload)), 'listsApi:', str(len(dictsApi))) return 1 time.sleep(config.ACTION_WAIT_SLEEP_LONG) time.sleep(config.ACTION_WAIT_SLEEP_LONG) rows = driver.find_elements_by_xpath( "//table[@id='customerTable']/tbody/tr") for i in range(len(rows)): if i < 1: continue tdsSum = rows[i].find_elements_by_tag_name("td") if tdsSum[1].text != '' and tdsSum[1].text != '11': line = tdsSum[1].text qm = tdsSum[2].text.replace(',', '') nc = tdsSum[3].text.replace(',', '') # log.e('tdsSum[1]:\t', line) if dictsApi['r' + line + 'qm'] == dictsDownload[ 'r' + line + 'qm'] == qm == '' and dictsApi[ 'r' + line + 'nc'] == dictsDownload[ 'r' + line + 'nc'] == nc == '': pass elif not (float(dictsApi['r' + line + 'qm']) == float( dictsDownload['r' + line + 'qm']) == float(qm) and float(dictsApi['r' + line + 'nc']) == float( dictsDownload['r' + line + 'nc']) == float(nc)): log.e('比较失败——行次', line, '\n页面:\t' '期末余额', qm, '年初余额', nc, '\nAPI:\t', dictsApi['r' + line + 'qm'], '年初余额', dictsApi['r' + line + 'nc'], '\n文件:\t', dictsDownload['r' + line + 'qm'], '年初余额', dictsDownload['r' + line + 'nc']) return 1 # else: # log.d('行次',line,'期末余额', qm, '年初余额', nc ) if tdsSum[5].text != '': line = tdsSum[5].text qm = tdsSum[6].text.replace(',', '') nc = tdsSum[7].text.replace(',', '') # log.e('tdsSum[5]:\t', line) if dictsApi['r' + line + 'qm'] == dictsDownload[ 'r' + line + 'qm'] == qm == '' and dictsApi[ 'r' + line + 'nc'] == dictsDownload[ 'r' + line + 'nc'] == nc == '': pass elif not (float(dictsApi['r' + line + 'qm']) == float( dictsDownload['r' + line + 'qm']) == float(qm) and float(dictsApi['r' + line + 'nc']) == float( dictsDownload['r' + line + 'nc']) == float(nc)): log.e('比较失败——行次', line, '\n页面:\t' '期末余额', qm, '年初余额', nc, '\nAPI:\t', dictsApi['r' + line + 'qm'], '年初余额', dictsApi['r' + line + 'nc'], '\n文件:\t', dictsDownload['r' + line + 'qm'], '年初余额', dictsDownload['r' + line + 'nc']) return 1 # else: # log.d('行次', line, '期末余额', qm, '年初余额', nc) if dictsApi['r30qm'] != dictsApi['r53qm'] or dictsApi[ 'r30nc'] != dictsApi['r53nc']: log.e('资产负债不平衡') return 1 log.i('资产负债表页面接口对比通过') return 0 except: r = requests.get(driver.current_url, allow_redirects=False) log.exception('资产负债表', r.status_code) return 1
def run(driver): log.d('利润表') dicts = dict try: params = { 'origin': 'zidh', 'taxNo': config.caseTaxId, 'year': config.caseCurrentAccountYear, 'month': config.caseCurrentAccountMonth } log.i('API 利润表获取', config.domain_api) response = requests.get(config.domain_api + '/api/report/profit', params=params, allow_redirects=False) response.encoding = 'utf-8' if response.status_code == 200: ret = json.loads(response.text) if str(ret['code']) == '200': dicts = ret['data'] else: log.e('API 利润表获取失败:', response.text) return 1 else: log.e('API 利润表获取失败HTTP:', response.status_code) return 1 if toThird.run(driver, config.caseCompanyName, config.caseTaxId): time.sleep(config.FAIL_WAIT_SLEEP) return 1 if commonSelenium.toPage( driver, config.domain + "/cs-third/cer/profit/profitList"): return 1 driver.find_element_by_id('currentDate').click() time.sleep(config.ACTION_WAIT_SLEEP_LONG) months = driver.find_elements_by_class_name('month') for month in months: if str(config.caseCurrentAccountMonth) + '月' in month.text: ActionChains(driver).move_to_element(month).click().perform() time.sleep(config.ACTION_WAIT_SLEEP_LONG) break time.sleep(config.ACTION_WAIT_SLEEP_LONG) rows = driver.find_elements_by_xpath( "//table[@id='customerTable']/tbody/tr") for i in range(len(rows)): if i < 1: continue tdsSum = rows[i].find_elements_by_tag_name("td") if tdsSum[1].text != '' and tdsSum[1].text != '25': line = tdsSum[1].text bnlje = tdsSum[2].text.replace(',', '') byje = tdsSum[3].text.replace(',', '') if bnlje == '': bnlje = '0.00' if byje == '': byje = '0.00' if dicts['r' + line + 'bnlje'] != bnlje or dicts['r' + line + 'byje'] != byje: log.e('比较失败——行次', line, '本年累计额', bnlje, '本月金额', byje) log.e('本年累计额', dicts['r' + line + 'bnlje'], '本月金额', dicts['r' + line + 'byje']) return 1 # else: # log.d('行次', line, '本年累计额', bnlje, '本月金额', bnlje) log.i('利润表页面接口对比通过') return 0 except: r = requests.get(driver.current_url, allow_redirects=False) log.exception('利润表', r.status_code) return 1