def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() time.sleep(2) self.driver.find_element(*self.gxzygl).click() time.sleep(2) self.driver.find_element(*self.gldgl).click() l.join_iframe() time.sleep(3) self.driver.find_element(*self.first_modify).click() time.sleep(1) self.driver.find_element(*self.gld_length).clear() gld_length_num = random.randint(100, 140) self.driver.find_element(*self.gld_length).send_keys(gld_length_num) self.driver.find_element(*self.submitBtn).click() time.sleep(3) self.driver.find_element(*self.resetBtn).click() first_gld_num = self.driver.find_element(*self.first_gld_length).text try: assert gld_length_num == int(first_gld_num) logging.info('杆路段信息管理修改成功') except: logging.info('杆路段信息管理修改失败') l.getScreenShot('杆路段信息管理修改失败') time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() time.sleep(2) self.driver.find_element(*self.gxzygl).click() time.sleep(2) self.driver.find_element(*self.zjdxx).click() l.join_iframe() time.sleep(3) self.driver.find_element(*self.first_modify).click() time.sleep(1) self.driver.find_element(*self.cable_num).clear() cable_NUM = random.randint(50, 100) self.driver.find_element(*self.cable_num).send_keys(cable_NUM) self.driver.find_element(*self.submitBtn).click() time.sleep(3) self.driver.find_element(*self.resetBtn).click() cable_num_text = self.driver.find_element(*self.first_cable_num).text try: assert cable_NUM == int(cable_num_text) logging.info('中继段信息修改成功') except: logging.info('中继段信息修改失败') l.getScreenShot('中继段信息修改失败') time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() time.sleep(2) self.driver.find_element(*self.gzlgl).click() time.sleep(2) self.driver.find_element(*self.xgzl_detailedList).click() l.join_iframe() time.sleep(3) first_gzl_text = self.driver.find_element(*self.first_gzlNum).text self.driver.find_element(*self.gzl_num_searchInput).send_keys(first_gzl_text) self.driver.find_element(*self.searchBtn).click() time.sleep(2) afSearch_gzlNum = self.driver.find_element(*self.first_gzlNum).text displayText = self.driver.find_element(*self.display).text try: assert first_gzl_text == afSearch_gzlNum and displayText == self.display_text logging.info('事件工作量查询成功') except: logging.info('事件工作量查询失败') l.getScreenShot('事件工作量查询失败') time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() self.driver.find_element(*self.xxrwckBtn).click() l.join_iframe() time.sleep(1) # 模糊搜索 self.driver.switch_to.frame( self.driver.find_element_by_xpath( "//iframe[@id='myframe']")) # 切换至frame内嵌的frame firstline_text = self.driver.find_element( *self.firstline_name).text # 模糊搜索前第一条的线路名称 self.driver.find_element( *self.search_linname).send_keys(firstline_text) self.driver.find_element(*self.fuzzy_searchBtn).click() firstline_text1 = self.driver.find_element( *self.firstline_name).text # 模糊搜索后第一条的线路名称 try: assert firstline_text == firstline_text1 logging.info('巡线任务查看模糊搜索成功') except: logging.info('巡线任务查看模糊搜索失败') l.getScreenShot('巡线任务查看模糊搜索失败') time.sleep(1) # 精确搜索 self.driver.find_element(*self.exact_search).click() self.driver.find_element(*self.exact_search_input).send_keys( firstline_text) # 精确搜索输入线路名称 firstdescribe_text = self.driver.find_element( *self.firstline_describe).text self.driver.find_element( *self.line_describe_input).send_keys(firstdescribe_text) self.driver.find_element(*self.exact_searchBtn).click() firstline_text2 = self.driver.find_element( *self.firstline_name).text # 精确搜索后第一条的线路名称 try: assert firstline_text == firstline_text2 logging.info('巡线任务查看精确搜索成功') except: logging.info('巡线任务查看精确搜索失败') l.getScreenShot('巡线任务查看精确搜索失败') time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() time.sleep(2) self.driver.find_element(*self.gxzygl).click() time.sleep(2) self.driver.find_element(*self.zmdgl).click() l.join_iframe() time.sleep(3) first_start_text = self.driver.find_element( *self.first_start_name).text self.driver.find_element( *self.well_name_input).send_keys(first_start_text) self.driver.find_element(*self.searchBtn).click() time.sleep(1) search_start_text = self.driver.find_element( *self.first_start_name).text try: assert first_start_text == search_start_text logging.info('直埋段信息管理查询成功') except: logging.info('直埋段信息管理查询失败') l.getScreenShot('直埋段信息管理查询失败') self.driver.find_element(*self.first_modify).click() time.sleep(1) self.driver.find_element(*self.zmd_length).clear() zmd_length_num = random.randint(100, 140) self.driver.find_element(*self.zmd_length).send_keys(zmd_length_num) self.driver.find_element(*self.submitBtn).click() time.sleep(1) self.driver.find_element(*self.searchBtn).click() time.sleep(1) first_zmd_text = self.driver.find_element(*self.first_zmd_length).text try: assert zmd_length_num == int(first_zmd_text) logging.info('直埋段信息管理修改成功') except: logging.info('直埋段信息管理修改失败') l.getScreenShot('直埋段信息管理修改失败') time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() self.driver.find_element(*self.xxjlBtn).click() l.join_iframe() time.sleep(1) self.driver.find_element(*self.firstviewBtn).click() time.sleep(2) alert = self.driver.switch_to_alert().accept() time.sleep(2) self.driver.find_element(*self.closeviewBtn).click() self.driver.find_element(*self.firstdetailBtn).click() self.driver.find_element(*self.closedetailBtn).click() # 删除前数据条数 be_PageNum = self.driver.find_element(*self.pageNum).text be_nums = re.findall(r'\d+\.?', be_PageNum) be_num = be_nums[2] be_NUM = int(be_num) logging.info('删除前共有数据%s条' % be_NUM) time.sleep(1) self.driver.find_element(*self.firstdeleteBtn).click() alert = self.driver.switch_to_alert().accept() time.sleep(2) alert = self.driver.switch_to_alert().accept() time.sleep(2) self.driver.find_element(*self.resetBtn).click() time.sleep(1) # 删除后数据条数 af_PageNum = self.driver.find_element(*self.pageNum).text af_nums = re.findall(r'\d+\.?', af_PageNum) af_num = af_nums[2] af_NUM = int(af_num) logging.info('删除后共有数据%s条' % af_NUM) time.sleep(1) try: assert af_NUM == be_NUM - 1 logging.info('===巡线记录删除成功===') except: logging.info('===巡线记录删除失败===') l.getScreenShot('巡线记录删除失败') time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() time.sleep(2) self.driver.find_element(*self.gzlgl).click() time.sleep(2) self.driver.find_element(*self.xgzl_detailedList).click() l.join_iframe() time.sleep(3) self.driver.find_element(*self.personnelGzl).click() time.sleep(1) self.driver.find_element(*self.resetBtn).click() time.sleep(1) self.driver.find_element(*self.select).click() time.sleep(2) # 获取该模块数据条数 string_num = self.driver.find_element(*self.string).text nums = re.findall('\d+\.?', string_num) num = nums[1] NUM = int(num) logging.info('当前页共有数据%s行' % NUM) # 导出当前数据 self.driver.find_element(*self.export_current).click() time.sleep(3) workbook = openpyxl.load_workbook(self.slavepath) # 读取excel sheet = workbook['Sheet1'] h = sheet.max_row # 行 logging.info('导出表数据的行数为%s' % h) time.sleep(2) try: assert NUM == h - 1 logging.info('人员工作量查询导出当前成功') except: logging.info('人员工作量查询导出当前失败') l.getScreenShot('人员工作量查询导出当前失败') os.remove(self.slavepath) # 删除下载的文件 l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() time.sleep(2) self.driver.find_element(*self.gxzygl).click() time.sleep(2) self.driver.find_element(*self.bslr).click() l.join_iframe() time.sleep(3) first_bs_text = self.driver.find_element(*self.first_bs_name).text self.driver.find_element(*self.bs_name_input).send_keys(first_bs_text) self.driver.find_element(*self.searchBtn).click() time.sleep(2) search_bs_text = self.driver.find_element(*self.first_bs_name).text try: assert first_bs_text == search_bs_text logging.info('标石录入查询成功') except: logging.info('标石录入查询失败') l.getScreenShot('标石录入查询失败') self.driver.find_element(*self.first_modifyBtn).click() self.driver.find_element(*self.cable_depth).clear() depth_num = random.randint(30, 50) self.driver.find_element(*self.cable_depth).send_keys(depth_num) self.driver.find_element(*self.submitBtn).click() time.sleep(2) self.driver.find_element(*self.searchBtn).click() time.sleep(1) first_cable_text = self.driver.find_element( *self.first_cable_depth).text try: assert depth_num == int(first_cable_text) logging.info('标石录入修改成功') except: logging.info('标石录入修改失败') l.getScreenShot('标石录入修改失败') self.driver.find_element(*self.resetBtn).click() time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() time.sleep(2) self.driver.find_element(*self.gxzygl).click() time.sleep(2) self.driver.find_element(*self.dglr).click() l.join_iframe() time.sleep(1) first_pole_text = self.driver.find_element(*self.first_pole_name).text self.driver.find_element( *self.pole_name_input).send_keys(first_pole_text) self.driver.find_element(*self.searchBtn).click() search_pole_text = self.driver.find_element(*self.first_pole_name).text try: assert search_pole_text == first_pole_text logging.info('电杆录入查询成功') except: logging.info('电杆录入查询失败') l.getScreenShot('电杆录入查询失败') time.sleep(2) self.driver.find_element(*self.modifyBtn).click() self.driver.find_element(*self.pole_height).clear() num = random.randint(5, 15) self.driver.find_element(*self.pole_height).send_keys(num) self.driver.find_element(*self.submitBtn).click() time.sleep(2) self.driver.find_element(*self.searchBtn).click() pole_height = self.driver.find_element(*self.first_pole_height).text try: assert num == int(pole_height) logging.info('电杆录入修改成功') except: logging.info('电杆录入修改失败') l.getScreenShot('电杆录入修改失败') time.sleep(2) self.driver.find_element(*self.resetBtn).click() time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.swglBtn).click() self.driver.find_element(*self.bsfBtn).click() l.join_iframe() time.sleep(1) # 导出模板并写入内容 500 l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() time.sleep(2) self.driver.find_element(*self.gxzygl).click() time.sleep(2) self.driver.find_element(*self.gddgl).click() l.join_iframe() time.sleep(3) self.driver.find_element(*self.province).click() self.driver.find_element(*self.province_select).click() self.driver.find_element(*self.city).click() self.driver.find_element(*self.city_select).click() self.driver.find_element(*self.county).click() self.driver.find_element(*self.county_select).click() self.driver.find_element(*self.searchBtn).click() time.sleep(1) self.driver.find_element(*self.first_modify).click() self.driver.find_element(*self.pipeline_length).clear() pipeline_num = random.randint(100, 140) self.driver.find_element(*self.pipeline_length).send_keys(pipeline_num) self.driver.find_element(*self.submitBtn).click() time.sleep(1) self.driver.find_element(*self.searchBtn).click() time.sleep(2) first_pipeline_text = self.driver.find_element( *self.first_pipeline_length).text try: assert pipeline_num == int(first_pipeline_text) logging.info('管道段信息管理修改成功') except: logging.info('管道段信息管理修改失败') l.getScreenShot('管道段信息管理修改失败') time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.swglBtn).click() self.driver.find_element(*self.bzjBtn).click() l.join_iframe() time.sleep(1) First_xmmc = self.driver.find_element(*self.first_xmmc).text First_skr = self.driver.find_element(*self.first_skr).text First_oa = self.driver.find_element(*self.first_oa).text time.sleep(1) self.driver.find_element(*self.search_xmmc).send_keys(First_xmmc) self.driver.find_element(*self.search_skr).send_keys(First_skr) self.driver.find_element(*self.search_oa).send_keys(First_oa) self.driver.find_element(*self.searchBtn).click() time.sleep(2) self.driver.find_element(*self.modifyBtn).click() self.driver.find_element(*self.srk_je).clear() self.driver.find_element(*self.srk_je).send_keys(*self.num_je_text) self.driver.find_element(*self.submitBtn).click() time.sleep(2) self.driver.find_element(*self.searchBtn).click() time.sleep(2) Num_je = float(self.num_je_text) Get_je = self.driver.find_element(*self.get_je).text je = re.findall(r'\d+\.?', Get_je) #用正则修改je格式 je_num = je[0] + je[1] + je[2] num_je = float(je_num) time.sleep(1) try: assert num_je == Num_je logging.info('===保证金 金额修改成功===') except: logging.info('===保证金 金额修改失败===') l.getScreenShot('保证金 金额修改失败') self.driver.find_element(*self.resetBtn).click() l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() time.sleep(2) self.driver.find_element(*self.gxzygl).click() time.sleep(2) self.driver.find_element(*self.gddgl).click() l.join_iframe() time.sleep(1) # 获取该模块数据条数 string_num = self.driver.find_element(*self.string).text nums = re.findall('\d+\.?', string_num) num = nums[2] NUM = int(num) logging.info('当前模块共有数据%s行' % NUM) # 导出全部数据 self.driver.find_element(*self.export_all).click() time.sleep(7) workbook = openpyxl.load_workbook(self.slavepath) # 读取excel sheet = workbook['Sheet1'] h = sheet.max_row # 行 logging.info('导出表数据的行数为%s行' % h) time.sleep(2) try: assert NUM == h - 1 logging.info('管道段信息管理导出全部成功') except: logging.info('管道段信息管理导出全部失败') l.getScreenShot('管道段信息管理导出全部失败') os.remove(self.slavepath) # 删除下载的文件 time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() self.driver.find_element(*self.xlglBtn).click() l.join_iframe() time.sleep(2) self.driver.find_element(*self.firstmodifyBtn).click() WebDriverWait(self.driver, 5).until(lambda x: x.find_element(*self.closewindowBtn)) l.join_iframe() self.driver.find_element(*self.standardNum).clear() num = random.randint(1, 7) self.driver.find_element(*self.standardNum).send_keys(num) self.driver.find_element(*self.submitBtn).click() time.sleep(2) alert = self.driver.switch_to_alert().accept() time.sleep(2) self.driver.find_element(*self.cancelBtn).click() l.quit_iframe() time.sleep(2) l.join_iframe() self.driver.find_element(*self.resetBtn).click() time.sleep(3) standard = self.driver.find_element(*self.time).text timeNum = int(standard) try: assert timeNum == num logging.info('线路管理修改达标次数成功') except: logging.info('线路管理修改达标次数失败') l.getScreenShot('线路管理修改达标次数失败') time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.swglBtn).click() self.driver.find_element(*self.bsfBtn).click() l.join_iframe() time.sleep(1) # 获取该模块数据条数 string_num = self.driver.find_element(*self.string).text nums = re.findall('\d+\.?', string_num) num = nums[1] NUM = int(num) logging.info('当前页共有数据%s行' % NUM) # 导出当前数据 self.driver.find_element(*self.export_current).click() time.sleep(3) tableopen = xlrd.open_workbook(self.slavepath) # 读取excel table = tableopen.sheet_by_name('Sheet1') h = table.nrows # 行 logging.info('导出表数据的行数为%s' % h) time.sleep(2) try: assert NUM == h - 1 logging.info('标书费导出当前成功') except: logging.info('标书费导出当前失败') l.getScreenShot('标书费导出当前失败') os.remove(self.slavepath) # 删除下载的文件 l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() time.sleep(2) self.driver.find_element(*self.gzlgl).click() time.sleep(2) self.driver.find_element(*self.xgzl_maintain).click() l.join_iframe() time.sleep(3) self.driver.find_element(*self.first_modify).click() self.driver.find_element(*self.modulus_input).clear() modulus_num = random.randint(5, 20) time.sleep(3) self.driver.find_element(*self.modulus_input).send_keys(modulus_num) time.sleep(1) self.driver.find_element(*self.submitBtn).click() self.driver.find_element(*self.resetBtn).click() time.sleep(1) first_modulus_text = self.driver.find_element(*self.first_modulus).text time.sleep(1) try: assert modulus_num == int(float(first_modulus_text)) logging.info('新工作量数据维护修改成功') except: logging.info('新工作量数据维护修改失败') l.getScreenShot('新工作量数据维护修改失败') time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() time.sleep(2) self.driver.find_element(*self.gxzygl).click() time.sleep(2) self.driver.find_element(*self.zmdgl).click() l.join_iframe() time.sleep(3) bf_add_PageNum = self.driver.find_element(*self.pageNum).text bf_add_nums = re.findall(r'\d+\.?', bf_add_PageNum) bf_add_num = bf_add_nums[2] bf_add_NUM = int(bf_add_num) logging.info('新增前共有数据%s条' % bf_add_NUM) time.sleep(1) # 新增 self.driver.find_element(*self.addBtn).click() time.sleep(1) self.driver.find_element(*self.zm_class).click() self.driver.find_element(*self.zm_class_select).click() self.driver.find_element(*self.property_nature).click() self.driver.find_element(*self.property_nature_select).click() self.driver.find_element(*self.province).click() self.driver.find_element(*self.province_select).click() self.driver.find_element(*self.city).click() self.driver.find_element(*self.city_select).click() self.driver.find_element(*self.county).click() self.driver.find_element(*self.county_select).click() self.driver.find_element(*self.maintain_mode).click() self.driver.find_element(*self.maintain_mode_select).click() self.driver.find_element(*self.start_type).click() self.driver.find_element(*self.start_type_select).click() self.driver.find_element(*self.end_type).click() self.driver.find_element(*self.end_type_select).click() self.driver.find_element(*self.start_name).click() time.sleep(1) self.driver.find_element(*self.start_name_select).click() self.driver.find_element(*self.end_name).click() time.sleep(1) self.driver.find_element(*self.end_name_select).click() self.driver.find_element(*self.share_unit).click() self.driver.find_element(*self.share_unit_select).click() self.driver.find_element(*self.co_unit).click() self.driver.find_element(*self.co_unit_select).click() self.driver.find_element(*self.submitBtn).click() time.sleep(2) self.driver.find_element(*self.resetBtn).click() time.sleep(2) af_add_PageNum = self.driver.find_element(*self.pageNum).text af_add_nums = re.findall(r'\d+\.?', af_add_PageNum) af_add_num = af_add_nums[2] af_add_NUM = int(af_add_num) logging.info('新增后共有数据%s条' % af_add_NUM) time.sleep(1) try: assert bf_add_NUM == af_add_NUM - 1 logging.info('直埋段信息管理新增成功') except: logging.info('直埋段信息管理新增失败') l.getScreenShot('直埋段信息管理新增失败') time.sleep(1) # 删除 self.driver.find_element(*self.dele_firstBtn).click() time.sleep(0.5) self.driver.find_element(*self.dele_certainBtn).click() time.sleep(2) self.driver.find_element(*self.resetBtn).click() time.sleep(5) af_delete_PageNum = self.driver.find_element(*self.pageNum).text af_delete_nums = re.findall(r'\d+\.?', af_delete_PageNum) af_delete_num = af_delete_nums[2] af_delete_NUM = int(af_delete_num) logging.info('删除后共有数据%s条' % af_delete_NUM) time.sleep(1) try: assert af_delete_NUM == af_add_NUM - 1 logging.info('直埋段信息管理删除成功') except: logging.info('直埋段信息管理删除失败') l.getScreenShot('直埋段信息管理删除失败') time.sleep(1) # 批量删除 self.driver.find_element(*self.show_data).click() time.sleep(1) self.driver.find_element(*self.show_data_select).click() time.sleep(3) self.driver.find_element(*self.select_ten).click() self.driver.find_element(*self.batch_dele).click() time.sleep(1) self.driver.find_element(*self.batch_dele_certainBtn).click() time.sleep(3) # 批量删除重复操作才可以真正删除 self.driver.find_element(*self.select_ten).click() self.driver.find_element(*self.batch_dele).click() time.sleep(1) self.driver.find_element(*self.batch_dele_certainBtn).click() time.sleep(3) self.driver.find_element(*self.resetBtn).click() time.sleep(5) af_batchdele = self.driver.find_element(*self.pageNum).text af_batchdele_nums = re.findall(r'\d+\.?', af_batchdele) af_batchdele_num = af_batchdele_nums[2] af_batchdele_NUM = int(af_batchdele_num) logging.info('批量删除后共有数据%s条' % af_batchdele_NUM) time.sleep(1) try: assert af_batchdele_NUM == af_delete_NUM - 1 logging.info('直埋段信息管理批量删除成功') except: logging.info('直埋段信息管理批量删除失败') l.getScreenShot('直埋段信息管理批量删除失败') time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() time.sleep(2) self.driver.find_element(*self.gzlgl).click() time.sleep(2) self.driver.find_element(*self.xgzl_maintain).click() l.join_iframe() time.sleep(3) # 新增 bf_add_PageNum = self.driver.find_element(*self.pageNum).text bf_add_nums = re.findall(r'\d+\.?', bf_add_PageNum) bf_add_num = bf_add_nums[2] bf_add_NUM = int(bf_add_num) logging.info('新增前共有数据%s条' % bf_add_NUM) time.sleep(1) self.driver.find_element(*self.addBtn).click() time.sleep(1) self.driver.find_element(*self.operator).send_keys(*self.operator_text) self.driver.find_element(*self.jsms).send_keys(*self.jsms_text) self.driver.find_element(*self.profession).send_keys(*self.profession_text) self.driver.find_element(*self.workType).send_keys(*self.workType_text) self.driver.find_element(*self.measureUnit).send_keys(*self.measureUnit_text) self.driver.find_element(*self.region).click() self.driver.find_element(*self.region_select).click() self.driver.find_element(*self.modulus).send_keys(*self.modulus_input) self.driver.find_element(*self.submitBtn).click() time.sleep(2) self.driver.find_element(*self.resetBtn).click() time.sleep(1) af_add_PageNum = self.driver.find_element(*self.pageNum).text af_add_nums = re.findall(r'\d+\.?', af_add_PageNum) af_add_num = af_add_nums[2] af_add_NUM = int(af_add_num) logging.info('新增后共有数据%s条' % af_add_NUM) time.sleep(1) try: assert bf_add_NUM == af_add_NUM - 1 logging.info('新工作量数据维护新增成功') except: logging.info('新工作量数据维护新增失败') l.getScreenShot('新工作量数据维护新增失败') time.sleep(1) # 删除 self.driver.find_element(*self.dele_firstBtn).click() time.sleep(1) self.driver.find_element(*self.dele_certainBtn).click() time.sleep(1) self.driver.find_element(*self.resetBtn).click() time.sleep(1) af_delete_PageNum = self.driver.find_element(*self.pageNum).text af_delete_nums = re.findall(r'\d+\.?', af_delete_PageNum) af_delete_num = af_delete_nums[2] af_delete_NUM = int(af_delete_num) logging.info('删除后共有数据%s条' % af_delete_NUM) time.sleep(1) try: assert af_delete_NUM == af_add_NUM - 1 logging.info('新工作量数据维护删除成功') except: logging.info('新工作量数据维护删除失败') l.getScreenShot('新工作量数据维护删除失败') time.sleep(1) # 再次新增 bf_add_PageNum = self.driver.find_element(*self.pageNum).text bf_add_nums = re.findall(r'\d+\.?', bf_add_PageNum) bf_add_num = bf_add_nums[2] bf_add_NUM = int(bf_add_num) logging.info('新增前共有数据%s条' % bf_add_NUM) time.sleep(1) self.driver.find_element(*self.addBtn).click() time.sleep(1) self.driver.find_element(*self.operator).send_keys(*self.operator_text) self.driver.find_element(*self.jsms).send_keys(*self.jsms_text) self.driver.find_element(*self.profession).send_keys(*self.profession_text) self.driver.find_element(*self.workType).send_keys(*self.workType_text) self.driver.find_element(*self.measureUnit).send_keys(*self.measureUnit_text) self.driver.find_element(*self.region).click() self.driver.find_element(*self.region_select).click() self.driver.find_element(*self.modulus).send_keys(*self.modulus_input) self.driver.find_element(*self.submitBtn).click() time.sleep(2) self.driver.find_element(*self.resetBtn).click() time.sleep(1) af_add_PageNum = self.driver.find_element(*self.pageNum).text af_add_nums = re.findall(r'\d+\.?', af_add_PageNum) af_add_num = af_add_nums[2] af_add_NUM = int(af_add_num) logging.info('新增后共有数据%s条' % af_add_NUM) time.sleep(1) try: assert bf_add_NUM == af_add_NUM - 1 logging.info('新工作量数据维护新增成功') except: logging.info('新工作量数据维护新增失败') l.getScreenShot('新工作量数据维护新增失败') time.sleep(1) # 批量删除 self.driver.find_element(*self.first_sele).click() self.driver.find_element(*self.batch_dele).click() time.sleep(1) self.driver.find_element(*self.batch_dele_certainBtn).click() time.sleep(1) self.driver.find_element(*self.resetBtn).click() time.sleep(1) af_delete_PageNum = self.driver.find_element(*self.pageNum).text af_delete_nums = re.findall(r'\d+\.?', af_delete_PageNum) af_delete_num = af_delete_nums[2] af_delete_NUM = int(af_delete_num) logging.info('批量删除后共有数据%s条' % af_delete_NUM) time.sleep(1) try: assert af_delete_NUM == af_add_NUM - 1 logging.info('新工作量数据维护批量删除成功') except: logging.info('新工作量数据维护批量删除失败') l.getScreenShot('新工作量数据维护批量删除失败') time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() time.sleep(2) self.driver.find_element(*self.gxzygl).click() time.sleep(2) self.driver.find_element(*self.zjdxx).click() l.join_iframe() time.sleep(3) # 新增 bf_add_PageNum = self.driver.find_element(*self.pageNum).text bf_add_nums = re.findall(r'\d+\.?', bf_add_PageNum) bf_add_num = bf_add_nums[2] bf_add_NUM = int(bf_add_num) logging.info('新增前共有数据%s条' % bf_add_NUM) time.sleep(1) self.driver.find_element(*self.addBtn).click() time.sleep(1) self.driver.find_element(*self.province).click() self.driver.find_element(*self.province_select).click() self.driver.find_element(*self.city).click() self.driver.find_element(*self.city_select).click() self.driver.find_element(*self.county).click() self.driver.find_element(*self.county_select).click() self.driver.find_element(*self.start_station).send_keys( *self.start_station_name) time.sleep(3) self.driver.find_element(*self.start_station_select).click() time.sleep(2) self.driver.find_element(*self.end_station).send_keys( *self.end_station_name) time.sleep(3) self.driver.find_element(*self.end_station_select).click() self.driver.find_element(*self.cable_num).send_keys( *self.cable_num_text) self.driver.find_element(*self.cable_class).click() self.driver.find_element(*self.cable_class_select).click() self.driver.find_element(*self.cable_signage).send_keys( *self.cable_signage_input) self.driver.find_element(*self.start_ODF).send_keys( *self.start_ODF_input) self.driver.find_element(*self.end_ODF).send_keys(*self.end_ODF_input) time.sleep(1) zjd_length_input = random.randint(100, 200) self.driver.find_element(*self.zjd_length).send_keys(zjd_length_input) self.driver.find_element(*self.file_select).send_keys(*self.slavepath) time.sleep(1) self.driver.find_element(*self.submitBtn).click() time.sleep(2) self.driver.find_element(*self.resetBtn).click() time.sleep(2) af_add_PageNum = self.driver.find_element(*self.pageNum).text af_add_nums = re.findall(r'\d+\.?', af_add_PageNum) af_add_num = af_add_nums[2] af_add_NUM = int(af_add_num) logging.info('新增后共有数据%s条' % af_add_NUM) time.sleep(1) try: assert bf_add_NUM == af_add_NUM - 1 logging.info('中继段信息新增成功') except: logging.info('中继段信息新增失败') l.getScreenShot('中继段信息新增失败') time.sleep(1) # 删除 self.driver.find_element(*self.dele_firstBtn).click() time.sleep(0.5) self.driver.find_element(*self.dele_certainBtn).click() time.sleep(2) self.driver.find_element(*self.resetBtn).click() time.sleep(2) af_delete_PageNum = self.driver.find_element(*self.pageNum).text af_delete_nums = re.findall(r'\d+\.?', af_delete_PageNum) af_delete_num = af_delete_nums[2] af_delete_NUM = int(af_delete_num) logging.info('删除后共有数据%s条' % af_delete_NUM) time.sleep(1) try: assert af_delete_NUM == af_add_NUM - 1 logging.info('中继段信息删除成功') except: logging.info('中继段信息删除失败') l.getScreenShot('中继段信息删除失败') time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() WebDriverWait(self.driver, 3).until(lambda x: x.find_element(*self.tsxlBtn)) self.driver.find_element(*self.tsxlBtn).click() l.join_iframe() # 搜索 line_text = self.driver.find_element(*self.line_name).text # 第一条线路名称 tsdms_text = self.driver.find_element(*self.tsdms).text # 第一条特殊点描述 tsdmc_text = self.driver.find_element(*self.tsdmc).text # 第一条特殊点名称 self.driver.find_element(*self.exact_search).click() self.driver.find_element(*self.line_input).send_keys(line_text) self.driver.find_element(*self.tsdms_input).send_keys(tsdms_text) self.driver.find_element(*self.tsdmc_input).send_keys(tsdmc_text) self.driver.find_element(*self.searchBtn).click() time.sleep(1) af_line_text = self.driver.find_element( *self.line_name).text # 搜索后第一条线路名称 try: assert line_text == af_line_text logging.info('特殊线路管理搜索成功') except: logging.info('特殊线路管理搜索失败') l.getScreenShot('特殊线路管理搜索失败') self.driver.find_element(*self.resetBtn).click() time.sleep(2) # 删除 be_PageNum = self.driver.find_element(*self.pageNum).text be_nums = re.findall(r'\d+\.?', be_PageNum) be_num = be_nums[2] be_NUM = int(be_num) logging.info('删除前共有数据%s条' % be_NUM) time.sleep(1) self.driver.find_element(*self.dele_firstBtn).click() time.sleep(1) alert = self.driver.switch_to_alert().accept() time.sleep(1) alert = self.driver.switch_to_alert().accept() time.sleep(1) self.driver.find_element(*self.resetBtn).click() time.sleep(1) af_PageNum = self.driver.find_element(*self.pageNum).text af_nums = re.findall(r'\d+\.?', af_PageNum) af_num = af_nums[2] af_NUM = int(af_num) logging.info('删除后共有数据%s条' % af_NUM) time.sleep(1) try: assert af_NUM == be_NUM - 1 logging.info('特殊线路管理删除成功') except: logging.info('特殊线路管理删除失败') l.getScreenShot('特殊线路管理删除失败') time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() time.sleep(2) self.driver.find_element(*self.gxzygl).click() time.sleep(2) self.driver.find_element(*self.dglr).click() l.join_iframe() time.sleep(3) # 新增 self.driver.find_element(*self.addBtn).click() time.sleep(1) self.driver.find_element(*self.pole_name_input).send_keys( *self.pole_name_text) self.driver.find_element(*self.pull_line_input).send_keys( *self.pull_line_num) self.driver.find_element(*self.pole_type).click() self.driver.find_element(*self.pole_type_select).click() self.driver.find_element(*self.pole_material).click() self.driver.find_element(*self.pole_material_select).click() self.driver.find_element(*self.province).click() self.driver.find_element(*self.province_select).click() self.driver.find_element(*self.city).click() self.driver.find_element(*self.city_select).click() self.driver.find_element(*self.pole_height).send_keys( *self.pole_height_num) self.driver.find_element(*self.property_unit).click() self.driver.find_element(*self.property_select).click() self.driver.find_element(*self.province_nature).click() self.driver.find_element(*self.nature_select).click() self.driver.find_element(*self.longitude_input).send_keys( *self.longitude_text) self.driver.find_element(*self.latitude_input).send_keys( *self.latitude_text) self.driver.find_element(*self.uphold_method).click() self.driver.find_element(*self.uphold_select).click() self.driver.find_element(*self.select_file).click() time.sleep(2) l.win32_pick_slave(self.slavepath) self.driver.find_element(*self.submitBtn).click() time.sleep(3) self.driver.find_element(*self.resetBtn).click() time.sleep(2) first_pole_text = self.driver.find_element(*self.first_pole_name).text try: assert self.pole_name_text == first_pole_text logging.info('电杆录入新增成功') except: logging.info('电杆录入新增失败') l.getScreenShot('电杆录入新增失败') # 删除 be_PageNum = self.driver.find_element(*self.pageNum).text be_nums = re.findall(r'\d+\.?', be_PageNum) be_num = be_nums[2] be_NUM = int(be_num) logging.info('删除前共有数据%s条' % be_NUM) time.sleep(1) self.driver.find_element(*self.dele_firstBtn).click() self.driver.find_element(*self.dele_certainBtn).click() self.driver.find_element(*self.resetBtn).click() time.sleep(1) af_PageNum = self.driver.find_element(*self.pageNum).text af_nums = re.findall(r'\d+\.?', af_PageNum) af_num = af_nums[2] af_NUM = int(af_num) logging.info('删除后共有数据%s条' % af_NUM) time.sleep(1) try: assert af_NUM == be_NUM - 1 logging.info('电杆录入删除成功') except: logging.info('电杆录入删除失败') l.getScreenShot('电杆录入删除失败') self.driver.find_element(*self.resetBtn).click() time.sleep(1) # 批量删除 be_PageNum = self.driver.find_element(*self.pageNum).text be_nums = re.findall(r'\d+\.?', be_PageNum) be_num = be_nums[2] be_NUM = int(be_num) logging.info('批量删除前共有数据%s条' % be_NUM) time.sleep(1) self.driver.find_element(*self.first_sele).click() self.driver.find_element(*self.batch_dele).click() self.driver.find_element(*self.batch_dele_certainBtn).click() time.sleep(1) self.driver.find_element(*self.resetBtn).click() time.sleep(1) af_PageNum = self.driver.find_element(*self.pageNum).text af_nums = re.findall(r'\d+\.?', af_PageNum) af_num = af_nums[2] af_NUM = int(af_num) logging.info('批量删除后共有数据%s条' % af_NUM) time.sleep(1) try: assert af_NUM == be_NUM - 1 logging.info('电杆录入批量删除成功') except: logging.info('电杆录入批量删除失败') l.getScreenShot('电杆录入批量删除失败') time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() time.sleep(2) self.driver.find_element(*self.gxzygl).click() time.sleep(2) self.driver.find_element(*self.gqgl).click() l.join_iframe() time.sleep(3) # 新增 self.driver.find_element(*self.addBtn).click() time.sleep(1) self.driver.find_element(*self.gq_name).send_keys(*self.gq_name_text) self.driver.find_element(*self.province).click() self.driver.find_element(*self.province_select).click() self.driver.find_element(*self.city).click() self.driver.find_element(*self.city_select).click() self.driver.find_element(*self.county).click() self.driver.find_element(*self.county_select).click() self.driver.find_element(*self.place_describe).send_keys( *self.place_text) self.driver.find_element(*self.gq_type).click() self.driver.find_element(*self.gq_type_select).click() self.driver.find_element(*self.longitude).send_keys( *self.longitude_num) self.driver.find_element(*self.latitude).send_keys(*self.latitude_num) self.driver.find_element(*self.height).send_keys(*self.height_num) self.driver.find_element(*self.pick_slave).send_keys(*self.slavepath) self.driver.find_element(*self.submitBtn).click() time.sleep(1) self.driver.find_element(*self.resetBtn).click() time.sleep(1) be_PageNum = self.driver.find_element(*self.pageNum).text be_nums = re.findall(r'\d+\.?', be_PageNum) be_num = be_nums[2] be_NUM = int(be_num) logging.info('删除前共有数据%s条' % be_NUM) time.sleep(1) self.driver.find_element(*self.gq_name_input).send_keys( *self.gq_name_text) self.driver.find_element(*self.searchBtn).click() time.sleep(1) first_gq_text = self.driver.find_element(*self.first_gq_name).text try: assert self.gq_name_text == first_gq_text logging.info('挂墙管理新增成功') except: logging.info('挂墙管理新增失败') l.getScreenShot('挂墙管理新增失败') self.driver.find_element(*self.resetBtn).click() time.sleep(1) # 删除 self.driver.find_element(*self.dele_firstBtn).click() self.driver.find_element(*self.dele_certainBtn).click() time.sleep(1) self.driver.find_element(*self.resetBtn).click() time.sleep(1) af_PageNum = self.driver.find_element(*self.pageNum).text af_nums = re.findall(r'\d+\.?', af_PageNum) af_num = af_nums[2] af_NUM = int(af_num) logging.info('删除后共有数据%s条' % af_NUM) time.sleep(1) try: assert af_NUM == be_NUM - 1 logging.info('挂墙管理删除成功') except: logging.info('挂墙管理删除失败') l.getScreenShot('挂墙管理删除失败') time.sleep(1) self.driver.find_element(*self.resetBtn).click() time.sleep(1) # 批量删除 be_PageNum = self.driver.find_element(*self.pageNum).text be_nums = re.findall(r'\d+\.?', be_PageNum) be_num = be_nums[2] be_NUM = int(be_num) logging.info('批量删除前共有数据%s条' % be_NUM) time.sleep(1) self.driver.find_element(*self.first_sele).click() self.driver.find_element(*self.batch_dele).click() self.driver.find_element(*self.batch_dele_certainBtn).click() time.sleep(1) self.driver.find_element(*self.resetBtn).click() time.sleep(1) af_PageNum = self.driver.find_element(*self.pageNum).text af_nums = re.findall(r'\d+\.?', af_PageNum) af_num = af_nums[2] af_NUM = int(af_num) logging.info('批量删除后共有数据%s条' % af_NUM) time.sleep(1) try: assert af_NUM == be_NUM - 1 logging.info('挂墙管理批量删除成功') except: logging.info('挂墙管理批量删除失败') l.getScreenShot('挂墙管理批量删除失败') time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() self.driver.find_element(*self.xlglBtn).click() l.join_iframe() time.sleep(2) # 第一条的查看按钮 self.driver.find_element(*self.first_viewBtn).click() time.sleep(1) # 判断alert弹出框 result = EC.alert_is_present()(self.driver) if result: alert = self.driver.switch_to_alert().accept() time.sleep(1) self.driver.find_element(*self.close_viewBtn).click() logging.info('关闭alert弹窗后关闭查看弹框') else: self.driver.find_element(*self.close_viewBtn).click() logging.info('该条数据没有alert弹窗,关闭查看弹框') time.sleep(2) # 第一条的轨迹回放按钮 self.driver.find_element(*self.first_playbackBtn).click() time.sleep(1) # 判断alert弹出框 result = EC.alert_is_present()(self.driver) if result: alert = self.driver.switch_to_alert().accept() time.sleep(1) self.driver.find_element(*self.close_viewBtn).click() logging.info('关闭alert弹窗后关闭轨迹回放弹框') else: l.join_iframe() logging.info('该条数据没有alert弹窗,进行轨迹回放') self.driver.find_element(*self.play_startBtn).click() time.sleep(10) self.driver.find_element(*self.play_pauseBtn).click() self.driver.find_element(*self.play_endBtn).click() l.quit_iframe() time.sleep(1) l.join_iframe() self.driver.find_element(*self.close_viewBtn).click() logging.info('关闭轨迹回放弹框') # 删除前数据条数 be_PageNum = self.driver.find_element(*self.pageNum).text be_nums = re.findall(r'\d+\.?', be_PageNum) be_num = be_nums[2] be_NUM = int(be_num) logging.info('删除前共有数据%s条' % be_NUM) time.sleep(1) # 第一条的删除按钮 self.driver.find_element(*self.first_deleteBtn).click() time.sleep(1) alert = self.driver.switch_to_alert().accept() time.sleep(1) alert = self.driver.switch_to_alert().accept() time.sleep(1) self.driver.find_element(*self.resetBtn).click() time.sleep(1) # 删除后数据条数 af_PageNum = self.driver.find_element(*self.pageNum).text af_nums = re.findall(r'\d+\.?', af_PageNum) af_num = af_nums[2] af_NUM = int(af_num) logging.info('删除后共有数据%s条' % af_NUM) time.sleep(1) try: assert af_NUM == be_NUM - 1 logging.info('===线路管理删除成功===') except: logging.info('===线路管理删除失败===') l.getScreenShot('线路管理删除失败') time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.swglBtn).click() self.driver.find_element(*self.bzjBtn).click() l.join_iframe() time.sleep(1) # 获取该模块数据条数 be_string_num = self.driver.find_element(*self.string).text be_nums = re.findall('\d+\.?', be_string_num) be_num = be_nums[2] be_NUM = int(be_num) logging.info('导入前当前页共有数据%s条' % be_NUM) # 导出模板并写入内容 self.driver.find_element(*self.importBtn).click() WebDriverWait(self.driver, 5).until(lambda x: x.find_element(*self.download)) self.driver.find_element(*self.download).click() time.sleep(2) workbook = openpyxl.load_workbook(self.slavepath) # 读取excel sheet = workbook['Sheet1'] # 写入实际内容(第二行) logging.info("系统即将执行Excel写入...") sheet['A2'] = self.text_smmc sheet['B2'] = self.text_skr sheet['C2'] = '111.11' sheet['D2'] = '2018-11-19' sheet['E2'] = '2018-11-20' sheet['F2'] = '100.00' sheet['G2'] = '13655554444' sheet['H2'] = '1' sheet['I2'] = self.text_OA sheet['J2'] = '1' sheet['K2'] = '111' workbook.save(self.slavepath) # 保存 logging.info("写入完成,即将上传") self.driver.find_element(*self.file_select).click() time.sleep(2) l.win32_pick_slave(self.slavepath) time.sleep(2) WebDriverWait(self.driver, 5).until(lambda x: x.find_element(*self.submitBtn)) self.driver.find_element(*self.submitBtn).click() time.sleep(2) self.driver.find_element(*self.close_alert).click() self.driver.find_element(*self.resetBtn).click() time.sleep(2) # 获取导入一条数据后该模块数据条数 af_string_num = self.driver.find_element(*self.string).text af_nums = re.findall('\d+\.?', af_string_num) af_num = af_nums[2] af_NUM = int(af_num) logging.info('导入后当前页共有数据%s条' % af_NUM) time.sleep(1) try: assert af_NUM == be_NUM + 1 logging.info('===保证金导入成功===') except: logging.info('===保证金导入失败===') l.getScreenShot('保证金导入失败') time.sleep(1) #删除该导入数据 self.driver.find_element(*self.smmc).send_keys(self.text_smmc) self.driver.find_element(*self.skr).send_keys(self.text_skr) self.driver.find_element(*self.OA).send_keys(self.text_OA) self.driver.find_element(*self.searchBtn).click() time.sleep(2) self.driver.find_element(*self.deleteBtn).click() self.driver.find_element(*self.certain).click() time.sleep(2) self.driver.find_element(*self.resetBtn).click() time.sleep(1) string_num = self.driver.find_element(*self.string).text nums = re.findall('\d+\.?', string_num) num = nums[2] NUM = int(num) logging.info('删除后当前页共有数据%s条' % NUM) time.sleep(1) try: assert NUM == be_NUM logging.info('===导入数据删除成功===') except: logging.info('===导入数据删除失败===') l.getScreenShot('导入数据删除失败') time.sleep(1) os.remove(self.slavepath) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() time.sleep(2) self.driver.find_element(*self.gzlgl).click() time.sleep(2) self.driver.find_element(*self.xgzl_maintain).click() l.join_iframe() time.sleep(3) # 获取该模块数据条数 be_string_num = self.driver.find_element(*self.string).text be_nums = re.findall('\d+\.?', be_string_num) be_num = be_nums[2] be_NUM = int(be_num) logging.info('导入前当前页共有数据%s条' % be_NUM) # 导出模板并写入内容 self.driver.find_element(*self.importBtn).click() WebDriverWait(self.driver, 5).until(lambda x: x.find_element(*self.download)) self.driver.find_element(*self.download).click() time.sleep(2) workbook = openpyxl.load_workbook(self.slavepath) # 读取excel sheet = workbook['Sheet1'] # 写入实际内容(第二行) logging.info("系统即将执行Excel写入...") sheet['A2'] = sheet['A3'] = sheet['A4'] = self.A sheet['B2'] = sheet['C2'] = sheet['D2'] = sheet['E2'] = sheet[ 'F2'] = self.row2 sheet['B3'] = sheet['C3'] = sheet['D3'] = sheet['E3'] = sheet[ 'F3'] = self.row3 sheet['B4'] = sheet['C4'] = sheet['D4'] = sheet['E4'] = sheet[ 'F4'] = self.row4 sheet['H2'] = sheet['H3'] = sheet['H4'] = self.cell_H workbook.save(self.slavepath) # 保存 logging.info("写入完成,即将上传") self.driver.find_element(*self.file_select).click() time.sleep(2) l.win32_pick_slave(self.slavepath) time.sleep(2) WebDriverWait(self.driver, 5).until(lambda x: x.find_element(*self.submitBtn)) self.driver.find_element(*self.submitBtn).click() time.sleep(2) self.driver.find_element(*self.close_alert).click() self.driver.find_element(*self.resetBtn).click() time.sleep(2) # 获取导入3条数据后该模块数据条数 af_string_num = self.driver.find_element(*self.string).text af_nums = re.findall('\d+\.?', af_string_num) af_num = af_nums[2] af_NUM = int(af_num) logging.info('导入后当前页共有数据%s条' % af_NUM) time.sleep(1) try: assert af_NUM == be_NUM + 3 logging.info('新工作量数据维护批量导入成功') except: logging.info('新工作量数据维护批量导入失败') l.getScreenShot('新工作量数据维护批量导入失败') time.sleep(1) #判断批量导入的数据内容 self.driver.find_element(*self.region_search).click() self.driver.find_element(*self.region_search_select).click() self.driver.find_element(*self.searchBtn).click() time.sleep(1) first_operator_text = self.driver.find_element( *self.first_operator).text second_operator_text = self.driver.find_element( *self.second_operator).text third_operator_text = self.driver.find_element( *self.third_operator).text time.sleep(1) try: assert first_operator_text == self.row2 and second_operator_text == self.row3 \ and third_operator_text == self.row4 logging.info('新工作量数据维护批量导入成功') except: logging.info('新工作量数据维护批量导入失败') l.getScreenShot('新工作量数据维护批量导入失败') time.sleep(1) #批量删除导入的数据 self.driver.find_element(*self.first_select).click() self.driver.find_element(*self.second_select).click() self.driver.find_element(*self.third_select).click() self.driver.find_element(*self.batch_dele).click() self.driver.find_element(*self.batch_dele_certainBtn).click() time.sleep(1) self.driver.find_element(*self.resetBtn).click() time.sleep(1) string_num = self.driver.find_element(*self.string).text nums = re.findall('\d+\.?', string_num) num = nums[2] NUM = int(num) logging.info('删除后当前页共有数据%s条' % NUM) time.sleep(1) try: assert NUM == be_NUM logging.info('===导入数据删除成功===') except: logging.info('===导入数据删除失败===') l.getScreenShot('导入数据删除失败') time.sleep(1) os.remove(self.slavepath) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) # 新增 self.driver.find_element(*self.swglBtn).click() self.driver.find_element(*self.bzjBtn).click() l.join_iframe() time.sleep(1) self.driver.find_element(*self.addBtn).click() time.sleep(1) self.driver.find_element(*self.xmname).send_keys(*self.text_xmmc) self.driver.find_element(*self.skr).send_keys(*self.text_skr) self.driver.find_element(*self.yfje).send_keys(*self.text_yfje) self.driver.find_element(*self.kbsj).click() self.driver.find_element(*self.kbsj_today).click() self.driver.find_element(*self.fhsj).click() self.driver.find_element(*self.fhsj_today).click() self.driver.find_element(*self.fhje).send_keys(*self.text_fhje) self.driver.find_element(*self.phone).send_keys(*self.text_ph) self.driver.find_element(*self.OANUM).send_keys(*self.text_OA) self.driver.find_element(*self.tper).send_keys(*self.text_tper) self.driver.find_element(*self.add_sub).click() time.sleep(2) First_xmmc = self.driver.find_element(*self.first_xmmc).text try: assert self.text_xmmc == First_xmmc logging.info('===保证金新增成功===') except: logging.info('===保证金新增失败===') l.getScreenShot('保证金新增失败') # 搜索 self.driver.find_element(*self.search_xmmc).send_keys(*self.text_xmmc) self.driver.find_element(*self.searchBtn).click() time.sleep(2) try: assert self.text_xmmc == First_xmmc logging.info('===保证金搜索成功===') except: logging.info('===保证金搜索失败===') l.getScreenShot('保证金搜索失败') # 删除 self.driver.find_element(*self.dele_firstBtn).click() self.driver.find_element(*self.dele_certainBtn).click() self.driver.find_element(*self.resetBtn).click() time.sleep(2) First_xmmc_1 = self.driver.find_element(*self.first_xmmc).text time.sleep(1) try: assert self.text_xmmc == First_xmmc_1 logging.info('===保证金删除失败===') l.getScreenShot('保证金删除失败') except: logging.info('===保证金删除成功===') # 批量删除 be_PageNum = self.driver.find_element(*self.pageNum).text be_nums = re.findall(r'\d+\.?', be_PageNum) be_num = be_nums[2] be_NUM = int(be_num) logging.info('批量删除前共有数据%s条' % be_NUM) time.sleep(1) self.driver.find_element(*self.first_sele).click() self.driver.find_element(*self.batch_dele).click() self.driver.find_element(*self.batch_dele_certainBtn).click() time.sleep(1) af_PageNum = self.driver.find_element(*self.pageNum).text af_nums = re.findall(r'\d+\.?', af_PageNum) af_num = af_nums[2] af_NUM = int(af_num) logging.info('批量删除后共有数据%s条' % af_NUM) time.sleep(1) try: assert af_NUM == be_NUM - 1 logging.info('===保证金批量删除成功===') except: logging.info('===保证金批量删除失败===') l.getScreenShot('保证金批量删除失败') self.driver.find_element(*self.resetBtn).click() time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() time.sleep(2) self.driver.find_element(*self.gxzygl).click() time.sleep(2) self.driver.find_element(*self.gddgl).click() l.join_iframe() time.sleep(3) # 获取该模块数据条数 be_string_num = self.driver.find_element(*self.string).text be_nums = re.findall('\d+\.?', be_string_num) be_num = be_nums[2] be_NUM = int(be_num) logging.info('导入前当前页共有数据%s条' % be_NUM) # 导出模板并写入内容 self.driver.find_element(*self.importBtn).click() WebDriverWait(self.driver, 5).until(lambda x: x.find_element(*self.download)) self.driver.find_element(*self.download).click() time.sleep(2) workbook = openpyxl.load_workbook(self.slavepath) # 读取excel sheet = workbook['Sheet1'] # 写入实际内容(第二行) logging.info("系统即将执行Excel写入...") sheet['D2'] = self.excel_start_name sheet['F2'] = self.excel_end_name sheet['Q2'] = self.excel_province sheet['R2'] = self.excel_city sheet['S2'] = self.excel_county workbook.save(self.slavepath) # 保存 logging.info("写入完成,即将上传") self.driver.find_element(*self.file_select).click() time.sleep(2) l.win32_pick_slave(self.slavepath) time.sleep(2) WebDriverWait(self.driver, 5).until(lambda x: x.find_element(*self.submitBtn)) self.driver.find_element(*self.submitBtn).click() time.sleep(2) self.driver.find_element(*self.close_alert).click() self.driver.find_element(*self.resetBtn).click() time.sleep(2) # 获取导入一条数据后该模块数据条数 af_string_num = self.driver.find_element(*self.string).text af_nums = re.findall('\d+\.?', af_string_num) af_num = af_nums[2] af_NUM = int(af_num) logging.info('导入后当前页共有数据%s条' % af_NUM) time.sleep(1) try: assert af_NUM == be_NUM + 1 logging.info('管道段信息管理导入成功') except: logging.info('管道段信息管理导入失败') l.getScreenShot('管道段信息管理导入失败') time.sleep(1) # 删除该导入数据 self.driver.find_element(*self.deleteBtn).click() self.driver.find_element(*self.certain).click() time.sleep(2) self.driver.find_element(*self.resetBtn).click() time.sleep(1) string_num = self.driver.find_element(*self.string).text nums = re.findall('\d+\.?', string_num) num = nums[2] NUM = int(num) logging.info('删除后当前页共有数据%s条' % NUM) time.sleep(1) try: assert NUM == be_NUM logging.info('导入的数据删除成功') except: logging.info('导入的数据删除失败') l.getScreenShot('导入的数据删除失败') time.sleep(1) os.remove(self.slavepath) time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()
def test_login_zhaobingcheng(self): logging.info('=========test_login_zhaobingcheng============') l = LoginView(self.driver) data = l.get_csv_data(self.csv_file, 1) l.login_action(data[0], data[1]) time.sleep(2) self.driver.find_element(*self.ywglBtn).click() time.sleep(2) self.driver.find_element(*self.gxzygl).click() time.sleep(2) self.driver.find_element(*self.rsjlr).click() l.join_iframe() time.sleep(3) # 新增 self.driver.find_element(*self.addBtn).click() time.sleep(1) self.driver.find_element(*self.rsj_name_input).send_keys(self.rsj_name_text) self.driver.find_element(*self.rsj_material).click() self.driver.find_element(*self.rsj_material_select).click() self.driver.find_element(*self.rsj_type).click() self.driver.find_element(*self.rsj_type_select).click() self.driver.find_element(*self.rsj_model).click() self.driver.find_element(*self.rsj_model_select).click() self.driver.find_element(*self.province).click() self.driver.find_element(*self.province_select).click() self.driver.find_element(*self.city).click() self.driver.find_element(*self.city_select).click() self.driver.find_element(*self.county).click() self.driver.find_element(*self.county_select).click() self.driver.find_element(*self.holes).send_keys(*self.holes_num) self.driver.find_element(*self.longitude).send_keys(*self.longitude_num) self.driver.find_element(*self.latitude).send_keys(*self.latitude_num) self.driver.find_element(*self.manhole_shape).send_keys(*self.manhole_shape_text) self.driver.find_element(*self.manhole_size).send_keys(*self.manhole_size_text) self.driver.find_element(*self.manhole_material).click() self.driver.find_element(*self.manhole_material_select).click() self.driver.find_element(*self.dx_length).send_keys(*self.dx_length_text) self.driver.find_element(*self.nb_length).send_keys(*self.nb_length_text) self.driver.find_element(*self.well_deep).send_keys(*self.well_deep_text) self.driver.find_element(*self.well_high).send_keys(*self.well_high_text) self.driver.find_element(*self.property_unit).click() self.driver.find_element(*self.property_unit_select).click() self.driver.find_element(*self.property_nature).click() self.driver.find_element(*self.property_nature_select).click() self.driver.find_element(*self.rode_name).send_keys(*self.rode_name_text) self.driver.find_element(*self.maintain).click() self.driver.find_element(*self.maintain_select).click() self.driver.find_element(*self.lbj).send_keys(*self.lbj_text) self.driver.find_element(*self.lzj).send_keys(*self.lzj_text) self.driver.find_element(*self.manhole).click() self.driver.find_element(*self.manhole_select).click() self.driver.find_element(*self.worn).click() self.driver.find_element(*self.worn_select).click() self.driver.find_element(*self.manhole_num).send_keys(*self.manhole_num_text) self.driver.find_element(*self.bottom_width).send_keys(*self.bottom_width_text) self.driver.find_element(*self.level_high).send_keys(*self.level_high_text) self.driver.find_element(*self.pick_slave).send_keys(*self.slavepath) self.driver.find_element(*self.submitBtn).click() time.sleep(2) self.driver.find_element(*self.resetBtn).click() time.sleep(1) be_PageNum = self.driver.find_element(*self.pageNum).text be_nums = re.findall(r'\d+\.?', be_PageNum) be_num = be_nums[2] be_NUM = int(be_num) logging.info('删除前共有数据%s条' % be_NUM) time.sleep(1) self.driver.find_element(*self.well_name_input).send_keys(*self.rsj_name_text) self.driver.find_element(*self.searchBtn).click() time.sleep(2) well_name_search = self.driver.find_element(*self.first_well_name).text try: assert self.rsj_name_text == well_name_search logging.info('人手井录入新增成功') except: logging.info('人手井录入新增失败') l.getScreenShot('人手井录入新增失败') # 删除 self.driver.find_element(*self.dele_firstBtn).click() self.driver.find_element(*self.dele_certainBtn).click() time.sleep(1) self.driver.find_element(*self.resetBtn).click() time.sleep(1) af_PageNum = self.driver.find_element(*self.pageNum).text af_nums = re.findall(r'\d+\.?', af_PageNum) af_num = af_nums[2] af_NUM = int(af_num) logging.info('删除后共有数据%s条' % af_NUM) time.sleep(1) try: assert af_NUM == be_NUM - 1 logging.info('人手井录入删除成功') except: logging.info('人手井录入删除失败') l.getScreenShot('人手井录入删除失败') time.sleep(1) self.driver.find_element(*self.resetBtn).click() time.sleep(1) # 批量删除 be_PageNum = self.driver.find_element(*self.pageNum).text be_nums = re.findall(r'\d+\.?', be_PageNum) be_num = be_nums[2] be_NUM = int(be_num) logging.info('批量删除前共有数据%s条' % be_NUM) time.sleep(1) self.driver.find_element(*self.first_sele).click() self.driver.find_element(*self.batch_dele).click() self.driver.find_element(*self.batch_dele_certainBtn).click() time.sleep(1) self.driver.find_element(*self.resetBtn).click() time.sleep(1) af_PageNum = self.driver.find_element(*self.pageNum).text af_nums = re.findall(r'\d+\.?', af_PageNum) af_num = af_nums[2] af_NUM = int(af_num) logging.info('批量删除后共有数据%s条' % af_NUM) time.sleep(1) try: assert af_NUM == be_NUM - 1 logging.info('人手井录入批量删除成功') except: logging.info('人手井录入批量删除失败') l.getScreenShot('人手井录入批量删除失败') time.sleep(1) l.quit_iframe() k = QuitView(self.driver) k.quit_action()