Example #1
0
def project_delay(driver):
    try:
        into_one_level(driver, '工程面板')
        sleep(1)
        get_elements(driver, ('xpath', "//a[contains(text(),'设置')]"))[1].click()
        sleep(0.5)
        get_element(driver, ('xpath', "//button[contains(text(),'项目延期')]")).click()
        sleep(1)
        num = 300
        setting_input_time(driver)
        get_element(driver, ('xpath', "//input[@placeholder='选择日期需大于原总包合同结束时间']")).send_keys(get_future_date(num))
        get_element(driver, ('xpath', "//button[contains(text(),'提交申请')]")).click()
        sleep(0.5)
        get_element(driver, ('id', 'success')).click()
        while 1:
            if is_element_present(driver, ('xpath', "//div[contains(text(),'延期时间必须大于总包合同的竣工日期')]")):
                sleep(0.1)
                get_element(driver, ('xpath', "//span[@class='layui-layer-setwin']/a")).click()
                get_element(driver, ('xpath', "//input[@placeholder='选择日期需大于原总包合同结束时间']")).clear()
                num += 20
                get_element(driver, ('xpath', "//input[@placeholder='选择日期需大于原总包合同结束时间']")).send_keys(get_future_date(num))
                get_element(driver, ('xpath', "//button[contains(text(),'提交申请')]")).click()
                sleep(0.5)
                get_element(driver, ('id', 'success')).click()
            else:
                break
    except Exception as e:
        print(e)
        bug_photo(driver)
        assert False
Example #2
0
def change_workman_contract_date(driver):
    try:
        now_date = get_future_date(90)
        into_one_level(driver, "任务面板")
        sleep(1)
        into_two_level(driver, "发起申请")
        get_element(driver,
                    ('xpath', "//div[contains(text(),'用工合同期限修改')]")).click()
        get_elements(
            driver,
            ('xpath', "//input[@class='form-control input-sm']"))[0].click()
        get_element(driver, ('id', 'realname')).send_keys('曹永')
        get_element(driver, ('id', 'realsearch')).click()
        sleep(0.5)
        get_element(
            driver,
            ('xpath', "//*[@id='lay-user-f']/tbody/tr/td[1]/input")).click()
        get_element(driver, ('xpath', "//a[contains(text(),'确定')]")).click()
        sleep(0.5)
        setting_input_time(driver)
        get_element(
            driver,
            ('xpath', "//input[@placeholder='请选择日期']")).send_keys(now_date)
        get_element(driver,
                    ('xpath', "//button[contains(text(),'提交申请')]")).click()
        get_element(driver, ('id', "success")).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 delete_area(driver):
    # 删除区域
    into_one_level(driver, '工程面板')
    sleep(1)
    get_elements(driver, ('xpath', "//a[contains(text(),'设置')]"))[1].click()
    into_two_level(driver, '项目设置')
    # 区域个数
    project_area_elements = "//div[@class='select-area-util-item select-area-util-area']"

    new_area_name = []
    number = int(len(get_elements(driver, ('xpath', project_area_elements))))
    for i in range(number):
        new_area_name.insert(
            i,
            get_elements(driver, ('xpath', project_area_elements))[i].text)
    project_element = "//div[@class='select-area-util-item select-area-util-area'and contains(text(),'%s')]" % \
                      new_area_name[number - 1]
    delete_project_element = project_element + "/div/div[3]"
    ActionChains(driver).move_to_element(
        get_element(driver, ('xpath', project_element))).perform()
    sleep(1)
    get_element(driver, ('xpath', delete_project_element)).click()
    get_element(driver, ('id', 'success')).click()
    sleep(2)
    new_number = int(
        len(get_elements(driver, ('xpath', project_area_elements))))
    print(new_number, number)
    sleep(2)
    if number == int(new_number + 1):
        print('删除区域成功')
    else:
        bug_photo(driver)
        assert False
Example #4
0
def material_equipment_management(driver, switch):
    # 材料设备管理
    if switch:
        get_element(
            driver,
            ('xpath', "//input[@placeholder='请输入供应设备到期时间']")).send_keys(
                random.randint(20, 99))
        get_element(
            driver,
            ('xpath', "//input[@placeholder='请输入0-100范围内整数']")).send_keys(
                random.randint(1, 99))
        get_elements(driver,
                     ('xpath', "//button[contains(text(),'添加')]"))[-1].click()
        get_elements(
            driver, ('xpath',
                     "//input[@class='need form-control input-sm text-center']"
                     ))[0].send_keys(get_company_name()[2:-4])
        get_elements(
            driver, ('xpath',
                     "//input[@class='need form-control input-sm text-center']"
                     ))[1].send_keys(get_company_name()[2:-4])
        get_elements(driver, (
            'xpath',
            "//input[@class='need form-control input-sm form-num text-center']"
        ))[0].send_keys(random.randint(200, 300))
        get_elements(driver, (
            'xpath',
            "//input[@class='need form-control input-sm form-num text-center']"
        ))[1].send_keys(random.randint(200, 300))
    else:
        pass
Example #5
0
def attendance_machine_login(driver):
    into_one_level(driver, '工程面板')
    sleep(1)
    get_elements(driver, ('xpath', "//a[contains(text(),'设置')]"))[1].click()
    into_two_level(driver, '考勤机设置')
    get_elements(
        driver,
        ('xpath',
         "//i[@class='glyphicon glyphicon-facetime-video']"))[0].click()
    # 得到selenium打开的浏览器的所有句柄
    all_hand = driver.window_handles
    # 切换句柄
    driver.switch_to_window(all_hand[-1])
    get_element(driver, ('id', 'firstname')).clear()
    sleep(0.5)
    get_element(driver, ('id', 'firstname')).send_keys('hpface固定ipc测试')
    get_element(driver, ('id', 'lastname')).send_keys('123456')
    get_element(driver,
                ('xpath', "//button[@class='btn btn-primary']")).click()
    sleep(0.5)
    if get_element(driver, ('id', 'LAY_demo2')).text == '成功:订阅':
        pass
    else:
        bug_photo(driver)
        assert False
    driver.close()
    driver.switch_to_window(all_hand[0])
Example #6
0
def forget_password(driver, mobile, new_password, code):
    get_elements(driver,
                 ('xpath', "//button[contains(text(),'登录')]"))[0].click()
    get_element(driver, ('xpath', "//a[contains(text(),'忘记密码?')]")).click()
    # 输入用户名
    sleep(0.1)
    get_element(driver, ('id', "user")).send_keys(mobile)
    # 输入新密码
    get_element(driver, ('id', "newPassWork")).send_keys(new_password)
    # 再次输入密码
    get_element(
        driver,
        ('xpath', "//input[@placeholder='请再次输入确认密码']")).send_keys(new_password)
    # driver.find_elements_by_xpath("//span[contains(text(),'点击获取验证码')]")[1].click()
    get_element(driver,
                ('xpath', "//span[contains(text(),'点击获取验证码')]")).click()
    # 输入验证码
    get_element(
        driver,
        ('xpath',
         ".//*[@id='forgetPass']/form/div[4]/div[2]/input")).send_keys(code)
    sleep(0.5)
    get_element(driver, ('xpath', "//button[contains(text(),'重置密码')]")).click()
    sleep(6)
    try:
        web_login(driver, mobile, new_password)
        print('重置密码,且登陆成功')
    except Exception as e:
        print(e)
        print("重置密码失败")
        assert False
def upload_file_document_library(driver):
    # 台账管理,上传专项检查文件、 查看文件上传是否成功、
    into_one_level(driver, '工程面板')
    sleep(1)
    into_two_level(driver, '台账管理')
    sleep(0.5)
    # 获取所有的文件夹
    folder_number = len(
        get_elements(
            driver,
            ('xpath', "//div[@class='col-sm-2 text-center type-item']/p")))
    # 文件夹的名称
    for i in range(folder_number):
        folder_name = get_elements(
            driver,
            ('xpath',
             "//div[@class='col-sm-2 text-center type-item']/p"))[i].text
        print(folder_name)
        element = "//p[contains(text(),'%s')]" % folder_name
        get_element(driver, ('xpath', element)).click()
        if folder_name in ('考勤记录表', '工资单', '银行代发'):

            get_elements(driver, (
                'xpath',
                "//div[@class='col-sm-2 text-center type-item search-month-name']"
            ))[0].click()
        upload_and_delete_file(driver)
        driver.refresh()
        sleep(1)
Example #8
0
def remuneration_pay(driver, switch):
    # 劳务报酬中间支付
    if switch:
        price = random.randint(3000, 50000)
        price_1 = random.randint(3000, 50000)
        price_2 = random.randint(3000, 50000)
        get_element(driver, (
            'xpath',
            "//div[contains(text(),'元')]/input[@class='form-num form-control input-sm']"
        )).send_keys(price)
        get_element(driver,
                    ('xpath', "//option[contains(text(),'现金')]")).click()
        get_elements(driver,
                     ('xpath', "//button[contains(text(),'添加')]"))[2].click()
        setting_input_time(driver)
        get_elements(driver, (
            'xpath',
            "//input[@class='need form-control input-sm text-center form-date']"
        ))[0].send_keys(get_pass_dates(60))
        get_elements(driver, (
            'xpath',
            "//input[@class='need form-control input-sm text-center form-date']"
        ))[1].send_keys(get_pass_dates(30))
        get_elements(driver, (
            'xpath',
            "//div[contains(text(),'元')]/input[@class='need form-control input-sm']"
        ))[0].send_keys(price_1)
        get_elements(driver, (
            'xpath',
            "//div[contains(text(),'元')]/input[@class='need form-control input-sm']"
        ))[1].send_keys(price_2)
    else:
        pass
Example #9
0
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', "//button[contains(text(),'添加至已选')]")).click()
    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')
    overtime_type = "//select[@class='form-control input-sm']/option[%s]" % str(
        random.randint(1, 2))
    get_element(driver, ('xpath', overtime_type)).click()
    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)
    into_one_level(driver, '我的任务')
    get_element(driver, ('xpath', "//a[contains(text(),'我发起的')]")).click()
    try:
        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
Example #10
0
def laws_and_regulations(driver, switch):
    # 法律法规
    if switch:
        for i in range(5):
            get_elements(driver, ('xpath', "//input[@class='zblaw-item']"))[i].click()
            sleep(0.1)
    else:
        pass
def batch_add_workman(driver, file_path, remark):
    # 批量发起请假申请
    """

    :param driver:
    :param file_path: 附件路径
    :param remark: 备注信息
    :return:
    """
    into_one_level(driver, '任务面板')
    sleep(1)
    into_one_level(driver, '发起申请')
    get_element(driver, ('xpath', "//div[contains(text(),'请假申请')]")).click()
    sleep(0.5)
    # 请假类型
    element = "//select[@class='form-control input-sm']/option[%s]" % str(
        random.randint(1, 7))
    get_element(driver, ('xpath', element)).click()
    get_element(driver, ('id', 'leaveAdd')).click()
    sleep(0.5)
    for i in range(0, 3):
        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', "//input[@placeholder='选择日期在合同范围内']"))[0].send_keys(
                     get_now_dates())
    get_elements(driver,
                 ('xpath', "//input[@placeholder='选择日期在合同范围内']"))[1].send_keys(
                     get_tomorrow_dates())
    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(1.5)
    into_one_level(driver, '我的任务')
    get_element(driver, ('xpath', "//a[contains(text(),'我发起的')]")).click()
    try:
        get_element(driver,
                    ('xpath', "//button[contains(text(),'请假工作流')]")).click()
        sleep(3)
        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
        is_element_present(driver, ('xpath', assert_element))
    except Exception as e:
        print(e)
        print('工人已经存在请假工作流,无法继续发起')
        bug_photo(driver)
        assert False
Example #12
0
def sub_insurance(driver, switch):
    # 保险
    if switch:
        information = "劳务分包人施工开始前,工程承包人应获得发包人为施工场地内的自有人员及第三人人员生命财产办理的保险,且不需劳务分包人支付保险费用。"
        information_1 = "即负责承建该项工程的施工单位,可分为总承包人和分承包人"
        get_elements(driver, ('xpath', "//textarea[@class='form-control input-sm']"))[1].send_keys(information)
        get_elements(driver, ('xpath', "//textarea[@class='form-control input-sm']"))[2].send_keys(information_1)
    else:
        pass
Example #13
0
def to_apply_for_leave(driver, file_path, remark):
    """

    :param driver:
    :param file_path: 附件路径
    :param remark: 备注
    :return:
    """
    into_one_level(driver, '任务面板')
    sleep(1)
    into_one_level(driver, '发起申请')
    get_element(driver, ('xpath', "//div[contains(text(),'请假申请')]")).click()
    sleep(0.5)
    element = "//select[@class='form-control input-sm']/option[%s]" % str(
        random.randint(1, 7))
    get_element(driver, ('xpath', element)).click()
    get_element(driver, ('id', 'leaveAdd')).click()
    get_element(driver, ('id', 'realname')).send_keys('曹永')
    get_element(driver, ('id', 'realsearch')).click()
    sleep(0.5)
    get_element(
        driver,
        ('xpath', "//*[@id='lay-user-f']/tbody/tr/td[1]/input")).click()
    get_element(driver,
                ('xpath', "//button[contains(text(),'添加至已选')]")).click()
    get_element(driver, ('xpath', "//a[contains(text(),'确定')]")).click()
    setting_input_time(driver)
    get_elements(driver,
                 ('xpath', "//input[@placeholder='选择日期在合同范围内']"))[0].send_keys(
                     get_now_dates())
    get_elements(driver,
                 ('xpath', "//input[@placeholder='选择日期在合同范围内']"))[1].send_keys(
                     get_tomorrow_dates())
    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(2)
    into_one_level(driver, '我的任务')
    get_element(driver, ('xpath', "//a[contains(text(),'我发起的')]")).click()
    try:
        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
Example #14
0
def change_time_of_attendance(driver, remark, file_path):
    try:
        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', "//button[contains(text(),'添加至已选')]")).click()
        get_element(driver, ('xpath', "//a[contains(text(),'确定')]")).click()
        setting_input_time(driver)
        get_element(
            driver,
            ('xpath', "//input[@placeholder='选择日期不得小于当前日期']")).send_keys(
                get_now_dates())
        get_elements(
            driver,
            ('xpath', "//input[@placeholder='']"))[0].send_keys('08:00')
        get_elements(
            driver,
            ('xpath', "//input[@placeholder='']"))[1].send_keys('17:00')
        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)
        into_one_level(driver, '我的任务')
        get_element(driver, ('xpath', "//a[contains(text(),'我发起的')]")).click()
        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
Example #15
0
def subcontract(driver, project_name, labor_company, sub_contract, labor_people):
    """
    :param driver: 驱动
    :param project_name: 工程名称
    :param labor_company: 劳务公司
    :param sub_contract: 分包合同名称
    :param labor_people: 劳务经理
    :return:
    """
    try:
        into_one_level(driver, '任务面板')
        sleep(0.5)
        into_two_level(driver, '发起申请')
        driver.find_element_by_xpath("//div[contains(text(),'新建分包合同')]").click()
        driver.find_element_by_xpath("//span[contains(text(),'输入工程名称')]").click()
        get_element(driver, ('xpath', "//input[@class='select2-search__field']")).send_keys(project_name)
        sleep(0.5)
        get_element(driver, ('xpath', "//input[@class='select2-search__field']")).send_keys(Keys.ENTER)
        sleep(1)
        driver.find_element_by_xpath("//span[contains(text(),'输入公司关键字查找')]").click()
        get_element(driver, ('xpath', "//input[@class='select2-search__field']")).send_keys(labor_company)
        sleep(0.5)
        get_element(driver, ('xpath', "//input[@class='select2-search__field']")).send_keys(Keys.ENTER)
        # 分包合同名称
        get_elements(driver, ('xpath', "//input[@placeholder='必填']"))[0].send_keys(sub_contract)
        information = "地基与基础、建筑装饰装修、建筑幕墙、钢结构、机电设备安装、电梯安装、消防设施、建筑防水、防腐保温、园林古建筑、爆破与拆除、电信工程、管道工程等"
        get_element(driver, ('xpath', "//textarea[@placeholder='必填']")).send_keys(information)
        setting_input_time(driver)
        get_element(driver, ('xpath', "//input[@placeholder='选择日期不得晚于计划竣工日期']")).send_keys(get_now_dates())
        get_element(driver, ('xpath', "//input[@placeholder='选择日期不得早于今天']")).send_keys(get_future_date(299))
        driver.find_element_by_xpath("//span[contains(text(),'输入姓名查找')]").click()
        get_element(driver, ('xpath', "//input[@class='select2-search__field']")).send_keys(labor_people)
        sleep(1)
        get_element(driver, ('xpath', "//input[@class='select2-search__field']")).send_keys(Keys.ENTER)
        get_elements(driver, ('xpath', "//input[@placeholder='必填']"))[1].send_keys(random.randint(10000, 99999))
        QA_standard(driver, random.randint(0, 1))
        remuneration_pay(driver, random.randint(0, 1))
        the_contract_comes_into_effect(driver, random.randint(0, 1))
        material_equipment_management(driver, random.randint(0, 1))
        sub_insurance(driver, random.randint(0, 1))
        dispute_resolution(driver, random.randint(0, 1))
        laws_and_regulations(driver, random.randint(0, 1))
        sleep(0.5)
        driver.find_element_by_xpath("//button[contains(text(),'完成')]").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 web_employee_registration(browser, name, mobile, password, company_name):
    # 企业员工注册
    """

    :param browser:
    :param name:
    :param mobile:
    :param password:
    :param company_name:
    :return:
    """
    browser.find_element_by_xpath("//button[contains(text(),'注册')]").click()
    sleep(0.5)
    browser.find_element_by_xpath("//div[contains(text(),'企业员工')]").click()
    get_element(browser, ('xpath', "//input[@data-pattern-message='请输入正确的手机号码']")).send_keys(mobile)
    sleep(0.5)
    get_elements(browser, ('xpath', "//span[contains(text(),'点击获取验证码')]"))[0].click()
    if is_element_present_3s(browser, ('xpath', "//div[contains(text(),'此号码已经存在,无需注册')]"), 5):
        get_element(browser, ('id', 'username')).send_keys(get_mobile())
    if is_element_present_3s(browser, ('xpath', "//input[@data-tip='请输入真实姓名']"), 4):
        get_element(browser, ('xpath', "//input[@placeholder='手机验证码']")).send_keys('11111')
    else:
        browser.find_element_by_xpath("//div[contains(text(),'企业员工')]").click()
        get_element(browser, ('xpath', "//input[@data-pattern-message='请输入正确的手机号码']")).send_keys(mobile)
        get_element(browser, ('xpath', "//input[@placeholder='短信校验码']")).clear()
        get_element(browser, ('xpath', "//input[@placeholder='短信校验码']")).send_keys('11111')
    get_element(browser, ('xpath', "//input[@data-tip='请输入真实姓名']")).send_keys(name)
    get_element(browser, ('id', "password1")).send_keys(password)
    get_element(browser, ('xpath', "//input[@data-tip='请再新输入密码']")).send_keys(password)
    get_element(browser, ('xpath', "//b[@role='presentation']")).click()
    get_element(browser, ('xpath', "//input[@class='select2-search__field' and @type='search']")).send_keys(
        company_name)
    sleep(0.5)
    get_element(browser, ('xpath', "//input[@class='select2-search__field' and @type='search']")).send_keys(Keys.ENTER)
    get_element(browser, ('xpath', "//input[@class='agree-input']")).click()
    get_element(browser, ('xpath', "//button[contains(text(),'创建账户')]")).click()
    sleep(0.5)
    a = get_element(browser, ('xpath', "//div[contains(text(),'成功:公司职员注册')]")).text
    if '成功:公司职员注册' == a:
        pass
    else:
        print("失败:公司职员注册")
        bug_photo(browser)
        assert False
    sleep(2)
    browser.find_element_by_xpath("//button[contains(text(),'登录')]").click()
    get_element(browser, ('id', "username")).send_keys(mobile)
    get_element(browser, ('id', "password")).send_keys(password)
    get_element(browser, ('id', "loginButton")).click()
Example #17
0
def update_PM(driver):
    into_one_level(driver, '工程面板')
    sleep(1)
    get_elements(driver, ('xpath', "//a[contains(text(),'设置')]"))[1].click()
    sleep(1)
    get_element(driver, ('xpath', "//button[contains(text(),'修改项目经理')]")).click()
    get_element(driver, ('xpath', "//select[@class='form-control input-sm']/option[2]")).click()
    get_element(driver, ('xpath', "//button[@class='btn btn-primary btn-sm']")).click()
    get_element(driver, ('id', 'success')).click()
    try:
        '更新成功' == get_element(driver, ('id', 'LAY_demo2')).text
    except Exception as e:
        print(e)
        bug_photo(driver)
        assert False
Example #18
0
def workers_review(driver, worker_name):
    try:
        into_one_level(driver, "任务面板")
        sleep(0.5)
        into_two_level(driver, "我的任务")
        get_element(driver,
                    ('xpath', "//button[contains(text(),'签订用工合同')]")).click()
        get_element(
            driver,
            ('xpath',
             "//*[@id='task-mytask-table']/tbody/tr[1]/td[9]/a")).click()
        get_element(
            driver,
            ('xpath', "//button[@class='btn btn-sm btn-success']")).click()
        get_element(driver, ('xpath', "//textarea")).send_keys('s')
        get_element(driver,
                    ('xpath', "//a[@class='layui-layer-btn0']")).click()
        sleep(10)
        driver.find_element_by_xpath("//a[contains(text(),'我审核过的')]").click()
        sleep(2)
        worker_name += '用工合同签订审核'
        element_len = get_elements(
            driver, ('xpath', "//*[@id='task-mytask-table']/tbody/tr"))
        title_text = []
        for i in range(1, len(element_len)):
            element = "//*[@id='task-mytask-table']/tbody/tr[%d]/td[4]" % i
            text = get_element(driver, ('xpath', element)).text
            title_text.insert(i, text)
            print(title_text)
        information = '用工合同签订失败'
        assert worker_name in title_text, "%s" % information
    except Exception as e:
        print(e)
        bug_photo(driver)
        assert False
Example #19
0
def contract_workflow(driver, contract_name, information):
    """

    :param information: 错误提示
    :param driver:
    :param contract_name: 合同名称
    :return:
    """
    into_one_level(driver, '任务面板')
    sleep(0.5)
    into_two_level(driver, '我的任务')
    get_element(
        driver,
        ('xpath', "//*[@id='task-mytask-table']/tbody/tr[1]/td[8]/a")).click()
    get_element(
        driver,
        ('xpath', "//button[@class='btn btn-sm btn-success']")).click()
    get_element(driver, ('xpath', "//textarea")).send_keys('s')
    get_element(driver, ('xpath', "//a[@class='layui-layer-btn0']")).click()
    sleep(10)
    driver.find_element_by_xpath("//a[contains(text(),'我审核过的')]").click()
    sleep(2)
    contract_name += '签订审核'
    element_len = get_elements(
        driver, ('xpath', "//*[@id='task-mytask-table']/tbody/tr"))
    title_text = []
    for i in range(1, len(element_len)):
        element = "//*[@id='task-mytask-table']/tbody/tr[%d]/td[4]" % i
        text = get_element(driver, ('xpath', element)).text
        title_text.insert(i, text)
        print(title_text)
    information += '签订失败'
    assert contract_name in title_text, "%s" % information
def initiate_artifacts(driver, file_path):
    # 工件审核
    into_one_level(driver, '任务面板')
    sleep(1)
    into_one_level(driver, '发起申请')
    get_element(driver, ('xpath', "//div[contains(text(),'工件审核')]")).click()
    sleep(0.5)
    get_elements(
        driver,
        ('xpath', "//i[@class='glyphicon glyphicon-plus']"))[0].click()
    input_element = "//*[@id='lay-user-f']/tbody/tr[1]/td[1]/input"
    get_element(driver, ('xpath', input_element)).click()
    get_element(driver, ('xpath', "//a[contains(text(),'确定')]")).click()
    element = "//select[@class='form-control input-sm']/option[2]"
    try:
        get_element(driver, ('xpath', element)).click()
    except Exception as e:
        print(e)
        assert False, "没有此工件"
    get_element(driver, ('xpath', "//input[@placeholder='数量为整数']")).send_keys(
        random.randint(1, 9))
    setting_input_time(driver)
    get_element(driver,
                ('xpath', "//input[@placeholder='选择日期需小于或等于今天']")).send_keys(
                    get_now_dates())
    get_elements(
        driver,
        ('xpath', "//div[@class='col-sm-6']/input[1]"))[2].send_keys('优秀')
    get_element(driver,
                ('xpath', "//input[@data-min-message='输入值不能小于0']")).send_keys(
                    random.randint(1, 100))
    get_element(
        driver,
        ('xpath', "//div[@id='uploadFile']/input")).send_keys(file_path)
    get_element(driver, ('xpath', "//button[contains(text(),'提交申请')]")).click()
    sleep(0.5)
    get_element(driver, ('id', 'success')).click()
    sleep(1)
    try:
        '成功' == get_element(
            driver,
            ('xpath',
             "//div[@class='layui-layer-content layui-layer-padding']")).text
    except Exception as e:
        print(e)
        bug_photo(driver)
        assert False
Example #21
0
def termination_of_the_contract(driver, workers_name):
    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()
        get_elements(
            driver,
            ('xpath', "//a[contains(text(),'查看详情') and @class='table-a-link']"
             ))[1].click()
        sleep(1.5)
        get_element(driver,
                    ('xpath', "//button[contains(text(),'合同终止')]")).click()
        get_element(driver, ('id', 'success')).click()
        assert get_element(driver,
                           ('xpath', "//div[@id='LAY_demo2']")).text == '成功'
        sleep(3)
        get_element(
            driver,
            ('xpath',
             "//div[@id='table-toolbar']/input")).send_keys(workers_name)
        get_element(driver,
                    ('xpath', "//div[@id='table-toolbar']/button")).click()
        sleep(1)
        if is_element_present_3s(
                driver,
            ('xpath',
             "//a[contains(text(),'查看详情') and @class='table-a-link']"), 2):
            assert False, '终止合同后,还可以搜到工人'
        else:
            pass
    except Exception as e:
        print(e)
        bug_photo(driver)
        assert False
Example #22
0
def forget(phone_num):
    # driver.wait_activity(desired_caps['appWaitActivity'], 10)
    # driver.contexts
    get_elements(driver, ('ACCESSIBILITY_ID', '忘记密码')).click()
    driver.find_element_by_accessibility_id("忘记密码 ").click()
    sleep(6)
    driver.find_elements_by_class_name("android.widget.EditText")[0].send_keys(
        phone_num)
    sleep(3)
    driver.find_element_by_accessibility_id("点击获取 ").click()
    driver.find_element_by_android_uiautomator("text(\"请输入校验码\")").send_keys(
        "11111")
    sleep(5)
    driver.find_elements_by_class_name("android.widget.EditText")[2].send_keys(
        "123456")
    driver.find_elements_by_class_name("android.widget.EditText")[3].send_keys(
        "123456")
    driver.find_element_by_accessibility_id("重置密码 ").click()
Example #23
0
def add_team(driver, team_name):
    into_one_level(driver, '工程面板')
    sleep(1)
    into_two_level(driver, '组织构架')
    # 新增班组按钮
    get_element(driver, ('xpath', "//button[@class='btn btn-primary btn-sm']")).click()
    sleep(1)
    get_elements(driver, ('xpath', "//input[@class='form-control input-sm']"))[2].clear()
    # 输入班组名称
    get_elements(driver, ('xpath', "//input[@class='form-control input-sm']"))[2].send_keys(team_name)
    # 选择班组长
    get_element(driver, ('xpath', "//*[@id='add-team']/form/div[3]/div/select/option[2]")).click()
    # 选择质量员
    get_element(driver, ('xpath', "//*[@id='add-team']/form/div[4]/div/select/option[2]")).click()
    # 确定
    get_element(driver, ('xpath', "//*[@id='add-team']/form/div[5]/div/button[1]")).click()
    sleep(1)
    team_name_element = "//div[contains(text(),'%s')]" % team_name
    if is_element_present(driver, ('xpath', team_name_element)):
        pass
    else:
        bug_photo(driver)
        print('新增班组失败')
        assert False
    # 修改班组
    driver.find_element_by_xpath(team_name_element).click()
    get_element(driver, ('xpath', "//button[contains(text(),'修改班组')]")).click()
    new_team_name = getRandomName()
    sleep(1)
    get_elements(driver, ('xpath', "//input[@class='form-control input-sm']"))[2].clear()
    # 输入新的班组名称
    get_elements(driver, ('xpath', "//input[@class='form-control input-sm']"))[2].send_keys(new_team_name)
    # 确定
    get_element(driver, ('xpath', "//*[@id='add-team']/form/div[5]/div/button[1]")).click()
    sleep(1)
    new_team_name_element = "//div[contains(text(),'%s')]" % new_team_name
    if is_element_present(driver, ('xpath', new_team_name_element)):
        pass
    else:
        bug_photo(driver)
        print('新增班组失败')
        assert False
    get_element(driver, ('xpath', new_team_name_element)).click()
    get_element(driver, ('xpath', "//button[contains(text(),'删除班组')]")).click()
    get_element(driver, ('xpath', "//a[@class='layui-layer-btn0']")).click()
    sleep(1)
    if is_element_present(driver, ('xpath', team_name_element)):
        bug_photo(driver)
        print('新增班组失败')
        assert False
    else:
        pass
def brake_machine(driver):
    into_two_level(driver, '设备管理')
    driver.find_element_by_xpath("//a[contains(text(),'闸机')]").click()
    num = random_str(4) + str(random.randint(1000000, 9999999))
    random_ip = "192.168.1.%d" % random.randint(1, 255)
    # 增加闸机
    driver.find_elements_by_xpath("//button[contains(text(),'新增')]")[2].click()
    get_element(driver,
                ('xpath', "//input[@placeholder='请输入闸机设备号']")).send_keys(num)
    get_element(driver,
                ('xpath', "//option[contains(text(),'hpface联调闸机')]")).click()
    get_element(
        driver,
        ('xpath', "//input[@placeholder='请输入闸机IP']")).send_keys(random_ip)
    driver.find_element_by_xpath("//button[contains(text(),'确认')]").click()
    get_element(driver,
                ('xpath', "//input[@placeholder='请输入设备号筛选']")).send_keys(num)
    get_elements(driver,
                 ('xpath', "//button[contains(text(),'筛选')]"))[2].click()
    assert str(num) == get_element(
        driver,
        ('xpath',
         "//*[@id='zj-table']/tbody/tr[1]/td[2]")).text, "不在location中,新增失败"
    # 更新闸机
    get_element(driver,
                ('xpath', "//*[@id='zj-table']/tbody/tr/td[5]/a")).click()
    num1 = random_str(4) + str(random.randint(1000000, 9999999))
    get_element(driver, ('xpath', "//input[@placeholder='请输入闸机号码']")).clear()
    get_element(driver,
                ('xpath', "//input[@placeholder='请输入闸机号码']")).send_keys(num1)
    driver.find_elements_by_xpath("//button[contains(text(),'确认')]")[1].click()
    get_element(driver, ('xpath', "//input[@placeholder='请输入设备号筛选']")).clear()
    get_element(driver,
                ('xpath', "//input[@placeholder='请输入设备号筛选']")).send_keys(num1)
    get_elements(driver,
                 ('xpath', "//button[contains(text(),'筛选')]"))[2].click()
    assert str(num1) == get_element(
        driver,
        ('xpath',
         "//*[@id='zj-table']/tbody/tr[1]/td[2]")).text, "不在location中,新增失败"
    # 删除闸机
    get_element(driver,
                ('xpath', "//*[@id='zj-table']/tbody/tr/td[1]")).click()
    get_elements(driver,
                 ('xpath', "//button[contains(text(),'删除')]"))[2].click()
    get_elements(driver,
                 ('xpath', "//button[contains(text(),'确认')]"))[2].click()
    get_element(driver, ('id', "success")).click()
    assert is_element_present(driver,
                              ('xpath', "//td[@colspan='5']")), "删除闸机失败"
def webview_employee_register(driver,
                              company_name,
                              people,
                              mobile,
                              code='11111',
                              password='******'):
    print(driver.current_context)
    sleep(1)
    contexts = driver.contexts
    print(contexts)
    sleep(2)
    driver.switch_to.context(contexts[-1])
    print(driver.current_context)
    get_element(driver, ('xpath', "//input[@placeholder='请选择公司名称']")).click()
    get_element(
        driver,
        ('xpath', "//input[@placeholder='请输入公司名称']")).send_keys(company_name)
    get_element(driver, ('xpath', "//i[contains(text(),'搜索')]")).click()
    get_elements(driver, ('xpath', "//div[@class='radio-content']"))[0].click()
    get_element(driver, ('xpath', "//i[contains(text(),'确定')]")).click()
    get_element(
        driver,
        ('xpath', "//input[@placeholder='请输入您的真实姓名']")).send_keys(people)
    get_element(
        driver,
        ('xpath', "//input[@placeholder='请输入正确的帐号(手机号)']")).send_keys(mobile)
    get_element(driver, ('xpath', "//button[contains(text(),'点击获取')]")).click()
    get_element(driver, ('xpath', "//button[contains(text(),'确定')]")).click()
    get_element(driver,
                ('xpath', "//input[@placeholder='请输入校验码']")).send_keys(code)
    get_element(
        driver,
        ('xpath', "//input[@placeholder='请输入6-16位密码']")).send_keys(password)
    get_element(
        driver,
        ('xpath', "//input[@placeholder='再次输入密码以确认']")).send_keys(password)
    get_element(driver, ('xpath', "//button[contains(text(),'立即注册')]")).click()
    get_element(driver, ('xpath', "//button[contains(text(),'确定')]")).click()
    sleep(1)
    driver.switch_to.context(contexts[0])
Example #26
0
def labor_remuneration(driver, switch):
    if switch:
        # 暂停
        print('选中劳务报酬计算')
        price_0 = random.randint(3000, 90000)
        price_1 = random.randint(3000, 90000)
        price_2 = random.randint(3000, 90000)
        price_3 = random.randint(3000, 90000)
        get_element(
            driver,
            ('xpath', "//input[@placeholder='请输入整数']")).send_keys(price_0)
        # 选择工种
        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_elements(
            driver, ('xpath', "//div[@class='col-sm-6']/input[@placeholder='']"
                     ))[1].send_keys(price_1)
        get_elements(
            driver, ('xpath', "//div[@class='col-sm-6']/input[@placeholder='']"
                     ))[2].send_keys(price_2)
        get_elements(
            driver, ('xpath', "//div[@class='col-sm-6']/input[@placeholder='']"
                     ))[3].send_keys(price_3)
    else:
        pass
def get_attendance_machine_area_name(driver):
    # 获取考勤机设置当前界面的所有考勤机区域
    area_names = len(
        get_elements(
            driver,
            ('xpath', "//*[@id='engineering-set-table']/tbody/tr/td[2]")))
    area_name_lists = []
    for i in range(1, area_names):
        area_element = "//*[@id='engineering-set-table']/tbody/tr[%s]/td[2]" % i
        area_name_lists.insert(
            i,
            get_element(driver, ('xpath', area_element)).text)
    return area_name_lists
def sub_select_city_choice(driver):
    # 省
    all_province = len(get_elements(driver, ('xpath', "//div[@id='fbqydd']/div[1]/select/option")))
    element_1 = "//div[@id='fbqydd']/div[1]/select/option[%d]" % random.randint(2, all_province)
    get_element(driver, ('xpath', element_1)).click()
    sleep(0.5)
    # 市
    all_city = len(get_elements(driver, ('xpath', "//div[@id='fbqydd']/div[2]/select/option")))
    if all_city > 1:
        element_2 = "//div[@id='fbqydd']/div[2]/select/option[%d]" % random.randint(2, all_city)
        get_element(driver, ('xpath', element_2)).click()
    else:
        element_2 = "//div[@id='fbqydd']/div[2]/select/option[%d]" % random.randint(1, all_city)
        get_element(driver, ('xpath', element_2)).click()
    sleep(0.5)
    # 区
    all_district = len(get_elements(driver, ('xpath', "//div[@id='fbqydd']/div[3]/select/option")))
    if all_district > 1:
        element_3 = "//div[@id='fbqydd']/div[3]/select/option[%d]" % random.randint(2, all_district)
        get_element(driver, ('xpath', element_3))
    else:
        element_3 = "//div[@id='fbqydd']/div[3]/select/option[%d]" % random.randint(1, all_district)
        get_element(driver, ('xpath', element_3))
def work_experience(driver):
    company_name = getCompanyName()
    project_name = company_name[2:-4] + '工程'
    start_date = get_pass_dates(random.randint(300, 400))
    end_date = get_pass_dates(random.randint(100, 299))
    information = "上士闻道勤而行之;中士闻道若存若亡;下士闻道大笑之,不笑不足以为道。执行是一日复一日的"
    try:
        if is_element_present(driver,
                              ('xpath', "//i[@data-target='#mo-work-add']")):
            get_element(driver,
                        ('xpath', "//i[@data-target='#mo-work-add']")).click()
        else:
            get_element(driver,
                        ('xpath', "//div[@data-target='#mo-work']")).click()
            get_element(driver, (
                'xpath',
                "//div[@data-target='#mo-work-add' and contains(text(),'添加工作经验')]"
            )).click()
        get_elements(
            driver, ('xpath', "//div[@class='col-sm-6']/input[@placeholder='']"
                     ))[1].send_keys(company_name)
        sleep(1)
        setting_input_time(driver)
        get_elements(
            driver,
            ('xpath', "//input[@data-max-time='']"))[2].send_keys(start_date)
        end_date_element = "//input[@data-min-time='%s']" % start_date
        get_element(driver, ('xpath', end_date_element)).send_keys(end_date)
        get_elements(
            driver, ('xpath', "//div[@class='col-sm-6']/input[@placeholder='']"
                     ))[2].send_keys(project_name)
        get_element(driver,
                    ('xpath',
                     "//div[@class='col-sm-6']/textarea[@class='form-control']"
                     )).send_keys(information)
        get_elements(driver,
                     ('xpath', "//button[contains(text(),'完成')]"))[1].click()
        sleep(0.5)
        element = "//h4[contains(text(),'%s')]" % company_name

        assert is_element_present(driver, ('xpath', element))
    except Exception as e:
        print(e)
        bug_photo(driver)
        assert False
def basic_information(driver):
    sleep(3)
    try:
        get_element(driver,
                    ('xpath', "//div[@data-target='#mo-basic']")).click()
        get_element(
            driver,
            ('xpath', "//button[@class='btn btn-primary btn-sm']/i")).click()
        len_element = len(
            get_elements(driver, ('xpath', "//div[@id='selectWorkType']/div")))
        for i in range(1, len_element, 3):
            element = "//div[@id='selectWorkType']/div[%s]/div/div[1]" % i
            get_element(driver, ('xpath', element)).click()
            sleep(0.1)
        get_element(driver, ('xpath', "//a[contains(text(),'确定')]")).click()
        # 省
        len_province = len(
            get_elements(driver, ('xpath', "//div[12]/select/option")))
        province_element = "//div[12]/select/option[%s]" % str(
            random.randint(2, len_province))
        get_element(driver, ('xpath', province_element)).click()
        sleep(0.2)
        # 市
        len_city = len(
            get_elements(driver, ('xpath', "//div[13]/select/option")))
        city_element = "//div[13]/select/option[%s]" % str(
            random.randint(2, len_city))
        get_element(driver, ('xpath', city_element)).click()
        sleep(0.2)
        # 区
        len_district = len(
            get_elements(driver, ('xpath', "//div[14]/select/option")))
        district_element = "//div[14]/select/option[%s]" % str(
            random.randint(2, len_district))
        get_element(driver, ('xpath', district_element)).click()
        get_element(driver,
                    ('xpath', "//textarea[@type='text']")).send_keys('潘松区88号')
        get_elements(driver,
                     ('xpath', "//button[contains(text(),'保存')]"))[0].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