def prisoner_add(page): """罪犯信息导入""" # 生成模板 list = xlsx_read('./tmp_file/import.xlsx', '添加新犯') xls_update('./tmp_file/新学员导入模板.xls', list, 2) file_path = os.path.abspath('./') page.driver.find_element_by_link_text('基础信息管理').click() page.driver.find_element_by_link_text('戒毒人员信息管理').click() page.driver.switch_to_frame(1) page.fun_btn_nth5.click() page.driver.switch_to.default_content() page.driver.switch_to_frame(2) page.btn_file_upload.click() page.input_file_upload.send_keys(file_path + '/tmp_file/新学员导入模板.xls') sleep(1) page.base_prisoner_file_upload_submit.click() sleep(2) result = page.base_prisoner_file_upload_result for item in result: assert "有误" not in item.text page.base_prisoner_add_submit.click() sleep(1) try: page.driver.switch_to.default_content() result = page.base_prisoner_add_submit_result.text except: page.driver.switch_to_frame(2) result = page.win_error.text return result
def goods_sell_return(page): """ 销售退货 """ excel_list = xlsx_read('./tmp_file/import.xlsx', '销售') page.driver.find_element_by_link_text('销售业务管理').click() for i in range(0, len(excel_list)): page.driver.find_element_by_link_text('销售订单退货').click() page.driver.switch_to_frame(1) page.sell_return_prisoner.click() sleep(0.5) page.sell_return_prisoner.send_keys(excel_list[i][0]) sleep(0.5) page.btn_search.click() sleep(1) js = "document.getElementsByClassName('fixed-table-body')[0].scrollLeft=1000" page.driver.execute_script(js) page.sell_center_return page.driver.find_element_by_css_selector( 'tr:nth-child({}) .fa-reply'.format(i + 1)).click() page.driver.switch_to.default_content() page.driver.switch_to_frame(2) page.driver.execute_script('window.scrollTo(0,1000);') page.sell_center_return_all.click() page.sell_center_return_cont.send_keys('退货测试') page.sell_center_return_submit.click() page.driver.switch_to.default_content() res = page.sell_center_submit_result.text assert "处理中" in res goods_sell_return_query(page, excel_list)
def prisoner_leave(page): # 生成上账模板 global list list = xlsx_read('./tmp_file/import.xlsx', '出狱') page.driver.find_element_by_link_text('资金业务管理').click() # for i in range(0, len(list)): # page.driver.find_element_by_link_text('出所结算').click() # page.driver.switch_to_frame(1) # page.money_manage_leave # sleep(5) # page.money_manage_leave.click() # sleep(2) # page.money_manage_leave.send_keys(list[i][0]) # sleep(1) # page.btn_search.click() # sleep(1) # page.driver.find_element_by_link_text('出所结算').click() # page.money_manage_leave_cont.send_keys("出狱测试") # page.money_manage_leave_submit.click() # res = page.dialog_h2.text # # if "出所结算完成" in res: # assert "完成" in res # else: # assert "成功" in res # # page.driver.switch_to.default_content() # page.win_min_close.click() # sleep(1) prisoner_leave_cancel(page)
def prisoner_switch_level(page): # 生成模板 js_ver = 'window.scrollTo(0,1000);' list = xlsx_read('./tmp_file/import.xlsx', '转级') xls_update('./tmp_file/批量转级模板.xls', list, 1) page.driver.find_element_by_link_text('基础信息管理').click() page.driver.find_element_by_link_text('戒毒人员转级管理').click() page.driver.switch_to_frame(1) page.prisoner_switch_area.click() page.driver.switch_to.default_content() page.driver.switch_to_frame(2) page.prisoner_switch_area_upload.click() page.input_file_upload.send_keys( os.path.abspath('./') + '/tmp_file/批量转级模板.xls') sleep(2) page.prisoner_switch_level_upload_submit.click() sleep(2) res = page.prisoner_switch_area_upload_list cursor1 = conn("116.63.68.108", "lecentMysql", "lecentMysql#1234", "gd_9081") bol = True index = 0 for item in res: if bol: bol = False continue text = item.text.split(maxsplit=6) config_list = query_one( cursor1, "select t.`Name` from prisoner as p,treat_level as t where p.TreatLevelID = t.ID and " "p.`Code`='{}'".format(list[index][1])) # 断言监区是否正确 assert str(text[5]) == str(config_list) index += 1 close() page.prisoner_switch_level_cont.send_keys('转级测试') page.driver.execute_script(js_ver) page.btn_next.click() sleep(1) page.btn_next.click() sleep(1) res = page.prisoner_switch_area_submit_result.text return res
def goods_sell(page, is_confirm, is_check): """ 供应站销售 """ list = xlsx_read('./tmp_file/import.xlsx', '上下账') js = 'window.scrollTo(0,1000);' page.driver.find_element_by_link_text('销售业务管理').click() for i in range(0, len(list)): page.driver.find_element_by_link_text('供应站销售').click() page.driver.switch_to_frame(1) page.sell_center_prisoner.click() sleep(1) page.sell_center_prisoner.send_keys(list[i][0]) sleep(2) page.sell_center_prisoner_select.click() sleep(1) page.sell_center_store.click() page.sell_center_store_select.click() page.sell_center_goods.click() page.sell_center_goods_select.click() sleep(1) page.sell_center_submit.click() sleep(2) page.sell_center_submit_confirm.click() sleep(2) page.driver.switch_to.default_content() page.sell_center_submit_result_confirm sleep(0.5) res = page.sell_center_submit_result.text if "成功" not in res: is_confirm[0] = True sleep(1) assert "成功" in res page.sell_center_submit_result_confirm.click() sleep(0.5) page.win_min_close.click() if is_check == '0': goods_sell_check(page, 2)
def money_in(page, is_check): # 生成上账模板 list = xlsx_read('./tmp_file/import.xlsx', '上下账') xls_update('./tmp_file/资金上账模板.xls', list, 1) page.driver.find_element_by_link_text('资金业务管理').click() page.driver.find_element_by_link_text('资金上账').click() page.driver.switch_to_frame(1) page.money_manage_in_add.click() page.driver.switch_to.default_content() page.driver.switch_to_frame(2) page.money_manage_in_add_class.click() page.money_manage_in_add_class_check.click() page.money_manage_in_add_type.click() page.money_manage_in_add_type_check.click() # 上传文件 page.money_manage_in_file_upload.click() page.input_file_upload.send_keys( os.path.abspath('./') + '/tmp_file/资金上账模板.xls') sleep(3) # 点击开始上传 page.money_manage_in_file_submit.click() page.money_manage_in_cont.send_keys('测试上账') page.btn_next.click() js = 'window.scrollTo(0,1000);' page.driver.execute_script(js) page.btn_next.click() page.money_manage_in_close.click() # 上账完成 page.driver.switch_to.default_content() page.driver.switch_to_frame(1) page.win_refresh.click() sleep(1) money_in_check(page, is_check, 1)
def money_out(page, flag): # 生成上账模板 list = xlsx_read('./tmp_file/import.xlsx', '上下账') xls_update('./tmp_file/资金下账模板.xls', list, 1) js = 'window.scrollTo(0,1000);' page.driver.find_element_by_link_text('资金业务管理').click() page.driver.find_element_by_link_text('资金下账').click() page.driver.switch_to_frame(1) page.money_manage_in_add.click() page.driver.switch_to.default_content() page.driver.switch_to_frame(2) page.money_manage_out_add_class.click() page.money_manage_out_add_class_check.click() page.money_manage_out_add_type.click() page.money_manage_out_add_type_check.click() # 点击 上传文件 page.money_manage_in_file_upload.click() page.money_manage_out_file_check.send_keys( os.path.abspath('./') + '/tmp_file/资金下账模板.xls') sleep(2) # 点击开始上传 page.money_manage_out_file_submit.click() sleep(3) page.money_manage_out_cont.send_keys('测试下账thuu') page.driver.execute_script(js) page.btn_next.click() sleep(1) page.driver.execute_script(js) page.btn_next.click() sleep(1) page.money_manage_out_close.click() # 审核 page.driver.switch_to.default_content() page.driver.switch_to_frame(1) page.win_refresh.click() sleep(1) # 审核下账 if flag == '0': page.money_manage_out_check.click() page.money_manage_out_check_cont.send_keys('审核通过') page.money_manage_out_check_submit.click() page.win_prisoner_confirm.click() # 提交下账 page.money_manage_out_submit.click() sleep(1) page.win_prisoner_confirm.click() res = "" page.win_refresh.click() # res = page.money_manage_out_result.text while True: res = page.money_manage_out_result.text sleep(1) if "处理中" in res: page.win_refresh.click() else: break sleep(2) page.driver.switch_to.default_content() page.win_min_close.click() sleep(1) page.driver.find_element_by_link_text('资金业务管理').click() return res