Ejemplo n.º 1
0
def testcase7551():
    fo = open("device.txt", "rt")
    lastingDevicename = fo.read()
    file = "C:\\download\\" + lastingDevicename
    options = borwserConfigure()
    global driver
    driver = webdriver.Chrome(chrome_options=options)
    from Page.indexPage import linuxindexPage
    linuxindexPage = linuxindexPage(driver)
    # 进入到选择device页
    linuxindexPage.clickNextButton()
    #输入设备名
    linuxindexPage.chooseDevice()
    #选择FW
    fw_select = driver.find_element_by_css_selector(
        "select[name='configurationViewModel.Devices[0].SelectedFirmware.Id']")
    Select(fw_select).select_by_index("1")

    set_table = driver.find_element_by_class_name('settings-table')
    td_content = set_table.find_elements_by_tag_name('tr')
    table_tr_number = len(td_content)

    i = 0
    while i < table_tr_number:
        flag = isElementExist(
            driver,
            "select[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
            + str(i) + "].SelectedValue']")
        if flag:
            setting = driver.find_element_by_css_selector(
                "select[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                + str(i) + "].SelectedValue']")
            if Select(setting):
                select = Select(setting)
                selectlen = len(select.options)
                Select(setting).select_by_index(
                    random.randint(1, selectlen - 1))
                i = i + 1
                continue
        elif isInputExist(
                driver,
                "input[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                + str(i) + "].SelectedValue']"):
            try:
                driver.find_element_by_css_selector(
                    "input[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                    + str(i) + "].SelectedValue']").send_keys('2021')
            except:
                i = i + 1
                continue
            i = i + 1
            continue
        else:
            i = i + 1
            continue
    #判断按钮是否可用
    nextButton = driver.find_element_by_xpath("//input[@value='NEXT >']")
    isNextButtonEnable = nextButton.is_enabled()
    if isNextButtonEnable == False:
        i = 0
        while i < table_tr_number:
            flag = isElementExist(
                driver,
                "select[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                + str(i) + "].SelectedValue']")
            if flag:
                setting = driver.find_element_by_css_selector(
                    "select[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                    + str(i) + "].SelectedValue']")
                if Select(setting):
                    i = i + 1
                    continue
            elif isInputExist(
                    driver,
                    "input[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                    + str(i) + "].SelectedValue']"):
                try:
                    driver.find_element_by_css_selector(
                        "input[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                        + str(i) + "].SelectedValue']").send_keys('2021')
                    i = i + 1
                    continue
                except Exception as e:
                    i = i + 1
                    continue
            elif isUploadButton(driver, "input[value='Upload']"):
                try:
                    driver.find_element_by_css_selector(
                        "input[id='configurationViewModel.Devices[0].SelectedFirmware.Settings[20].fileinputId']"
                    ).send_keys('C:\\Desktop\\Engage75_deskimg.bmp')
                    sleep(5)
                    i = i + 1
                    continue
                except Exception as e:
                    print(e)
            else:
                i = i + 1
                continue
    print(lastingDevicename + ' ' + sys._getframe().f_code.co_name +
          ' Configure finish')
    # #进入softphone配置页
    driver.find_element_by_xpath("//input[@value='NEXT >']").click()

    driver.find_element_by_xpath("//input[@value='NEXT >']").click()
    # 下载Summary
    driver.find_element_by_xpath("//input[@value='DOWNLOAD SUMMARY']").click()
    # 重命名summary文件
    sleep(5)
    summary = file + '\\summary.html'
    renamesummary = file + '\\7551.html'
    try:
        os.rename(summary, renamesummary)
        print(lastingDevicename + ' testcase7551 summary download successful')
        summary = file + '\\JabraXpressFiles.zip'
        renamesummary = file + '\\7551'
    except Exception as e:
        os.remove(renamesummary)
        os.rename(summary, renamesummary)
    # 返回到下载页
    driver.find_element_by_xpath("//input[@value='< PREVIOUS']").click()
    # 勾选同意协议
    driver.find_element_by_id('eulaOk').click()
    # 输入网址:
    driver.find_element_by_css_selector(
        "input[name='localServerUrl']").send_keys('http://my.gn.com/')
    # #点击下载
    driver.find_element_by_id('downloadZip').click()
    sleep(20)
    try:
        while os.path.exists(summary) == False:
            sleep(10)
        with zipfile.ZipFile(summary, "r") as zip_ref:
            zip_ref.extractall(file)
        summary = file + '\\Files_to_place_on_local_server'
        os.rename(summary, renamesummary)
        shutil.rmtree(file + '\\Files_to_install_on_end-user_computers')
        os.remove(file + '\\JabraXpressFiles.zip')
        os.remove(file + '\\readme.txt')
        print(lastingDevicename + ' testcase7551 download successful')
        print('\n')
        driver.close()
    except Exception as e:
        sleep(40)
        os.rename(summary, renamesummary)
        print('rename success')
        driver.close()
Ejemplo n.º 2
0
def testcase3969():
    fo = open("device.txt", "rt")
    lastingDevicename = fo.read()
    file = "C:\\download\\" + lastingDevicename
    options = borwserConfigure()
    global driver
    driver = webdriver.Chrome(chrome_options=options)
    from Page.indexPage import windowsPage
    windowsPage = windowsPage(driver)
    # 进入到选择device页
    windowsPage.clickNextButton()
    #输入Device
    windowsPage.chooseDevice()
    #设置protect=notprotect
    setting = driver.find_element_by_css_selector(
        "select[name='configurationViewModel.Devices[0].SelectedFirmware.Settings[0].SelectedValue']"
    )
    Select(setting).select_by_index("2")
    # 配置settings为随机项
    set_table = driver.find_element_by_class_name('settings-table')
    td_content = set_table.find_elements_by_tag_name('tr')
    table_tr_number = len(td_content)

    i = 1
    while i < table_tr_number:
        flag = isElementExist(
            driver,
            "select[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
            + str(i) + "].SelectedValue']")
        if flag:
            setting = driver.find_element_by_css_selector(
                "select[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                + str(i) + "].SelectedValue']")
            if Select(setting):
                select = Select(setting)
                selectlen = len(select.options)
                Select(setting).select_by_index(
                    random.randint(1, selectlen - 1))
                i = i + 1
                continue
        elif isInputExist(
                driver,
                "input[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                + str(i) + "].SelectedValue']"):
            try:
                driver.find_element_by_css_selector(
                    "input[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                    + str(i) + "].SelectedValue']").send_keys('2021')
            except:
                i = i + 1
                continue
            i = i + 1
            continue
        else:
            i = i + 1
            continue

    print(lastingDevicename + ' ' + sys._getframe().f_code.co_name +
          ' Configure finish')

    #判断按钮是否可用
    nextButton = driver.find_element_by_xpath("//input[@value='NEXT >']")
    isNextButtonEnable = nextButton.is_enabled()
    if isNextButtonEnable == False:
        i = 0
        while i < table_tr_number:
            flag = isElementExist(
                driver,
                "select[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                + str(i) + "].SelectedValue']")
            if flag:
                setting = driver.find_element_by_css_selector(
                    "select[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                    + str(i) + "].SelectedValue']")
                if Select(setting):
                    i = i + 1
                    continue
            elif isInputExist(
                    driver,
                    "input[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                    + str(i) + "].SelectedValue']"):
                try:
                    driver.find_element_by_css_selector(
                        "input[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                        + str(i) + "].SelectedValue']").send_keys('2021')
                    i = i + 1
                    continue
                except Exception as e:
                    i = i + 1
                    continue
            elif isUploadButton(driver, "input[value='Upload']"):
                try:
                    driver.find_element_by_css_selector(
                        "input[id='configurationViewModel.Devices[0].SelectedFirmware.Settings[20].fileinputId']"
                    ).send_keys('C:\\Desktop\\Engage75_deskimg.bmp')
                    sleep(5)
                    i = i + 1
                    continue
                except Exception as e:
                    print(e)
            else:
                i = i + 1
                continue
    # #进入softphone配置页
    driver.find_element_by_xpath("//input[@value='NEXT >']").click()
    #勾选下载JD
    driver.find_element_by_xpath("//input[@value='true']").click()
    ## 选择1个随机的Preferred softphone
    setting = driver.find_element_by_css_selector(
        "select[name='PcSoftwareViewModel.DeploymentOptionGroups[2].DeploymentOptions[19].Value']"
    )
    if Select(setting):
        select = Select(setting)
        selectlen = len(select.options)
        Select(setting).select_by_index(random.randint(1, selectlen - 1))
    #跳转到.msi下载页面
    driver.find_element_by_xpath("//input[@value='NEXT >']").click()
    #跳转到Summary下载页面
    driver.find_element_by_xpath("//input[@value='NEXT >']").click()
    # 下载Summary
    driver.find_element_by_xpath("//input[@value='DOWNLOAD SUMMARY']").click()
    # 重命名summary文件
    sleep(5)
    summary = file + '\\summary.html'
    renamesummary = file + '\\3969.html'
    try:
        os.rename(summary, renamesummary)
        print(lastingDevicename + ' testcase3969 summary download successful')
        summary = file + '\\JabraXPRESSx64.msi'
        renamesummary = file + '\\3969.msi'
    except Exception as e:
        os.remove(renamesummary)
        os.rename(summary, renamesummary)
        summary = file + '\\JabraXPRESSx64.msi'
        renamesummary = file + '\\3969.msi'
    # 返回到下载页
    driver.find_element_by_xpath("//input[@value='< PREVIOUS']").click()
    # 勾选同意协议
    driver.find_element_by_id('eulaOk').click()
    # #点击下载
    driver.find_element_by_id('download64bit').click()
    #调用重命名函数
    renameAndclose(driver, summary, renamesummary)
    print(lastingDevicename + ' testcase3969 download successful')
    print('\n')
Ejemplo n.º 3
0
def testcase4090():
    fo = open("device.txt", "rt")
    lastingDevicename = fo.read()
    file = "C:\\download\\" + lastingDevicename
    options = borwserConfigure()
    global driver
    driver = webdriver.Chrome(chrome_options=options)
    from Page.indexPage import windowsPage
    windowsPage = windowsPage(driver)
    # 进入到选择device页
    windowsPage.clickNextButton()
    #输入Device
    windowsPage.chooseDevice()
    #选择FW
    fw_select = driver.find_element_by_css_selector(
        "select[name='configurationViewModel.Devices[0].SelectedFirmware.Id']")
    Select(fw_select).select_by_index("1")
    #配置设置项为随机项
    set_table = driver.find_element_by_class_name('settings-table')
    td_content = set_table.find_elements_by_tag_name('tr')
    table_tr_number = len(td_content)

    i = 1
    while i < table_tr_number:
        flag = isElementExist(
            driver,
            "select[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
            + str(i) + "].SelectedValue']")
        if flag:
            setting = driver.find_element_by_css_selector(
                "select[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                + str(i) + "].SelectedValue']")
            if Select(setting):
                select = Select(setting)
                selectlen = len(select.options)
                Select(setting).select_by_index(
                    random.randint(1, selectlen - 1))
                default = "*"
                selectedValue = Select(setting).first_selected_option.text
                chooseNotDefault = default in selectedValue
                while chooseNotDefault:
                    Select(setting).select_by_index(
                        random.randint(1, selectlen - 1))
                    selectedValue = Select(setting).first_selected_option.text
                    chooseNotDefault = default in selectedValue
                i = i + 1
                continue
            elif isInputExist(
                    driver,
                    "input[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                    + str(i) + "].SelectedValue']"):
                getInputName = driver.find_element_by_css_selector(
                    "input[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                    + str(i) + "].SelectedValue']")
                nameornumber = getInputName.get_attribute('data-val-regex')
                if nameornumber == '[\s\S]':
                    try:
                        driver.find_element_by_css_selector(
                            "input[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                            + str(i) + "].SelectedValue']").send_keys(
                                'J2½§!"@#£$¤*%&/\<>[]()=?')
                        i = i + 1
                        continue
                    except:
                        i = i + 1
                        continue
                else:
                    try:
                        driver.find_element_by_css_selector(
                            "input[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                            + str(i) +
                            "].SelectedValue']").send_keys('1*#959932881')
                        i = i + 1
                        continue
                    except:
                        i = i + 1
                        continue
        else:
            i = i + 1
            continue
    #判断按钮是否可用
    nextButton = driver.find_element_by_xpath("//input[@value='NEXT >']")
    isNextButtonEnable = nextButton.is_enabled()
    if isNextButtonEnable == False:
        i = 0
        while i < table_tr_number:
            flag = isElementExist(
                driver,
                "select[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                + str(i) + "].SelectedValue']")
            if flag:
                setting = driver.find_element_by_css_selector(
                    "select[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                    + str(i) + "].SelectedValue']")
                if Select(setting):
                    i = i + 1
                    continue
            elif isInputExist(
                    driver,
                    "input[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                    + str(i) + "].SelectedValue']"):
                getInputName = driver.find_element_by_css_selector(
                    "input[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                    + str(i) + "].SelectedValue']")
                nameornumber = getInputName.get_attribute('data-val-regex')
                if nameornumber == '[\s\S]':
                    try:
                        driver.find_element_by_css_selector(
                            "input[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                            + str(i) + "].SelectedValue']").send_keys(
                                'J2½§!"@#£$¤*%&/\<>[]()=?')
                        i = i + 1
                        continue
                    except:
                        i = i + 1
                        continue
                else:
                    try:
                        driver.find_element_by_css_selector(
                            "input[name='configurationViewModel.Devices[0].SelectedFirmware.Settings["
                            + str(i) +
                            "].SelectedValue']").send_keys('1*#959932881')
                        i = i + 1
                        continue
                    except:
                        i = i + 1
                        continue
            elif isUploadButton(driver, "input[value='Upload']"):
                try:
                    driver.find_element_by_css_selector(
                        "input[id='configurationViewModel.Devices[0].SelectedFirmware.Settings[20].fileinputId']"
                    ).send_keys('C:\\Desktop\\Engage75_deskimg.bmp')
                    sleep(5)
                    i = i + 1
                    continue
                except Exception as e:
                    print(e)
            else:
                i = i + 1
                continue
    print(lastingDevicename + ' ' + sys._getframe().f_code.co_name +
          ' Configure finish')

    # #进入softphone配置页
    driver.find_element_by_xpath("//input[@value='NEXT >']").click()
    #勾选下载JD
    driver.find_element_by_xpath("//input[@value='true']").click()
    #跳转到.msi下载页面
    driver.find_element_by_xpath("//input[@value='NEXT >']").click()
    #跳转到Summary下载页面
    driver.find_element_by_xpath("//input[@value='NEXT >']").click()
    # 下载Summary
    driver.find_element_by_xpath("//input[@value='DOWNLOAD SUMMARY']").click()
    # 重命名summary文件
    sleep(5)
    summary = file + '\\summary.html'
    renamesummary = file + '\\4090.html'
    try:
        os.rename(summary, renamesummary)
        print(lastingDevicename + ' testcase4090 summary download successful')
        summary = file + '\\JabraXPRESSx64.msi'
        renamesummary = file + '\\4090.msi'
    except Exception as e:
        os.remove(renamesummary)
        os.rename(summary, renamesummary)
        summary = file + '\\JabraXPRESSx64.msi'
        renamesummary = file + '\\4090.msi'
    # 返回到下载页
    driver.find_element_by_xpath("//input[@value='< PREVIOUS']").click()
    # 勾选同意协议
    driver.find_element_by_id('eulaOk').click()
    # #点击下载
    driver.find_element_by_id('download64bit').click()
    #调用重命名函数
    renameAndclose(driver, summary, renamesummary)
    print(lastingDevicename + ' testcase4090 download successful')
    print('\n')