Ejemplo n.º 1
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
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)
Ejemplo n.º 3
0
def register_worker(phone_num):
    # driver.wait_activity(desired_caps['appWaitActivity'], 10)
    get_element(driver, ("accessibility_id", "新用户注册")).click()
    WebDriverWait(driver, 10).until(lambda x: x.find_element_by_id("新用户注册"))
    # driver.find_element_by_accessibility_id("新用户注册 ").click()
    sleep(3)
    driver.find_element_by_accessibility_id("我是工人").click()
    sleep(3)
    a = driver.contexts
    print(a)
    driver.switch_to.context(a[-1])
    driver.find_element_by_xpath(
        "//android.widget.EditText[@content-desc='请输入正确的帐号(手机号)']").send_keys(
            phone_num)
    sleep(3)
    driver.find_element_by_xpath(
        "//android.widget.Button[@content-desc='点击获取 ']").click()
    sleep(6)
    driver.find_element_by_accessibility_id("请输入校验码").send_keys("11111")
    driver.find_element_by_xpath(
        "//android.webkit.WebView[@content-desc='注册']/android.widget.EditText[3]"
    ).send_keys("123456")
    driver.find_element_by_xpath(
        "//android.webkit.WebView[@content-desc='注册']/android.widget.EditText[4]"
    ).send_keys("123456")
    driver.find_element_by_accessibility_id("立即注册 ").click()
    driver.find_element_by_accessibility_id("确定 ").click()
    sleep(3)
Ejemplo n.º 4
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
Ejemplo n.º 5
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
def upload_and_delete_file(driver):
    file_type_list = ('xlsx', 'docx', 'pdf', 'png', 'pptx', 'zip', 'jpg')
    # 随机选取一个文件夹
    file_type = random.choice(file_type_list)
    a = file_path(file_type)
    print(a)
    get_element(driver, ('xpath', "//input[@type='file']")).send_keys(a)
    element = "//p[contains(text(),'%s.%s')]" % (file_type, file_type)
    #  判断文件状态
    assert is_element_present_3s(driver, ('xpath', element),
                                 6), "上传%s文件失败" % file_type
    sleep(0.5)
    #  删除文件状态
    if is_element_present_3s(driver, ('xpath', element)):
        # 右击文件
        sleep(1)
        ActionChains(driver).context_click(
            get_element(driver, ('xpath', element))).perform()
        sleep(0.3)
        get_element(driver, ('xpath', "//a[contains(text(),'删除')]")).click()
    else:
        pass
    if is_element_present_3s(driver, ('xpath', element)):
        print('删除失败')
        assert False
    else:
        print('删除成功')
Ejemplo n.º 7
0
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
Ejemplo n.º 8
0
def QA_standard(driver, switch):
    # 质量标准
    if switch:
        qa_element = "//div[@id='sub_contract']/form/div[6]/div[2]/div/div/select/option[%s]" % str(random.randint(2, 3))
        get_element(driver, ('xpath', qa_element)).click()
    else:
        pass
Ejemplo n.º 9
0
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号')
        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_now_dates())
        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='必填']")[1].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='必填']")[2].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 agree_with_permissions(driver):
    # 小米处理权限的方式 全部允许
    if is_element_present_3s(driver, ('id', 'android:id/button1'), 3):
        i = 0
        while 1:
            get_element(driver, ('id', "android:id/button1")).click()
            sleep(1)
            if i == 3:
                break
            i += 1
Ejemplo n.º 11
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
Ejemplo n.º 12
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])
Ejemplo n.º 13
0
def the_contract_comes_into_effect(driver, switch):
    #   合同生效
    if switch:
        # 选择城市
        sub_select_city_choice(driver)
        get_element(driver, ('xpath', "//input[@placeholder='选择日期不得晚于当前日期']")).send_keys(get_now_dates())
        conditions_element = "//div[@id='sub_contract']/form/div[8]/div[2]/div[3]/div/select/option[%d]" % random.randint(
            2, 3)
        get_element(driver, ('xpath',  conditions_element)).click()
    else:
        pass
Ejemplo n.º 14
0
def forget_password(driver, mobile, new_password, code):
    driver.find_element_by_xpath("//button[contains(text(),'登录')]").click()
    sleep(0.5)
    driver.find_element_by_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_elements(driver,
                 ('xpath', "//span[contains(text(),'点击获取验证码')]"))[1].click()
    # 输入验证码
    get_element(
        driver,
        ('xpath',
         ".//*[@id='forgetPass']/form/div[4]/div[2]/input")).send_keys(code)
    sleep(0.5)
    driver.find_elements_by_xpath(
        "//button[contains(text(),'重置密码')]")[1].click()
    sleep(6)
    try:
        web_login(driver, mobile, new_password)
        print('重置密码,且登陆成功')
    except Exception as e:
        print(e)
        print("重置密码失败")
        assert False
def handle_permissions_popovers(driver):
    if is_element_present_3s(
            driver,
        ('xpath', "//android.widget.TextView[@text='第 1 项权限(共 2 项)']")):
        get_element(driver,
                    ('xpath', "//android.widget.Button[@text='允许']")).click()
        sleep(1)
        if is_element_present_3s(
                driver,
            ('xpath', "//android.widget.TextView[@text='第 2 项权限(共 2 项)']")):
            get_element(
                driver,
                ('xpath', "//android.widget.Button[@text='允许']")).click()
        else:
            pass
    else:
        pass
Ejemplo n.º 16
0
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
Ejemplo n.º 17
0
def verify_worker_exists(driver, workers_name):
    #  平台运维验证工人是否存在
    try:
        into_one_level(driver, '运维面板')
        sleep(0.5)
        into_two_level(driver, '注册用户管理')
        # 查询工人姓名
        get_element(
            driver,
            ('xpath', "//input[@placeholder='工人姓名']")).send_keys(workers_name)
        # 搜索
        get_element(driver,
                    ('xpath', "//button[contains(text(),'搜索')]")).click()
        if is_element_present_3s(driver, ('xpath', "//tbody/tr/td[2]/a"), 3):
            get_element(driver, ('xpath', "//tbody/tr/td[2]/a")).click()
            sleep(1)
            role = get_element(
                driver,
                ('xpath', "//*[@id='basic']/div/div[2]/div[4]/div/span")).text
            print(role)
            assert role == '签约工人'
        else:
            print('签订终止合同工人的合同失败')
            assert False
        sleep(1.5)
    except Exception as e:
        print(e)
        bug_photo(driver)
        assert False
Ejemplo n.º 18
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
Ejemplo n.º 19
0
def change_phone_number(driver, mobile, new_mobile, password):
    # 更换手机号
    get_element(driver, ('id', 'dropdownMenu-set')).click()
    get_element(
        driver,
        ('xpath',
         "//a[@role='menuitem' and contains(text(),'账号设置') ]")).click()
    get_element(driver, ('xpath', "//a[contains(text(),'更改手机号')]")).click()
    sleep(0.5)
    get_element(
        driver,
        ('xpath', "//input[@placeholder='请输入原手机号码']")).send_keys(mobile)
    get_elements(
        driver,
        ('xpath', "//span[contains(text(),'点击获取验证码') and @class='get-btn' ]"
         ))[0].click()
    get_elements(
        driver,
        ('xpath', "//div[@class='col-sm-5']/input"))[0].send_keys('11111')
    get_elements(driver,
                 ('xpath', "//button[contains(text(),'下一步')]"))[0].click()
    sleep(2)
    get_element(
        driver,
        ('xpath', "//input[@placeholder='请输入新手机号码']")).send_keys(new_mobile)
    get_elements(
        driver,
        ('xpath', "//span[contains(text(),'点击获取验证码') and @class='get-btn' ]"
         ))[1].click()
    get_elements(
        driver,
        ('xpath', "//div[@class='col-sm-5']/input"))[1].send_keys('11111')
    get_elements(driver,
                 ('xpath', "//button[contains(text(),'下一步')]"))[1].click()
    sleep(6)
    try:
        web_login(driver, new_mobile, password)
        print('重置密码,且登陆成功')
    except Exception as e:
        print(e)
        print("重置密码失败")
        bug_photo(driver)
        assert False
Ejemplo n.º 20
0
 def test_01_SetManager(self):
     # 设置项目经理
     # 先获取职员当前是什么职位,然后对其进行设置角色,最后还原他的初始职位
     self.browser.find_element_by_xpath(
         "//a[contains(text(),'职员管理')]").click()
     num = self.browser.find_elements_by_class_name(
         "bs-checkbox>input")  # 获取当前页的所有选中框
     random_num = random.randint(1, len(num))
     # 被选择人的姓名
     name_element = ".//*[@id='company-staff-table']/tbody/tr[%s]/td[2]/a" % random_num
     name = self.browser.find_element_by_xpath(name_element).text
     print(name)
     information_element = ".//*[@id='company-staff-table']/tbody/tr[%s]/td[2]/a" % random_num
     self.browser.find_element_by_xpath(information_element).click()
     get_role = self.browser.find_element_by_xpath(
         ".//*[@id='basic']/div/div[2]/div[5]/div/span").text
     print(get_role)
     # 关闭按钮
     self.browser.find_element_by_class_name(
         "layui-layer-ico.layui-layer-close.layui-layer-close1").click()
     # 选中人
     people_element = ".//*[@id='company-staff-table']/tbody/tr[%s]/td[1]/input" % random_num
     for i in range(1, 6):
         self.browser.find_element_by_xpath(people_element).click()
         self.browser.find_element_by_xpath(
             "//button[contains(text(),'角色设置')]").click()  # 点击角色设置
         role_element = ".//*[@id='lay-role-set']/div[2]/div[2]/select/option[%d]" % i
         get_element(self.browser, ('xpath', role_element)).click()
         sleep(0.5)
         self.browser.find_element_by_xpath(
             "//a[contains(text(),'确定')]").click()
         sleep(0.5)
     self.browser.find_element_by_xpath(people_element).click()
     self.browser.find_element_by_xpath(
         "//button[contains(text(),'角色设置')]").click()  # 点击角色设置
     old_role_element = "//option[contains(text(),'%s')]" % get_role
     self.browser.find_elements_by_xpath(old_role_element)[1].click()
     self.browser.find_element_by_xpath(
         "//a[contains(text(),'确定')]").click()
     assert self.browser.find_element_by_class_name(
         "layui-layer-content.layui-layer-padding").text == '成功'
Ejemplo n.º 21
0
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
Ejemplo n.º 22
0
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))
Ejemplo n.º 23
0
def dispute_resolution(driver, switch):
    # 争议解决方式
    if switch:
        a = random.randint(1, 2)
        if a == 1:
            get_element(driver, ('xpath', "//div[@id='arg']/input[@value='仲裁']")).click()
            get_element(driver, ('xpath', "//textarea[@placeholder='请输入仲裁委员会地址']")).send_keys('南门保安室')
        elif a == 2:
            get_element(driver, ('xpath', "//div[@id='arg']/input[@value='起诉']")).click()
    else:
        pass
Ejemplo n.º 24
0
def android_logout(driver):
    try:
        get_element(driver,
                    ('id', 'com.zld.zld_face_rec_app:id/ll_account')).click()
        get_element(
            driver,
            ('id', 'com.zld.zld_face_rec_app:id/btn_sign_out')).click()
        get_element(
            driver,
            ('id', 'com.zld.zld_face_rec_app:id/tv_positive_btn')).click()
        assert is_element_present_3s(
            driver, ('id', 'com.zld.zld_face_rec_app:id/et_name')), '登出失败'
    except Exception as e:
        print(e)
Ejemplo n.º 25
0
def android_login(driver, username, password):
    try:
        get_element(
            driver,
            ('id', "com.zld.zld_face_rec_app:id/et_name")).send_keys(username)
        get_element(
            driver,
            ('id', "com.zld.zld_face_rec_app:id/et_pwd")).send_keys(password)
        get_element(driver,
                    ('id', "com.zld.zld_face_rec_app:id/btn_login")).click()
        # 通过定位 点击第一个班组
        sleep(2)
        driver.tap([(0, 231), (1080, 420)], 100)
        sleep(1)
        agree_with_permissions(driver)
        sleep(1)
        assert is_element_present_3s(
            driver, ('id', "com.zld.zld_face_rec_app:id/fl_message")), '登陆失败'
    except Exception as e:
        print(e)
        bug_photo(driver)
        assert False
Ejemplo n.º 26
0
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
Ejemplo n.º 27
0
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
Ejemplo n.º 28
0
def add_education_experience(driver):
    sleep(3)
    try:
        if is_element_present(driver,
                              ('xpath', "//i[@data-target='#mo-edu-add']")):
            get_element(driver,
                        ('xpath', "//i[@data-target='#mo-edu-add']")).click()
        else:
            get_element(driver,
                        ('xpath', "//div[@data-target='#mo-edu']")).click()
            get_element(driver, (
                'xpath',
                "//div[@data-target='#mo-edu-add' and contains(text(),'添加教育经历')]"
            )).click()
        work_type = "//div[1]/div[1]/select[@class='form-control']/option[%s]" % str(
            random.randint(1, 10))
        get_elements(driver, ('xpath', work_type))[1].click()
        get_element(driver,
                    ('xpath', "//input[@placeholder='专业']")).send_keys('建筑')
        start_dates = get_pass_dates(random.randint(200, 300))
        end_dates = get_pass_dates(random.randint(50, 199))
        setting_input_time(driver)
        get_element(driver, (
            'xpath',
            "//input[@placeholder='' and @class='form-control input-sm form-date val-start-date']"
        )).send_keys(start_dates)
        get_elements(driver, (
            'xpath',
            "//input[@placeholder='' and @class='form-control input-sm form-date']"
        ))[-1].send_keys(end_dates)
        school_name = getCompanyName()[2:-4] + '学校'
        get_element(
            driver,
            ('xpath', "//input[@placeholder='学校名称']")).send_keys(school_name)
        get_elements(driver,
                     ('xpath', "//button[contains(text(),'完成')]"))[2].click()
        title = school_name + '(' + start_dates + '——' + end_dates + ')'
        element = "//h4[contains(text(),'%s')]" % title
        assert is_element_present(driver, ('xpath', element))
    except Exception as e:
        print(e)
        bug_photo(driver)
        assert False
Ejemplo n.º 29
0
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(
                getPeopleName())
        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
Ejemplo n.º 30
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