def change_time_of_attendance(driver, remark, file_path, people_number): """ 1 代表单人, 2代表多人 """ try: into_one_level(driver, '任务面板') sleep(1) into_one_level(driver, '发起申请') get_element(driver, ('xpath', "//div[contains(text(),'考勤异常修改')]")).click() get_elements( driver, ('xpath', "//i[@class='glyphicon glyphicon-plus']"))[0].click() sleep(0.5) if people_number == 1: get_element(driver, ('id', "realname")).send_keys('曹永') get_element(driver, ('id', "realsearch")).click() get_elements( driver, ('xpath', "//input[@name='btSelectItem']"))[0].click() get_element(driver, ('xpath', "//a[contains(text(),'确定')]")).click() sleep(0.5) get_element(driver, ('xpath', "//div[@id='uploadFile']/input")).send_keys(file_path) element = "//input[@name='btSelectItem']" if people_number == 2: for i in range(0, len(get_elements(driver, ('xpath', element))), 2): elements = "//input[@name='btSelectItem']" get_elements(driver, ('xpath', elements))[i].click() sleep(0.1) get_element(driver, ('xpath', "//a[contains(text(),'确定')]")).click() setting_input_time(driver) get_element( driver, ('xpath', "//textarea[@class='form-control']")).send_keys(remark) get_elements(driver, ( 'xpath', "//input[@class='form-control input-sm form-date']"))[0].send_keys( get_pass_dates(1)) get_elements( driver, ('xpath', "//input[@class='form-control input-sm form-date-time2']" ))[0].send_keys('08:00') get_elements( driver, ('xpath', "//input[@class='form-control input-sm form-date-time2']" ))[1].send_keys('17:00') get_element(driver, ('xpath', "//button[contains(text(),'提交申请')]")).click() get_element(driver, ('id', "success")).click() sleep(0.5) # 工人个数 worker_number = 5 # 修改1天前的考勤异常 day_num = 1 while True: if is_element_present_3s( driver, ('xpath', "//div[contains(text(),'当前人员暂无考勤记录')]"), 2): print('考勤未生成昨天的数据,请查看定时任务是否开启') workers = random.sample(range(1, 15), worker_number) # 选择工人按钮 get_element( driver, ('xpath', "//button[@id='attendanceUpdateData']")).click() # 清空选择 get_element( driver, ('xpath', "//button[contains(text(),'清空选择')]")).click() if is_element_present_3s( driver, ('xpath', "//a[contains(text(),'›')]"), 1): # 滑动到最下面 get_elements( driver, ('xpath', "//a[contains(text(),'›')]"))[0].send_keys( Keys.DOWN) sleep(0.5) get_elements( driver, ('xpath', "//a[contains(text(),'›')]"))[0].click() for i in range(worker_number): get_elements(driver, ('xpath', element))[workers[i]].click() get_element(driver, ('xpath', "//a[contains(text(),'确定')]")).click() get_elements( driver, ('xpath', "//input[@class='form-control input-sm form-date']" ))[0].clear() get_elements( driver, ('xpath', "//input[@class='form-control input-sm form-date']" ))[0].send_keys(get_pass_dates(day_num)) day_num += 1 get_element( driver, ('xpath', "//button[contains(text(),'提交申请')]")).click() get_element(driver, ('id', "success")).click() sleep(0.5) else: break into_one_level(driver, '我的任务') get_element(driver, ('xpath', "//a[contains(text(),'我发起的')]")).click() sleep(1) get_element( driver, ('xpath', "//button[contains(text(),'修正工人考勤异常')]")).click() get_element( driver, ('xpath', "//*[@id='task-mytask-table']/tbody/tr[1]/td[8]/a")).click() assert_element = "//div[@class='tsk-inp col-xs-8' and contains(text(),'%s')]" % remark assert is_element_present(driver, ('xpath', assert_element)) except Exception as e: print(e) bug_photo(driver) assert False
def general_contract(driver, contract_name, contract_awarding, contracting, project_name): """ :param driver: :param contract_name:合同名称 :param contract_awarding: 发包方 :param contracting: 总承包方 :param project_name: 工程名称 :return: """ driver.implicitly_wait(5) try: into_one_level(driver, '任务面板') sleep(0.5) into_two_level(driver, '发起申请') # WebDriverWait(driver, 10).until(lambda x: x.find_element_by_xpath("//div[contains(text(),'新建总包合同')")).click() driver.find_element_by_xpath( "//div[contains(text(),'新建总包合同')]").click() # get_element(driver, ('XPATH', "//div[contains(text(),'新建总包合同'")).click() sleep(0.5) driver.find_element_by_xpath( "//input[@placeholder='请输入合同名称']").send_keys(contract_name) sleep(0.5) # 发包方 get_element(driver, ('id', 'select2-fbfName-container')).click() get_element( driver, ('xpath', "//input[@type='search']")).send_keys(contract_awarding) sleep(0.5) get_element(driver, ('xpath', "//input[@type='search']")).send_keys(Keys.ENTER) # 承包方 get_element(driver, ('id', "select2-cbfName-container")).click() driver.find_element_by_xpath("//input[@type='search']").send_keys( contracting) sleep(0.5) driver.find_element_by_xpath("//input[@type='search']").send_keys( Keys.ENTER) driver.find_element_by_xpath( "//input[@placeholder='请输入工程名称']").send_keys(project_name) select_city(driver) driver.find_element_by_xpath( "//input[@placeholder='请输入工程详细地址']").send_keys('南京路168号') # 工程属性 get_elements(driver, ('xpath', "//input[@type='checkbox']"))[random.randint( 0, 3)].click() driver.find_element_by_xpath("//input[@placeholder='类目']").send_keys( '建筑') driver.find_element_by_xpath("//input[@placeholder='年份']").click() driver.find_element_by_xpath("//span[@class='year active']").click() driver.find_element_by_xpath("//input[@placeholder='编号']").send_keys( random.randint(10000, 99999)) project_information = '土方开挖,土方回填,钢筋工程,模板工程,混凝土工程,砌体工程,装饰装修工程等' contract_scope = "售楼部的美女,工程部的汉,项目部的光棍满街转!财务的花,预算的草,施工队的和尚到处跑!食堂的饭,宿舍的床,搞工程的女人吓死郎!" driver.find_elements_by_xpath( "//textarea[@placeholder='选填']")[0].send_keys(project_information) driver.find_elements_by_xpath( "//textarea[@placeholder='选填']")[1].send_keys(contract_scope) setting_input_time(driver) driver.find_element_by_xpath( "//input[@placeholder='选择日期不得晚于计划竣工日期']").send_keys( get_pass_dates(2)) driver.find_element_by_xpath( "//input[@placeholder='选择日期不得早于今天']").send_keys( get_future_date(300)) driver.find_elements_by_xpath( "//input[@placeholder='选填']")[0].send_keys(random.randint( 100, 200)) driver.find_elements_by_xpath( "//input[@placeholder='必填']")[0].send_keys( random.randint(100000, 999999)) driver.find_element_by_xpath( "//input[@placeholder='请输入项目经理姓名']").send_keys("暂无") driver.find_element_by_xpath( "//input[@placeholder='选择日期不得晚于当前日期']").send_keys(get_now_dates()) select_city_choice(driver) driver.find_elements_by_xpath( "//input[@placeholder='选填']")[1].send_keys("南京路256号") driver.find_element_by_xpath("//button[@type='submit']").click() print(get_element(driver, ('id', "LAY_demo2")).text) assert get_element(driver, ('id', "LAY_demo2")).text == "成功" except Exception as e: print(e) bug_photo(driver) assert False
def new_payroll(driver, payroll_name, money): # 薪资管理 try: into_one_level(driver, '工程面板') sleep(1) into_two_level(driver, '薪资管理') get_element(driver, ('xpath', "//button[@class='btn btn-primary']")).click() # 工程名称 get_element(driver, ('xpath', "//select[@id='kkkk']/option[2]")).click() # 输入工资月份 get_now_dates() setting_input_time(driver) r = r'\d{4}-\d{2}' text = re.findall(r, get_now_dates()) get_element( driver, ('xpath', "//input[@class='form-control form-n-y-1']")).send_keys(text) # 工资单名称 get_element(driver, ('id', 'createProllNameAll')).clear() sleep(0.2) get_element(driver, ('id', 'createProllNameAll')).send_keys(payroll_name) # 确定按钮 get_element( driver, ('xpath', "//button[@class='btn btn-primary proll-btn-com']")).click() sleep(1) # 增加最后一个人 get_elements(driver, ( 'xpath', "//div[@id='createrProll']/div[3]/div[1]/div[2]/div/div[1]/div/div/div/span[2]" ))[-1].click() sleep(0.5) get_element(driver, ('xpath', "//a[contains(text(),'移除')]")).click() sleep(1) if is_element_present_3s(driver, ('xpath', "//tr[1]/td[7]/input"), 3): print("移除失败") assert False else: pass get_elements(driver, ( 'xpath', "//div[@id='createrProll']/div[3]/div[1]/div[2]/div/div[1]/div/div/div/span[2]" ))[-1].click() get_element(driver, ('xpath', "//tr[1]/td[5]/a")).click() get_elements(driver, ('xpath', "//input[@class='form-control']"))[1].send_keys( get_bank_card_number()[2:18]) get_element(driver, ('xpath', "//button[contains(text(),'确定')]")).click() # 发放金额 get_element(driver, ('xpath', "//input[@class='pay-money']")).send_keys(money) sleep(3) get_element(driver, ('xpath', "//button[contains(text(),'保存')]")).click() sleep(0.5) get_element( driver, ('xpath', "//table[@id='project-proll-release']/tbody/tr[1]/td[7]/a[1]" )).click() assert is_element_present_3s(driver, ('xpath', "//input[@class='pay-money']"), 3), "保存失败" sleep(3) get_element(driver, ('xpath', "//button[contains(text(),'保存')]")).click() sleep(0.5) get_element( driver, ('xpath', "//table[@id='project-proll-release']/tbody/tr[1]/td[7]/a[2]" )).click() sleep(3) report = os.path.join(test_report_path(), payroll_name + '.xls') import win32com.client sleep(1) excel = win32com.client.gencache.EnsureDispatch('Excel.Application') sleep(0.1) wb = excel.Workbooks.Open(report) sleep(2) wb.SaveAs(report + 'x', FileFormat=51) wb.Close() excel.Application.Quit() # 删除旧的xls sleep(0.5) os.remove(report) new_report = os.path.join(test_report_path(), payroll_name + '.xlsx') wb1 = load_workbook(filename=new_report) sheets = wb1.get_sheet_names() # 获取所有的表格 print(sheets) sheets_first = sheets[0] # 获取第一个表 ws1 = wb1.get_sheet_by_name(sheets_first) print(ws1['F2'].value) assert money == ws1['F2'].value, "下载文件内容显示不正确" os.remove(new_report) except Exception as e: bug_photo(driver) print(e) assert False
def request_for_overtime(driver, remark, file_path): """ # 加班申请 :param driver: :param remark:备注信息 :param file_path: 附件路径 :return: """ into_one_level(driver, '任务面板') sleep(1) into_one_level(driver, '发起申请') get_element(driver, ('xpath', "//div[contains(text(),'加班申请')]")).click() get_element(driver, ('id', 'leaveAdd')).click() sleep(0.5) element = "//*[@id='lay-user-f']/tbody/tr" for i in range(0, len(get_elements(driver, ('xpath', element))), 2): elements = "//tr[@data-index='%s']/td/input" % i get_element(driver, ('xpath', elements)).click() sleep(0.1) get_element(driver, ('xpath', "//a[contains(text(),'确定')]")).click() setting_input_time(driver) get_elements(driver, ('xpath', "//div[@class='col-sm-6']/input"))[0].send_keys( get_now_dates()) get_element( driver, ('xpath', "//input[@placeholder='选择时间需小于加班结束时间']")).send_keys('20:00') get_element( driver, ('xpath', "//input[@placeholder='选择时间需大于加班开始时间']")).send_keys('21:00') get_element( driver, ('xpath', "//input[@placeholder='请输入加班费, 单位:元/小时']")).send_keys( random.randint(20, 50)) get_element( driver, ('xpath', "//textarea[@class='form-control']")).send_keys(remark) get_element( driver, ('xpath', "//div[@id='uploadFile']/input")).send_keys(file_path) get_element(driver, ('xpath', "//button[contains(text(),'提交申请')]")).click() get_element(driver, ('id', "success")).click() sleep(0.5) i = 1 while 1: if is_element_present_3s(driver, ('xpath', "//div[contains(text(),'创建失败')]")): sleep(1) get_element(driver, ( 'xpath', "//a[@class='layui-layer-ico layui-layer-close layui-layer-close1']" )).click() sleep(0.2) get_elements( driver, ('xpath', "//div[@class='col-sm-6']/input"))[0].clear() get_elements( driver, ('xpath', "//div[@class='col-sm-6']/input"))[0].send_keys( get_pass_dates(i)) i += 1 get_element( driver, ('xpath', "//button[contains(text(),'提交申请')]")).click() get_element(driver, ('id', "success")).click() sleep(0.5) if is_element_present_3s(driver, ('id', "LAY_demo2")): break else: break into_one_level(driver, '我的任务') get_element(driver, ('xpath', "//a[contains(text(),'我发起的')]")).click() try: sleep(0.5) get_element(driver, ('xpath', "//button[contains(text(),'加班工作流')]")).click() get_element( driver, ('xpath', "//*[@id='task-mytask-table']/tbody/tr[1]/td[8]/a")).click() assert_element = "//div[@class='tsk-inp col-xs-8' and contains(text(),'%s')]" % remark assert is_element_present(driver, ('xpath', assert_element)) except Exception as e: print(e) bug_photo(driver) assert False
def personal_certificate(driver, file_path): sleep(3) try: if is_element_present(driver, ('xpath', "//i[@data-target='#mo-book-add']")): get_element(driver, ('xpath', "//i[@data-target='#mo-book-add']")).click() else: get_element(driver, ('xpath', "//div[@data-target='#mo-book']")).click() get_element(driver, ( 'xpath', "//div[@data-target='#mo-book-add' and contains(text(),'添加证书')]" )).click() work_type = "//div[1]/div[1]/select[@class='form-control']/option[%s]" % str( random.randint(2, 39)) get_elements(driver, ('xpath', work_type))[0].click() certificate_number = random_str() + get_org_no()[:-3] get_element( driver, ('xpath', "//input[@placeholder='请输入工种证书号']")).send_keys(certificate_number) level_education = "//div[3]/div[1]/select[@class='form-control']/option[%s]" % str( random.randint(2, 11)) get_elements(driver, ('xpath', level_education))[0].click() setting_input_time(driver) get_element( driver, ('xpath', "//input[@placeholder='选择日期不得晚于当前日期']")).send_keys( get_pass_dates(random.randint(200, 400))) get_element( driver, ('xpath', "//input[@placeholder='选择日期大于等于领证日期']")).send_keys( get_pass_dates(random.randint(50, 199))) get_element(driver, ('xpath', "//input[@placeholder='选择日期大于今天']")).send_keys( get_tomorrow_dates()) get_element( driver, ('xpath', "//div[7]/div[1][@class='col-sm-6']/input")).send_keys('政府') if len(get_elements(driver, ('xpath', "//input[@name='file']"))) == 2: get_elements( driver, ('xpath', "//input[@name='file']"))[0].send_keys(file_path) get_elements( driver, ('xpath', "//input[@name='file']"))[1].send_keys(file_path) else: get_elements( driver, ('xpath', "//input[@name='file']"))[-2].send_keys(file_path) get_elements( driver, ('xpath', "//input[@name='file']"))[-1].send_keys(file_path) # 利用js 获取当前元素位置 driver.execute_script( "arguments[0].scrollIntoView();", get_element(driver, ('xpath', "//button[contains(text(),'提交')]"))) sleep(0.5) get_element(driver, ('xpath', "//button[contains(text(),'提交')]")).click() element = "//h4[contains(text(),'%s')]" % certificate_number assert is_element_present(driver, ('xpath', element)), "添加证书失败" except Exception as e: print(e) bug_photo(driver) assert False
def family_information(driver): sleep(3) try: get_element(driver, ('xpath', "//div[@data-target='#mo-home']")).click() get_element( driver, ('xpath', "//input[@data-duplex-changed='show1']")).click() get_elements( driver, ('xpath', "//div[@class='pi-plane-con-text']/input"))[0].clear() get_elements( driver, ('xpath', "//div[@class='pi-plane-con-text']/input"))[0].send_keys('2') setting_input_time(driver) # 结婚日期 get_elements(driver, ('xpath', "//div[@id='marry']/input"))[0].send_keys( get_pass_dates(100)) get_elements( driver, ('xpath', "//div[@class='pi-plane-con-text']/input"))[1].send_keys( get_people_name()) get_elements( driver, ('xpath', "//div[@class='pi-plane-con-text']/input"))[2].send_keys( get_mobile()) relation_element = "//div[2]/div/div[6]/select/option[%s]" % str( random.randint(2, 8)) get_element(driver, ('xpath', relation_element)).click() len_province = len( get_elements(driver, ('xpath', "//div[2]/div/div[7]/select/option"))) province_element = "//div[2]/div/div[7]/select/option[%s]" % str( random.randint(2, len_province)) get_element(driver, ('xpath', province_element)).click() sleep(1) len_city = len( get_elements(driver, ('xpath', "//div[2]/div/div[8]/select/option"))) city_element = "//div[2]/div/div[8]/select/option[%s]" % str( random.randint(2, len_city)) get_element(driver, ('xpath', city_element)).click() sleep(1) len_district = len( get_elements(driver, ('xpath', "//div[2]/div/div[9]/select/option"))) district_element = "//div[2]/div/div[9]/select/option[%s]" % str( random.randint(1, len_district)) get_element(driver, ('xpath', district_element)).click() get_element(driver, ('xpath', "//div[2]/div/div[10]/input")).send_keys('塔克拉玛干') get_element(driver, ('xpath', "//div[2]/div/div[11]/input")).send_keys('厄尔') get_elements(driver, ('xpath', "//button[contains(text(),'保存')]"))[1].click() assert get_element(driver, ('id', "LAY_demo2")).text == '更新成功' a = get_element(driver, ('id', "LAY_demo2")).text print(a) except Exception as e: print(e) bug_photo(driver) assert False
def edit_workers_contract(driver, workers_name, photo_path): try: into_one_level(driver, '工程面板') sleep(0.5) into_two_level(driver, '工人管理') # 查询工人姓名 get_element( driver, ('xpath', "//div[@id='table-toolbar']/input")).send_keys(workers_name) # 搜索 get_element(driver, ('xpath', "//div[@id='table-toolbar']/button")).click() get_element(driver, ( 'xpath', "//a[contains(text(),'合同详情') and @class='table-a-link']")).click() sleep(0.5) get_element(driver, ('xpath', "//button[contains(text(),'内容编辑')]")).click() if is_element_present_3s( driver, ('xpath', "//input[@placeholder='请输入正常出勤单价']"), 3): pass else: driver.refresh() if is_element_present( driver, ('xpath', "//button[contains(text(),'内容编辑')]")): sleep(1) get_element( driver, ('xpath', "//button[contains(text(),'内容编辑')]")).click() else: pass sleep(0.5) get_element(driver, ('xpath', "//input[@placeholder='请输入正常出勤单价']")).clear() sleep(0.5) new_unit_price = random.randint(1, 200) get_element( driver, ('xpath', "//input[@placeholder='请输入正常出勤单价']")).send_keys(new_unit_price) sleep(0.1) new_overtime_work = random.randint(1, 200) get_element(driver, ('xpath', "//input[@placeholder='请输入加班单价']")).clear() sleep(1) get_element( driver, ('xpath', "//input[@placeholder='请输入加班单价']")).send_keys(new_overtime_work) get_element(driver, ('xpath', "//textarea[@placeholder='选填']")).clear() assert_information = '验证数据' get_element( driver, ('xpath', "//textarea[@placeholder='选填']")).send_keys(assert_information) setting_input_time(driver) get_element( driver, ('xpath', "//input[@placeholder='选择日期不得大于分包合同结束日期']")).clear() get_element( driver, ('xpath', "//input[@placeholder='选择日期不得大于分包合同结束日期']")).send_keys( get_future_date(150)) get_element( driver, ('xpath', "//div[@id='uploadFile2']/input[1]")).send_keys(photo_path) sleep(3) get_element(driver, ('xpath', "//button[contains(text(),'完成')]")).click() assert is_element_present(driver, ('id', 'LAY_demo2')) sleep(7) until_price = "//span[contains(text(),'单价:%s元/小时')]" % new_unit_price print(until_price) assert is_element_present(driver, ('xpath', until_price)), "工人单价未更新" over_time = "//span[contains(text(),'加班工资:%s元/小时')]" % new_overtime_work assert is_element_present(driver, ('xpath', over_time)), "加班工资未更新" workers_information = "//span[contains(text(),'内容:%s')]" % assert_information assert is_element_present(driver, ('xpath', workers_information)), "工作内容未更新" workers_contract_time = "//div[@id='laborContract']/p[contains(text(),'1.用工日期从%s进场始至%s日止')]" % ( str(get_pass_dates(2)), str(get_future_date(150))) assert is_element_present( driver, ('xpath', workers_contract_time)), "工人合同时间未更新" except Exception as e: print(e) bug_photo(driver) assert False
def workman_contract(driver, people): try: into_one_level(driver, "任务面板") sleep(1) into_two_level(driver, "发起申请") get_element(driver, ('xpath', "//div[contains(text(),'新建用工合同')]")).click() get_element(driver, ('xpath', "//span[contains(text(),'计时工人用工合同')]")).click() project_element = "//select[@id='reproject-name']/option[2]" get_element(driver, ('xpath', project_element)).click() get_element(driver, ('xpath', "//*[@id='reproject-team']/option[2]")).click() get_element(driver, ('xpath', "//input[@placeholder='请输入正常出勤单价']")).send_keys( random.randint(10, 99)) get_element(driver, ('xpath', "//input[@placeholder='请输入加班单价']")).send_keys( random.randint(10, 99)) # 选择工种 work_type = "//*[@id='work-type']/option" work_type_element = "//*[@id='work-type']/option[%d]" % random.randint( 2, len(work_type)) get_element(driver, ('xpath', work_type_element)).click() get_element( driver, ('xpath', "//input[@placeholder='请输入姓名查询']")).send_keys(people) sleep(0.5) workman_element = "//span[contains(text(),'%s')]" % people get_element(driver, ('xpath', "//input[@placeholder='请输入姓名查询']")).send_keys( Keys.ENTER) sleep(1) get_elements(driver, ('xpath', workman_element))[0].click() information = "按工作时间长短付给你工资的工作。" get_element( driver, ('xpath', "//textarea[@placeholder='选填']")).send_keys(information) setting_input_time(driver) get_elements( driver, ('xpath', "//input[@placeholder='必填']"))[0].send_keys('08:00') get_elements( driver, ('xpath', "//input[@placeholder='必填']"))[1].send_keys('18:00') get_element(driver, ('xpath', "//input[@placeholder='小于用工合同结束日期']")).send_keys( get_pass_dates(2)) get_element( driver, ('xpath', "//input[@placeholder='选择日期不得大于分包合同结束日期']")).send_keys( get_future_date(180)) get_elements( driver, ('xpath', "//input[@placeholder='必填']"))[2].send_keys('10') get_element(driver, ('xpath', "//button[contains(text(),'完成')]")).click() assert is_element_present(driver, ( 'xpath', "//div[contains(text(),'成功')]/i[@class='layui-layer-ico layui-layer-ico1' ]" )) except Exception as e: print(e) bug_photo(driver) assert False
def workman_contract_piece(driver, artifact_name, people): try: into_one_level(driver, "任务面板") sleep(1) into_two_level(driver, "发起申请") get_element(driver, ('xpath', "//div[contains(text(),'新建用工合同')]")).click() get_element(driver, ('xpath', "//span[contains(text(),'计件工人用工合同')]")).click() project_element = "//select[@id='reproject-name']/option[2]" get_element(driver, ('xpath', project_element)).click() get_element(driver, ('xpath', "//*[@id='reproject-team']/option[2]")).click() get_elements( driver, ('xpath', "//input[@placeholder='必填']"))[0].send_keys(artifact_name) address = ['上海', '北京', '广州', '杭州', '无锡', '苏州', '徐州'] get_elements(driver, ('xpath', "//input[@placeholder='必填']"))[1].send_keys( address[random.randint(0, len(address))]) get_elements(driver, ('xpath', "//input[@placeholder='必填']"))[2].send_keys( random.randint(88, 188)) get_elements(driver, ('xpath', "//input[@placeholder='必填']"))[3].send_keys( random.randint(199, 399)) get_element( driver, ('xpath', "//textarea[@placeholder='选填']")).send_keys('优秀的完成') # 选择工种 work_type = "//*[@id='work-type']/option" work_type_element = "//*[@id='work-type']/option[%d]" % random.randint( 2, len(work_type)) get_element(driver, ('xpath', work_type_element)).click() setting_input_time(driver) get_element(driver, ('id', 'select2-piece-worker-Name-container')).click() get_element( driver, ('xpath', "//input[@class='select2-search__field']")).send_keys(people) sleep(0.5) get_element( driver, ('xpath', "//input[@class='select2-search__field']")).send_keys( Keys.ENTER) get_elements( driver, ('xpath', "//input[@placeholder='必填']"))[4].send_keys('08:30') get_elements( driver, ('xpath', "//input[@placeholder='必填']"))[5].send_keys('17:30') get_element( driver, ('xpath', "//input[@placeholder='小于用工合同结束日期' ]")).send_keys( get_pass_dates(2)) get_element( driver, ('xpath', "//input[@placeholder='选择日期不得大于分包合同结束日期']")).send_keys( get_future_date(180)) get_elements(driver, ('xpath', "//input[@placeholder='必填']"))[6].send_keys( random.randint(1, 30)) get_element(driver, ('xpath', "//button[contains(text(),'完成')]")).click() assert is_element_present(driver, ( 'xpath', "//div[contains(text(),'成功')]/i[@class='layui-layer-ico layui-layer-ico1' ]" )) except Exception as e: print(e) bug_photo(driver) assert False