Пример #1
0
def get_1st_row_on_gui(driver):
    table_i = (
        By.XPATH,
        "//div[@class='table']/div/div/table[@class='ebTable elWidgets-Table-body']"
    )
    table = find_single_widget(driver, 10, table_i)

    name_i = (By.XPATH, "./thead/tr/th")
    column_name = find_all_widgets(table, 10, name_i)

    value_i = (By.XPATH, "./tbody/tr[1]/td")
    find_single_widget(table, 10, value_i).click()
    column_value = find_all_widgets(table, 10, value_i)

    name_list = []
    value_list = []

    if (len(column_name) != len(column_value)):
        logCommon.error("Alarm data mismatched on gui")

    for name in column_name:
        alarm_name = name.text.encode('utf-8')
        name_list.append(alarm_name)
    del name_list[0]

    for value in column_value:
        filed_value = value.text.encode('utf-8')
        value_list.append(filed_value)
    del value_list[0]

    alarm_gui = dict(zip(name_list, value_list))
    del alarm_gui["告警代码"]
    del alarm_gui["类型代码"]
    del alarm_gui["类型编号"]
    return alarm_gui
Пример #2
0
def to_tab_by_ne_type(driver, ne_type, logger):
    ne_type = ne_type.strip().upper()
    tab_index = 1
    if 'PGW' == ne_type:
        tab_index = 1
    elif 'SGW' == ne_type:
        tab_index = 2
    elif 'SGSN' == ne_type:
        tab_index = 3
    elif 'MME' == ne_type:
        tab_index = 4
    elif 'SBC' == ne_type:
        tab_index = 5
    elif 'OCGAS' == ne_type:
        tab_index = 6

    identifier = (By.XPATH, "//div[@class='ebTabs-tabArea']/div[" + str(tab_index) + "]")
    find_single_widget(driver, 10, identifier).click()

    # wait for the notification, maximum 10 seconds
    try:
        identifier = (By.XPATH, "//div[@class='noti']/div")
        WebDriverWait(driver, 10).until(EC.presence_of_element_located(identifier))
    except TimeoutException:
        pass
Пример #3
0
def to_tab_by_ne_type(driver, ne_type, logger):
    ne_type = ne_type.strip().upper()
    tab_index = 1
    if 'PGW' == ne_type:
        tab_index = 1
    elif 'SGW' == ne_type:
        tab_index = 2
    elif 'SGSN' == ne_type:
        tab_index = 3
    elif 'MME' == ne_type:
        tab_index = 4
    elif 'SBC' == ne_type:
        tab_index = 5
    elif 'OCGAS' == ne_type:
        tab_index = 6

    identifier = (By.XPATH,
                  "//div[@class='ebTabs-tabArea']/div[" + str(tab_index) + "]")
    find_single_widget(driver, 10, identifier).click()

    # wait for the notification, maximum 10 seconds
    try:
        identifier = (By.XPATH, "//div[@class='noti']/div")
        WebDriverWait(driver,
                      10).until(EC.presence_of_element_located(identifier))
    except TimeoutException:
        pass
Пример #4
0
def select_given_ne_name(driver, ne_name):
    identifier = (By.XPATH, "//div[@class='pmcommonarea']/div/div[2]/div[1]/div[2]/input")
    input_ne_name = find_single_widget(driver, 10, identifier)
    if not '' == input_ne_name.get_attribute('value').strip():
        input_ne_name.click()
        find_single_widget(driver, 10, (By.ID, "btnAllLeft")).click()
    else:
        input_ne_name.click()

    id_table_candidate = (By.XPATH, "//div[@class='ebLayout-candidateEnbs']/div[2]/div/div[3]/div/div/div/table")
    table_candidate = find_single_widget(driver, 20, id_table_candidate)

    id_input_search = (By.XPATH, ".//thead/tr[2]/th[2]/input")
    candi_input = find_single_widget(table_candidate, 10, id_input_search)
    candi_input.clear()
    candi_input.send_keys(ne_name.strip())
    time.sleep(1.0)

    id_checkbox = (By.XPATH, ".//tbody/tr[1]/td[1]/div/div/input")
    left_checkbox = find_single_widget(table_candidate, 10, id_checkbox)
    if not left_checkbox.is_selected():
        left_checkbox.click()

    # select to right
    id_arrow_to_right = (By.ID, "btnRight")
    find_single_widget(driver, 10, id_arrow_to_right).click()
    # time.sleep(5.0)

    # close select ne dialog
    id_btn_choose_ne = (By.CLASS_NAME, "choose")
    find_single_widget(driver, 10, id_btn_choose_ne).click()
Пример #5
0
def check_in_correct_pm_page(driver):
    '''
    This function works on the beginning editions and has been abandoned.
    :param driver:
    :return:
    '''
    id_search_btn = (By.ID, "idBtn-search")
    b_validate = False
    try:
        find_single_widget(driver, 10, id_search_btn)
        b_validate = True
    except TimeoutException as e:
        # page not loaded
        return False
    if b_validate:
        # check if in the correct page
        # id_navi = identifier = (By.XPATH, "//div[@class='ebLayout-Navigation']/div")
        # navi = find_single_widget(driver, 10, id_navi)
        id_divs = identifier = (By.XPATH, "//div[@class='ebLayout-Navigation']/div/div")
        children_divs = find_all_widgets(driver, 20, id_divs)
        str_last_navi = find_single_widget(children_divs[-1], 10, (By.XPATH, ".//a")).get_attribute('innerHTML').\
            encode('utf-8').strip()
        # logger.info(children_divs[-2].get_attribute('innerHTML').encode('utf-8'))
        lis = find_all_widgets(children_divs[-2], 10, (By.XPATH, ".//div/ul/li"))
        for li in lis:
            str_a_li = find_single_widget(li, 10, (By.XPATH, ".//a")).get_attribute('innerHTML').encode('utf-8').strip()
            if str_last_navi == str_a_li:
                return True
        # current page not in parent navigation
        return False
Пример #6
0
def get_1st_row_on_gui(driver):
    table_i = (By.XPATH,"//div[@class='table']/div/div/table[@class='ebTable elWidgets-Table-body']")
    table=find_single_widget(driver,10,table_i)

    name_i=(By.XPATH,"./thead/tr/th")
    column_name = find_all_widgets(table,10,name_i)

    value_i = (By.XPATH,"./tbody/tr[1]/td")
    find_single_widget(table,10,value_i).click()
    column_value = find_all_widgets(table,10,value_i)

    name_list=[]
    value_list=[]

    if(len(column_name) != len(column_value)):
        logCommon.error("Alarm data mismatched on gui")

    for name in column_name:
        alarm_name = name.text.encode('utf-8')
        name_list.append(alarm_name)
    del name_list[0]

    for value in column_value:
        filed_value = value.text.encode('utf-8')
        value_list.append(filed_value)
    del value_list[0]

    alarm_gui=dict(zip(name_list,value_list))
    del alarm_gui["告警代码"]
    del alarm_gui["类型代码"]
    del alarm_gui["类型编号"]
    return alarm_gui
Пример #7
0
def check_in_correct_pm_page(driver):
    '''
    This function works on the beginning editions and has been abandoned.
    :param driver:
    :return:
    '''
    id_search_btn = (By.ID, "idBtn-search")
    b_validate = False
    try:
        find_single_widget(driver, 10, id_search_btn)
        b_validate = True
    except TimeoutException as e:
        # page not loaded
        return False
    if b_validate:
        # check if in the correct page
        # id_navi = identifier = (By.XPATH, "//div[@class='ebLayout-Navigation']/div")
        # navi = find_single_widget(driver, 10, id_navi)
        id_divs = identifier = (By.XPATH,
                                "//div[@class='ebLayout-Navigation']/div/div")
        children_divs = find_all_widgets(driver, 20, id_divs)
        str_last_navi = find_single_widget(children_divs[-1], 10, (By.XPATH, ".//a")).get_attribute('innerHTML').\
            encode('utf-8').strip()
        # logger.info(children_divs[-2].get_attribute('innerHTML').encode('utf-8'))
        lis = find_all_widgets(children_divs[-2], 10,
                               (By.XPATH, ".//div/ul/li"))
        for li in lis:
            str_a_li = find_single_widget(
                li, 10,
                (By.XPATH,
                 ".//a")).get_attribute('innerHTML').encode('utf-8').strip()
            if str_last_navi == str_a_li:
                return True
        # current page not in parent navigation
        return False
Пример #8
0
def wait_noti_widget_show(driver, wait_time=10):
    id_div = (By.XPATH, "//div[@class='noti']/div")
    try:
        find_single_widget(driver, wait_time, id_div)
        test.info('Query result notification shown up.')
    except TimeoutException:
        test.warning('Query result notification did not shown up, case may or may not fail later.')
Пример #9
0
def init_and_search(driver,nename):
    logCommon.info("Query alarm for NE: " + nename + "...")
    selected_given_nename(driver,nename)
    search_btn = find_single_widget(driver, 10, (By.XPATH,"//button[@id='idBtn-search']"))
    search_btn.click()
    tips = find_single_widget(driver,10,(By.XPATH,"//div[@class='tip']")).get_attribute('innerHTML').encode('utf-8')
    if tips:
        logCommon.info("Alarm queried successfully")
Пример #10
0
def check_ne_exist_by_type(driver, ne_type, ne_ip, page_no=20):
    # note there is another way to check if NE with certain IP exist, that is connect to the server's database and
    # check the NES data table
    id_table = (By.XPATH,
                "//div[@id='dv1']/div[2]/div/div/div[3]/div/div/div/table")
    table = find_single_widget(driver, 10, id_table)

    id_page = (By.XPATH, "//div[@id='dv1']/div[2]/div/div/div[2]/div/input")
    pages = find_single_widget(driver, 10, id_page)
    pages.clear()
    pages.send_keys(page_no)
    ActionChains(driver).key_down(Keys.ENTER).key_up(Keys.ENTER).perform()

    # set ne type
    # id_type = (By.XPATH, "//div[@id='dv1']/div[2]/div/div/div[3]/div/div/div/table/thead/tr[2]/th[2]/input")
    # w_ne_type = find_single_widget(driver, 10, id_type)
    # w_ne_type.clear()
    # w_ne_type.send_keys(ne_type)

    id_trs = (By.XPATH, ".//tbody/tr")
    try:
        trs = find_all_widgets(table, 20, id_trs)
        is_has_pair_nes = False
        for tr in trs:
            # gui_type = tr.get_attribute('innerHTML').encode('utf-8')
            gui_ne_name = find_single_widget(
                tr, 10,
                (By.XPATH,
                 ".//td[1]")).get_attribute('innerHTML').encode('utf-8')
            gui_ne_type = find_single_widget(
                tr, 10,
                (By.XPATH,
                 ".//td[2]")).get_attribute('innerHTML').encode('utf-8')

            tr.click()
            if wait_until_text_shown_up(driver, 10, (By.ID, "i_nename"),
                                        gui_ne_name):
                gui_ip = find_single_widget(driver, 10, (By.ID, "i_neip"))
                if ne_ip == gui_ip.get_attribute('value').encode(
                        'utf-8').strip():
                    if ne_type == gui_ne_type:
                        # NE with same ip and same type exit
                        return 1, gui_ne_name
                    else:
                        if is_pair_nes(gui_ne_type.upper(), ne_type.upper()):
                            # this means that there is a pair NE with same IP exist, but we can still add a NE
                            # but will check if NE with the same type & same IP exist
                            is_has_pair_nes = True
                        else:
                            # this means a NE with different type but the same IP already exist.
                            return 2, gui_ne_name
        if is_has_pair_nes:
            return 0, None
        # the ip that we want to add does not exist
        return -1, None
    except Exception as e:
        # the ip that we want to add does not exist
        return -2, None
Пример #11
0
def to_second_page(driver, logger):
    id_next_page = (By.XPATH, "//div[@class='page']/ul/li[3]")
    pager = find_single_widget(driver, 10, id_next_page)
    # driver.execute_script("arguments[0].scrollIntoView(true);", tds[12])
    driver.execute_script("arguments[0].scrollIntoView(true);", pager)
    pager.click()
    # wait for the notification, maximum 10 seconds
    id_body_date = (By.XPATH, "//div[@class='ebTabs']/div[2]/div/div/div/div/table/tbody")
    find_single_widget(driver, 10, id_body_date)
Пример #12
0
def wait_noti_widget_show(driver, wait_time=10):
    id_div = (By.XPATH, "//div[@class='noti']/div")
    try:
        find_single_widget(driver, wait_time, id_div)
        test.info('Query result notification shown up.')
    except TimeoutException:
        test.warning(
            'Query result notification did not shown up, case may or may not fail later.'
        )
Пример #13
0
def to_second_page(driver, logger):
    id_next_page = (By.XPATH, "//div[@class='page']/ul/li[3]")
    pager = find_single_widget(driver, 10, id_next_page)
    # driver.execute_script("arguments[0].scrollIntoView(true);", tds[12])
    driver.execute_script("arguments[0].scrollIntoView(true);", pager)
    pager.click()
    # wait for the notification, maximum 10 seconds
    id_body_date = (
        By.XPATH, "//div[@class='ebTabs']/div[2]/div/div/div/div/table/tbody")
    find_single_widget(driver, 10, id_body_date)
Пример #14
0
def init_and_search(driver, nename):
    logCommon.info("Query alarm for NE: " + nename + "...")
    selected_given_nename(driver, nename)
    search_btn = find_single_widget(driver, 10,
                                    (By.XPATH, "//button[@id='idBtn-search']"))
    search_btn.click()
    tips = find_single_widget(
        driver, 10,
        (By.XPATH,
         "//div[@class='tip']")).get_attribute('innerHTML').encode('utf-8')
    if tips:
        logCommon.info("Alarm queried successfully")
Пример #15
0
def check_me_single_row(driver, id_table, index_row, ne_type, dict_counters,
                        rows_of_page, list_headers, me_types):
    test.info('Start to check ME row: ' + str(index_row))

    make_sure_is_correct_page(driver, index_row, rows_of_page)
    try:
        gui_index_row = rows_of_page if 0 == index_row % rows_of_page else index_row % rows_of_page
        id_tr = (By.XPATH, ".//tbody/tr[" + str(gui_index_row) + "]")
        table = find_single_widget(driver, 10, id_table)
        time.sleep(.5)
        tr = find_single_widget(table, 10, id_tr)
        gui_str_time = find_single_widget(
            tr, 10,
            (By.XPATH, ".//td[2]")).get_attribute('innerHTML').encode('utf-8')
        gui_time = datetime.strptime(gui_str_time.strip(), "%Y-%m-%d %H:%M")
        except_counter_id = str(gui_time.minute)

        # id_lic_name = (By.XPATH, ".//td[3]")
        # lic_name = find_single_widget(tr, 5, id_lic_name).get_attribute('innerHTML').encode('utf-8')

        list_row = dict_counters[except_counter_id].split(',')
        list_types = me_types['counter_types'].split(',')
        for i in range(len(list_row)):
            try:
                id_counter = (By.XPATH, ".//td[" + str(i + 3) + "]")
                gui_counter = find_single_widget(
                    tr, 5,
                    id_counter).get_attribute('innerHTML').encode('utf-8')
                # i_gui_counter = int(gui_counter) if 'int' == list_types[i].lower().strip()
                if 'int' == list_types[i].lower().strip():
                    i_gui_counter = int(gui_counter)
                    i_expected = int(list_row[i].strip())
                elif 'float' == list_types[i].lower().strip():
                    i_gui_counter = float(gui_counter)
                    i_expected = float(list_row[i].strip())
                else:
                    test.error('Unknown counter type of me counters.')
            except Exception as e:
                i_gui_counter = None
            if i_expected == i_gui_counter:
                msg = list_headers[1] + ": " + gui_str_time.strip() + ",\t" + "; " + list_headers[i + 2] + ", GUI is " \
                      + str(i_gui_counter) + ",\tExpected is " + str(list_row[i]) + "."

                test.passed(msg)
            else:
                msg = list_headers[1] + ": " + gui_str_time.strip() + ",\t" + "; " + list_headers[i + 2] + ", GUI is " \
                      + str(i_gui_counter) + ",\tExpected is " + str(list_row[i]) + "."

                test.failed(msg)
        return gui_time
    except Exception as e:
        test.error("Test failed, ERROR: " + str(e))
Пример #16
0
def to_pm_management_page(driver):
    '''
    This function has been abandoned.
    :param driver:
    :return:
    '''
    test.info('To the PmManagement page...')

    identifier = (By.XPATH, "//div[@class='ebLayout-Navigation']/div/div[1]/span")
    find_single_widget(driver, 10, identifier).click()

    identifier = (By.XPATH, "//div[@class='ebBreadcrumbs-list']/ul/li[3]/a")
    find_single_widget(driver, 10, identifier).click()
Пример #17
0
def selected_given_nename(driver,nename):
    ne_param = find_single_widget(driver,10,(By.XPATH,"//input[@class='ebInputNe']"))
    if ne_param.get_attribute('value'):
        ne_param.click()
        find_single_widget(driver, 10, (By.XPATH,"//div[@id='btnAllLeft']")).click()
    else:
        ne_param.click()
        
    input_ne = find_single_widget(driver,10,(By.XPATH,"//table[@class='ebTable elWidgets-Table-body']/thead/tr[2]/th[2]/input"))
    input_ne.clear()
    input_ne.send_keys(nename)
    time.sleep(1)
    
    found_ne=find_single_widget(driver, 10, (By.XPATH,"//table[@class='ebTable elWidgets-Table-body']/tbody/tr"))
    
    if found_ne:
        ne_check_box = find_single_widget(found_ne, 10, (By.XPATH,"./td/div/div/input"))
        if not ne_check_box.is_selected():
            ne_check_box.click()
    else:
        logCommon.error("the given nename: " + nename + " not found")
    
    right_arrow = find_single_widget(driver, 10,(By.XPATH,"//div[@id='btnRight']"))
    right_arrow.click()
    
    confirm_btn = find_single_widget(driver,10,(By.XPATH,"//div[@class='choose']/button"))
    confirm_btn.click()
Пример #18
0
def wait_until_pm_date_show_up(driver, ne_name, wait_time=720):
    select_given_ne_name(driver, ne_name)
    end_time = datetime.now() + timedelta(seconds=wait_time)
    while datetime.now() < end_time:
        id_query_btn = (By.ID, "idBtn-search")
        find_single_widget(driver, 10, id_query_btn).click()
        id_body_date = (By.XPATH, "//div[@class='ebTabs']/div[2]/div/div/div/div/table/tbody")
        try:
            find_single_widget(driver, 10, id_body_date)
            test.passed('Successfully found the PM datas.')
            return
        except TimeoutException:
            pass
    test.error('Wait for ' + str(wait_time) + ' seconds but cannot find any PM datas.')
Пример #19
0
def to_pm_management_page(driver):
    '''
    This function has been abandoned.
    :param driver:
    :return:
    '''
    test.info('To the PmManagement page...')

    identifier = (By.XPATH,
                  "//div[@class='ebLayout-Navigation']/div/div[1]/span")
    find_single_widget(driver, 10, identifier).click()

    identifier = (By.XPATH, "//div[@class='ebBreadcrumbs-list']/ul/li[3]/a")
    find_single_widget(driver, 10, identifier).click()
Пример #20
0
def init_and_search(driver, ne_name, end_time=None, start_time=None):
    # select the given nename
    select_given_ne_name(driver, ne_name)

    # select the correct time
    if end_time is not None:
        test.info('Query end time point set to: ' +
                  end_time.strftime('%H%M%S'))
        id_end_time = (By.XPATH, "//div[@class='endtime']/div/span/input")
        find_single_widget(driver, 10, id_end_time).click()
        set_time_for_query(driver, end_time)

    if start_time is not None:
        test.info('Query start time point set to: ' +
                  start_time.strftime('%H%M%S'))
        id_start_time = (By.XPATH, "//div[@class='starttime']/div/span/input")
        find_single_widget(driver, 10, id_start_time).click()
        set_time_for_query(driver, start_time)

    # click the query button
    id_query_btn = (By.ID, "idBtn-search")
    find_single_widget(driver, 10, id_query_btn).click()

    # wait for the notification, maximum 20 seconds
    id_body_date = (
        By.XPATH, "//div[@class='ebTabs']/div[2]/div/div/div/div/table/tbody")
    find_single_widget(driver, 20, id_body_date)
Пример #21
0
def make_sure_in_pm_page(driver):
    # btn id: ebBtnSearch
    id_btn_interface = (By.ID, 'ebBtnSearch')
    try:
        find_single_widget(driver, 5, id_btn_interface)
        test.error('Page redirect to the interface management page, critical error!')
    except TimeoutException:
        id_query_btn = (By.ID, "idBtn-search")
        try:
            pm_query_btn = find_single_widget(driver, 10, id_query_btn)
            if pm_query_btn:
                test.passed('Found the query button of PM Management page, check passed.')
        except TimeoutException:
            test.failed('Cannot find the query button of PM Management page.')
Пример #22
0
def check_ne_exist_by_type(driver, ne_type, ne_ip, page_no=20):
    # note there is another way to check if NE with certain IP exist, that is connect to the server's database and
    # check the NES data table
    id_table = (By.XPATH, "//div[@id='dv1']/div[2]/div/div/div[3]/div/div/div/table")
    table = find_single_widget(driver, 10, id_table)

    id_page = (By.XPATH, "//div[@id='dv1']/div[2]/div/div/div[2]/div/input")
    pages = find_single_widget(driver, 10, id_page)
    pages.clear()
    pages.send_keys(page_no)
    ActionChains(driver).key_down(Keys.ENTER).key_up(Keys.ENTER).perform()

    # set ne type
    # id_type = (By.XPATH, "//div[@id='dv1']/div[2]/div/div/div[3]/div/div/div/table/thead/tr[2]/th[2]/input")
    # w_ne_type = find_single_widget(driver, 10, id_type)
    # w_ne_type.clear()
    # w_ne_type.send_keys(ne_type)

    id_trs = (By.XPATH, ".//tbody/tr")
    try:
        trs = find_all_widgets(table, 20, id_trs)
        is_has_pair_nes = False
        for tr in trs:
            # gui_type = tr.get_attribute('innerHTML').encode('utf-8')
            gui_ne_name = find_single_widget(tr, 10, (By.XPATH, ".//td[1]")).get_attribute('innerHTML').encode('utf-8')
            gui_ne_type = find_single_widget(tr, 10, (By.XPATH, ".//td[2]")).get_attribute('innerHTML').encode('utf-8')

            tr.click()
            if wait_until_text_shown_up(driver, 10, (By.ID, "i_nename"), gui_ne_name):
                gui_ip = find_single_widget(driver, 10, (By.ID, "i_neip"))
                if ne_ip == gui_ip.get_attribute('value').encode('utf-8').strip():
                    if ne_type == gui_ne_type:
                        # NE with same ip and same type exit
                        return 1, gui_ne_name
                    else:
                        if is_pair_nes(gui_ne_type.upper(), ne_type.upper()):
                            # this means that there is a pair NE with same IP exist, but we can still add a NE
                            # but will check if NE with the same type & same IP exist
                            is_has_pair_nes = True
                        else:
                            # this means a NE with different type but the same IP already exist.
                            return 2, gui_ne_name
        if is_has_pair_nes:
            return 0, None
        # the ip that we want to add does not exist
        return -1, None
    except Exception as e:
        # the ip that we want to add does not exist
        return -2, None
Пример #23
0
def fetch_alarm_on_gui(driver, ne_type, alarm_trap, mappingInstance,
                       alarm_type):
    nowtime = pydate.datetime.now()
    endtime = nowtime + pydate.timedelta(seconds=30)
    id_button = (By.XPATH, "//button[@id='idBtn-search']")
    search_button = find_single_widget(driver, 10, id_button)
    while (pydate.datetime.now() < endtime):
        search_button.click()
        try:
            alarm_data = get_1st_row_on_gui(driver)
        except TimeoutException:
            time.sleep(5)
            continue

        if ne_type == 'OCGAS':
            specific_problem = mappingInstance.get_property(
                "specific_problem")[alarm_type]
        else:
            specific_problem = alarm_trap["specificProblem"]
        if (specific_problem == alarm_data["问题描述"]):
            logCommon.info("alarm received on GUI:" + alarm_type)
            return alarm_data
        else:
            time.sleep(10)
    return None
Пример #24
0
def wait_until_rounds_ok(driver, rows, rows_of_page, rows_each_period):
    '''
    This function will check the number of rows that we need to check the PM.
    :param driver:
    :param rows:
    :param rows_of_page:
    :param dict_additional:
    :param ne_type:
    :return: None
    '''
    id_tbdoy_trs = (
        By.XPATH,
        "//div[@class='ebTabs']/div[2]/div/div/div/div/table/tbody/tr")
    # if dict_additional.has_key('check_rows'):
    #    rows = dict_additional['check_rows']

    # if not 0 == rows % dict_additional['number_of_lic']:
    #    test.error('Number of checked rows should be integer multiples of number of LICs.')
    t_start = datetime.now()
    # Note that most of the PM need T2-T1, for Node like SBC, we may wait 5 minutes more since SBC don't need T2-T1
    # t_end = t_start + timedelta(minutes=5 * (rows // dict_additional['number_of_lic'] + 1) + 2)
    t_end = t_start + timedelta(minutes=5 * (rows // rows_each_period + 1) + 2)
    while datetime.now() < t_end:
        # click the query button
        id_query_btn = (By.ID, "idBtn-search")
        find_single_widget(driver, 10, id_query_btn).click()
        time.sleep(.1)
        try:
            i_page = rows / rows_of_page
            tgt_page_number = i_page if 0 == rows % rows_of_page else i_page + 1
            id_tgt_pager = (By.XPATH, ("//div[@class='page']/ul/li[2]/ul/li[" +
                                       str(tgt_page_number) + "]"))
            time.sleep(.1)
            tgt_pager = get_widget_ignore_refrence_error(driver, id_tgt_pager)
            if not tgt_pager.get_attribute('class').find(
                    'ebPagination-entryAnchor_current') > -1:
                tgt_pager.click()
                trs = find_all_widgets(driver, 20, id_tbdoy_trs)
                if rows % rows_of_page <= len(trs):
                    test.passed('All the data that we need are ready now.')
                    return
        except TimeoutException:
            pass
        time.sleep(.5)
    test.failed(
        'It seems that the the data we need has not been collected as expectes, case may fail later steps.'
    )
Пример #25
0
def check_pm_by_row(driver, id_table, index_row, ne_type, dict_counters,
                    rows_of_page, list_headers, is_m_lics):
    test.info('Start to check row: ' + str(index_row))

    make_sure_is_correct_page(driver, index_row, rows_of_page)
    try:
        gui_index_row = rows_of_page if 0 == index_row % rows_of_page else index_row % rows_of_page
        id_tr = (By.XPATH, ".//tbody/tr[" + str(gui_index_row) + "]")
        table = find_single_widget(driver, 10, id_table)
        time.sleep(.5)
        tr = find_single_widget(table, 10, id_tr)
        gui_str_time = find_single_widget(
            tr, 10,
            (By.XPATH, ".//td[2]")).get_attribute('innerHTML').encode('utf-8')
        gui_time = datetime.strptime(gui_str_time.strip(), "%Y-%m-%d %H:%M")
        except_counter_id = str(gui_time.minute)

        id_lic_name = (By.XPATH, ".//td[3]")
        lic_name = find_single_widget(
            tr, 5, id_lic_name).get_attribute('innerHTML').encode('utf-8')
        if is_m_lics:
            except_counter_id = str(gui_time.minute) + '-' + lic_name
        list_row = dict_counters[except_counter_id].split(',')
        for i in range(len(list_row)):
            try:
                id_counter = (By.XPATH, ".//td[" + str(i + 4) + "]")
                gui_counter = find_single_widget(
                    tr, 5,
                    id_counter).get_attribute('innerHTML').encode('utf-8')
                i_gui_counter = int(gui_counter)
            except Exception as e:
                i_gui_counter = None
            if int(list_row[i].strip()) == i_gui_counter:
                msg = list_headers[1] + ": " + gui_str_time.strip() + ",\t" + list_headers[2] + ": " + lic_name + "; " \
                      + list_headers[i + 3] + ", GUI is " + str(i_gui_counter) + ",\tExpected is " + str(list_row[i]) \
                      + "."

                test.passed(msg)
            else:
                msg = list_headers[1] + ": " + gui_str_time.strip() + ",\t" + list_headers[2] + ": " + lic_name + "; " \
                      + list_headers[i + 3] + ", GUI is " + str(i_gui_counter) + ",\tExpected is " + str(list_row[i]) \
                      + "."

                test.failed(msg)
        return [gui_time, lic_name]
    except Exception as e:
        test.error("Test failed, ERROR: " + str(e))
Пример #26
0
def make_sure_in_pm_page(driver):
    # btn id: ebBtnSearch
    id_btn_interface = (By.ID, 'ebBtnSearch')
    try:
        find_single_widget(driver, 5, id_btn_interface)
        test.error(
            'Page redirect to the interface management page, critical error!')
    except TimeoutException:
        id_query_btn = (By.ID, "idBtn-search")
        try:
            pm_query_btn = find_single_widget(driver, 10, id_query_btn)
            if pm_query_btn:
                test.passed(
                    'Found the query button of PM Management page, check passed.'
                )
        except TimeoutException:
            test.failed('Cannot find the query button of PM Management page.')
Пример #27
0
def wait_until_pm_date_show_up(driver, ne_name, wait_time=720):
    select_given_ne_name(driver, ne_name)
    end_time = datetime.now() + timedelta(seconds=wait_time)
    while datetime.now() < end_time:
        id_query_btn = (By.ID, "idBtn-search")
        find_single_widget(driver, 10, id_query_btn).click()
        id_body_date = (
            By.XPATH,
            "//div[@class='ebTabs']/div[2]/div/div/div/div/table/tbody")
        try:
            find_single_widget(driver, 10, id_body_date)
            test.passed('Successfully found the counters data.')
            return
        except TimeoutException:
            pass
    test.error('Wait for ' + str(wait_time) +
               ' seconds but cannot find any PM datas.')
Пример #28
0
def make_sure_is_correct_page(driver, row_index, rows_of_page):
    """
    This function handle the situation that we need to paginate to different to check the PM datas.
    :param rows_of_page: how many rows each page has
    :param driver: selenium instance
    :param row_index: row index of the GUI
    :return: None
    """
    i_page = row_index / rows_of_page
    tgt_page_number = i_page if 0 == row_index % rows_of_page else i_page + 1
    id_tgt_pager = (By.XPATH, ("//div[@class='page']/ul/li[2]/ul/li[" + str(tgt_page_number) + "]"))
    tgt_pager = find_single_widget(driver, 10, id_tgt_pager)
    if not tgt_pager.get_attribute('class').find('ebPagination-entryAnchor_current') > -1:
        tgt_pager.click()
        # wait for the notification, maximum 10 seconds
        id_body_date = (By.XPATH, "//div[@class='ebTabs']/div[2]/div/div/div/div/table/tbody")
        find_single_widget(driver, 10, id_body_date)
        test.info('Now in page ' + str(tgt_page_number) + '.')
Пример #29
0
def check_pm_by_row(driver, id_table, index_row, ne_type, dict_counters, rows_of_page, list_headers, is_m_lics):
    test.info('Start to check row: ' + str(index_row))

    make_sure_is_correct_page(driver, index_row, rows_of_page)
    try:
        gui_index_row = rows_of_page if 0 == index_row % rows_of_page else index_row % rows_of_page
        id_tr = (By.XPATH, ".//tbody/tr[" + str(gui_index_row) + "]")
        table = find_single_widget(driver, 10, id_table)
        time.sleep(.5)
        tr = find_single_widget(table, 10, id_tr)
        gui_str_time = find_single_widget(tr, 10, (By.XPATH, ".//td[2]")).get_attribute('innerHTML').encode('utf-8')
        gui_time = datetime.strptime(gui_str_time.strip(), "%Y-%m-%d %H:%M")
        except_counter_id = str(gui_time.minute)

        id_lic_name = (By.XPATH, ".//td[3]")
        lic_name = find_single_widget(tr, 5, id_lic_name).get_attribute('innerHTML').encode('utf-8')
        if is_m_lics:
            except_counter_id = str(gui_time.minute) + '-' + lic_name
        list_row = dict_counters[except_counter_id].split(',')
        for i in range(len(list_row)):
            try:
                id_counter = (By.XPATH, ".//td[" + str(i + 4) + "]")
                gui_counter = find_single_widget(tr, 5, id_counter).get_attribute('innerHTML').encode('utf-8')
                i_gui_counter = int(gui_counter)
            except Exception as e:
                i_gui_counter = None
            if int(list_row[i].strip()) == i_gui_counter:
                msg = list_headers[1] + ": " + gui_str_time.strip() + ",\t" + list_headers[2] + ": " + lic_name + "; " \
                      + list_headers[i + 3] + ", GUI is " + str(i_gui_counter) + ",\tExpected is " + str(list_row[i]) \
                      + "."

                test.passed(msg)
            else:
                msg = list_headers[1] + ": " + gui_str_time.strip() + ",\t" + list_headers[2] + ": " + lic_name + "; " \
                      + list_headers[i + 3] + ", GUI is " + str(i_gui_counter) + ",\tExpected is " + str(list_row[i]) \
                      + "."

                test.failed(msg)
        return [gui_time, lic_name]
    except Exception as e:
        test.error("Test failed, ERROR: " + str(e))
Пример #30
0
def wait_until_rounds_ok(driver, rows, rows_of_page, dict_additional):
    '''
    This function will check the number of rows that we need to check the PM.
    :param driver:
    :param rows:
    :param rows_of_page:
    :param dict_additional:
    :param ne_type:
    :return: None
    '''
    id_tbdoy_trs = (By.XPATH, "//div[@class='ebTabs']/div[2]/div/div/div/div/table/tbody/tr")
    if dict_additional.has_key('check_rows'):
        rows = dict_additional['check_rows']

    if not 0 == rows % dict_additional['number_of_lic']:
        test.error('Number of checked rows should be integer multiples of number of LICs.')
    t_start = datetime.now()
    # Note that most of the PM need T2-T1, for Node like SBC, we may wait 5 minutes more since SBC don't need T2-T1
    t_end = t_start + timedelta(minutes=5 * (rows // dict_additional['number_of_lic'] + 1) + 2)
    while datetime.now() < t_end:
        # click the query button
        id_query_btn = (By.ID, "idBtn-search")
        find_single_widget(driver, 10, id_query_btn).click()
        time.sleep(.2)
        try:
            i_page = rows / rows_of_page
            tgt_page_number = i_page if 0 == rows % rows_of_page else i_page + 1
            id_tgt_pager = (By.XPATH, ("//div[@class='page']/ul/li[2]/ul/li[" + str(tgt_page_number) + "]"))
            tgt_pager = find_single_widget(driver, 10, id_tgt_pager)
            if not tgt_pager.get_attribute('class').find('ebPagination-entryAnchor_current') > -1:
                tgt_pager.click()
                trs = find_all_widgets(driver, 20, id_tbdoy_trs)
                if rows % rows_of_page <= len(trs):
                    test.passed('All the data that we need are ready now.')
                    return
        except TimeoutException:
            pass
        time.sleep(.5)
    test.failed('It seems that the the data we need has not been collected as expectes, case may fail later steps.')
Пример #31
0
def make_sure_is_correct_page(driver, row_index, rows_of_page):
    """
    This function handle the situation that we need to paginate to different to check the PM datas.
    :param rows_of_page: how many rows each page has
    :param driver: selenium instance
    :param row_index: row index of the GUI
    :return: None
    """
    i_page = row_index / rows_of_page
    tgt_page_number = i_page if 0 == row_index % rows_of_page else i_page + 1
    id_tgt_pager = (By.XPATH, ("//div[@class='page']/ul/li[2]/ul/li[" +
                               str(tgt_page_number) + "]"))
    tgt_pager = find_single_widget(driver, 10, id_tgt_pager)
    if not tgt_pager.get_attribute('class').find(
            'ebPagination-entryAnchor_current') > -1:
        tgt_pager.click()
        # wait for the notification, maximum 10 seconds
        id_body_date = (
            By.XPATH,
            "//div[@class='ebTabs']/div[2]/div/div/div/div/table/tbody")
        find_single_widget(driver, 10, id_body_date)
        test.info('Now in page ' + str(tgt_page_number) + '.')
Пример #32
0
def select_given_ne_name(driver, ne_name):
    identifier = (
        By.XPATH,
        "//div[@class='pmcommonarea']/div/div[2]/div[1]/div[2]/input")
    input_ne_name = find_single_widget(driver, 10, identifier)
    if not '' == input_ne_name.get_attribute('value').strip():
        input_ne_name.click()
        find_single_widget(driver, 10, (By.ID, "btnAllLeft")).click()
    else:
        input_ne_name.click()

    id_table_candidate = (
        By.XPATH,
        "//div[@class='ebLayout-candidateEnbs']/div[2]/div/div[3]/div/div/div/table"
    )
    table_candidate = find_single_widget(driver, 20, id_table_candidate)

    id_input_search = (By.XPATH, ".//thead/tr[2]/th[2]/input")
    candi_input = find_single_widget(table_candidate, 10, id_input_search)
    candi_input.clear()
    candi_input.send_keys(ne_name.strip())
    time.sleep(1.0)

    id_checkbox = (By.XPATH, ".//tbody/tr[1]/td[1]/div/div/input")
    left_checkbox = find_single_widget(table_candidate, 10, id_checkbox)
    if not left_checkbox.is_selected():
        left_checkbox.click()

    # select to right
    id_arrow_to_right = (By.ID, "btnRight")
    find_single_widget(driver, 10, id_arrow_to_right).click()
    # time.sleep(5.0)

    # close select ne dialog
    id_btn_choose_ne = (By.CLASS_NAME, "choose")
    find_single_widget(driver, 10, id_btn_choose_ne).click()
Пример #33
0
def to_ne_management_page(driver, logger):
    logger.info('To the NeManagement page...')

    identifier = (By.XPATH, "//div[@class='ebLayout-Navigation']/div/div[1]/span")
    find_single_widget(driver, 10, identifier).click()

    identifier = (By.XPATH, "//div[@class='ebBreadcrumbs-list']/ul/li[1]/a")
    find_single_widget(driver, 10, identifier).click()

    id_new_btn = (By.ID, "idBtn-create")
    find_single_widget(driver, 10, id_new_btn)
Пример #34
0
def to_ne_management_page(driver, logger):
    logger.info('To the NeManagement page...')

    identifier = (By.XPATH,
                  "//div[@class='ebLayout-Navigation']/div/div[1]/span")
    find_single_widget(driver, 10, identifier).click()

    identifier = (By.XPATH, "//div[@class='ebBreadcrumbs-list']/ul/li[1]/a")
    find_single_widget(driver, 10, identifier).click()

    id_new_btn = (By.ID, "idBtn-create")
    find_single_widget(driver, 10, id_new_btn)
Пример #35
0
def selected_given_nename(driver, nename):
    ne_param = find_single_widget(driver, 10,
                                  (By.XPATH, "//input[@class='ebInputNe']"))
    if ne_param.get_attribute('value'):
        ne_param.click()
        find_single_widget(driver, 10,
                           (By.XPATH, "//div[@id='btnAllLeft']")).click()
    else:
        ne_param.click()

    input_ne = find_single_widget(driver, 10, (
        By.XPATH,
        "//table[@class='ebTable elWidgets-Table-body']/thead/tr[2]/th[2]/input"
    ))
    input_ne.clear()
    input_ne.send_keys(nename)
    time.sleep(1)

    found_ne = find_single_widget(
        driver, 10,
        (By.XPATH, "//table[@class='ebTable elWidgets-Table-body']/tbody/tr"))

    if found_ne:
        ne_check_box = find_single_widget(found_ne, 10,
                                          (By.XPATH, "./td/div/div/input"))
        if not ne_check_box.is_selected():
            ne_check_box.click()
    else:
        logCommon.error("the given nename: " + nename + " not found")

    right_arrow = find_single_widget(driver, 10,
                                     (By.XPATH, "//div[@id='btnRight']"))
    right_arrow.click()

    confirm_btn = find_single_widget(
        driver, 10, (By.XPATH, "//div[@class='choose']/button"))
    confirm_btn.click()
Пример #36
0
def init_and_search(driver, ne_name, end_time=None, start_time=None):
    # select the given nename
    select_given_ne_name(driver, ne_name)

    # select the correct time
    if end_time is not  None:
        test.info('Query end time point set to: ' + end_time.strftime('%H%M%S'))
        id_end_time = (By.XPATH, "//div[@class='endtime']/div/span/input")
        find_single_widget(driver, 10, id_end_time).click()
        set_time_for_query(driver, end_time)

    if start_time is not None:
        test.info('Query start time point set to: ' + start_time.strftime('%H%M%S'))
        id_start_time = (By.XPATH, "//div[@class='starttime']/div/span/input")
        find_single_widget(driver, 10, id_start_time).click()
        set_time_for_query(driver, start_time)

    # click the query button
    id_query_btn = (By.ID, "idBtn-search")
    find_single_widget(driver, 10, id_query_btn).click()

    # wait for the notification, maximum 20 seconds
    id_body_date = (By.XPATH, "//div[@class='ebTabs']/div[2]/div/div/div/div/table/tbody")
    find_single_widget(driver, 20, id_body_date)
Пример #37
0
def fetch_alarm_on_gui(driver,ne_type,alarm_trap,mappingInstance,alarm_type):
    nowtime=pydate.datetime.now()
    endtime=nowtime + pydate.timedelta(seconds=30)
    id_button=(By.XPATH,"//button[@id='idBtn-search']")
    search_button=find_single_widget(driver,10,id_button)
    while(pydate.datetime.now()< endtime):
        search_button.click()
        try:
            alarm_data=get_1st_row_on_gui(driver)
        except TimeoutException:
            time.sleep(5)
            continue

        if ne_type == 'OCGAS':
            specific_problem = mappingInstance.get_property("specific_problem")[alarm_type]
        else:
            specific_problem = alarm_trap["specificProblem"]
        if(specific_problem == alarm_data["问题描述"]):
            logCommon.info("alarm received on GUI:" + alarm_type)
            return alarm_data
        else:
            time.sleep(10)
    return None
Пример #38
0
def set_time_for_query(driver, date_time):
    # first edition will only set the time part
    id_time_holder = (By.XPATH, "//div[@data-namespace='ebTimePicker']")
    time_holder = find_single_widget(driver, 10, id_time_holder)

    id_hour = (By.XPATH, ".//table[1]/tbody/tr/td[2]/div[2]/input")
    hour_input = find_single_widget(time_holder, 10, id_hour)
    hour_input.clear()
    hour_input.send_keys(date_time.hour)

    id_minute = (By.XPATH, ".//table[2]/tbody/tr/td[2]/div[2]/input")
    minute_input = find_single_widget(time_holder, 10, id_minute)
    minute_input.clear()
    minute_input.send_keys(date_time.minute)

    id_second = (By.XPATH, ".//table[3]/tbody/tr/td[2]/div[2]/input")
    second_input = find_single_widget(time_holder, 10, id_second)
    second_input.clear()
    # second_input.send_keys(date_time.second)
    second_input.send_keys(0)

    id_ok_btn = (By.XPATH, "//div[@class='ebDialogBox-actionBlock']/button[1]")
    find_single_widget(driver, 10, id_ok_btn).click()
Пример #39
0
def set_time_for_query(driver, date_time):
    # first edition will only set the time part
    id_time_holder = (By.XPATH, "//div[@data-namespace='ebTimePicker']")
    time_holder = find_single_widget(driver, 10, id_time_holder)

    id_hour = (By.XPATH, ".//table[1]/tbody/tr/td[2]/div[2]/input")
    hour_input = find_single_widget(time_holder, 10, id_hour)
    hour_input.clear()
    hour_input.send_keys(date_time.hour)

    id_minute = (By.XPATH, ".//table[2]/tbody/tr/td[2]/div[2]/input")
    minute_input = find_single_widget(time_holder, 10, id_minute)
    minute_input.clear()
    minute_input.send_keys(date_time.minute)

    id_second = (By.XPATH, ".//table[3]/tbody/tr/td[2]/div[2]/input")
    second_input = find_single_widget(time_holder, 10, id_second)
    second_input.clear()
    # second_input.send_keys(date_time.second)
    second_input.send_keys(0)

    id_ok_btn = (By.XPATH, "//div[@class='ebDialogBox-actionBlock']/button[1]")
    find_single_widget(driver, 10, id_ok_btn).click()
Пример #40
0
def query_alarm(driver):
    search_btn = find_single_widget(driver, 10, (By.XPATH,"//button[@id='idBtn-search']"))
    search_btn.click()
Пример #41
0
def refresh_ne_management_page(driver):
    driver.refresh()
    # check page loaded
    find_single_widget(driver, 10, (By.ID, "idBtn-create"))
Пример #42
0
def add_new_ne(driver, dict_ne_info):
    find_single_widget(driver, 10, (By.ID, "idBtn-create")).click()
    sleep(.5)
    # choose the correct ne_type
    id_select_ne_type = (By.XPATH, "//div[@id='i_netype']/div/button")
    find_single_widget(driver, 10, id_select_ne_type).click()

    # id_ne_type_list = (By.XPATH, "//div[@id='i_netype']/div/div/div[" +
    #                  str(ne_type_index_add_ne_page(dict_ne_info["ne_type"])) + "]")
    ne_type = dict_ne_info["ne_type"]
    id_ne_type_list = (By.XPATH, "//div[@id='i_netype']/div/div/div[@title='" + ne_type + "']")
    find_single_widget(driver, 10, id_ne_type_list).click()
    sleep(.5)

    # insert the common part
    id_ne_name = (By.ID, "i_nename")
    id_ne_ip = (By.ID, "i_neip")
    id_ne_user = (By.ID, "i_neuser")
    id_password = (By.ID, "i_nepassword")
    id_ne_port = (By.ID, "i_neport")

    id_sftp_port = (By.ID, "i_nesftpport")

    id_pm_path = (By.ID, "i_nepmfilepath")
    id_log_path = (By.ID, "i_nelogfilepath")
    id_alarm_path = (By.ID, "i_nefmfilepath")

    id_li_pwd = (By.ID, "i_nelipwd")
    id_fro_id = (By.ID, "i_nefroid")
    
    #add for HSS
    id_snmp_port = (By.ID,"i_snmpport")
    id_usmusername = (By.ID,"i_usmusername")
    id_i_authpwd = (By.ID,"i_authpwd")
    id_i_privpwd = (By.ID,"i_privpwd")
    id_i_appuser = (By.ID,"i_serviceusername")
    id_i_apppwd = (By.ID,"i_servicepwd")

    ne_name = dict_ne_info["ne_type"] + "-" + str(binascii.hexlify(os.urandom(8))).upper()
    w_ne_name = find_single_widget(driver, 10, id_ne_name)
    w_ne_name.clear()
    w_ne_name.send_keys(ne_name)

    w_ne_ip = find_single_widget(driver, 10, id_ne_ip)
    w_ne_ip.clear()
    w_ne_ip.send_keys(dict_ne_info["ne_ip"])

    w_ne_user = find_single_widget(driver, 10, id_ne_user)
    w_ne_user.clear()
    w_ne_user.send_keys(dict_ne_info["ne_user"])

    w_ne_password = find_single_widget(driver, 10, id_password)
    w_ne_password.clear()
    w_ne_password.send_keys(dict_ne_info["ne_password"])

    w_ne_port = find_single_widget(driver, 10, id_ne_port)
    w_ne_port.clear()
    w_ne_port.send_keys(dict_ne_info["ne_port"])

    if 'SBC' == dict_ne_info["ne_type"]:
        w_li_pwd = find_single_widget(driver, 10, id_li_pwd)
        w_li_pwd.clear()
        w_li_pwd.send_keys(dict_ne_info["li_pwd"])

        w_fro_id = find_single_widget(driver, 10, id_fro_id)
        w_fro_id.clear()
        w_fro_id.send_keys(dict_ne_info["fro_id"])
          
    else:
        w_sftp_port = find_single_widget(driver, 10, id_sftp_port)
        w_sftp_port.clear()
        w_sftp_port.send_keys(dict_ne_info["sftp_port"])

        w_pm_path = find_single_widget(driver, 10, id_pm_path)
        w_pm_path.clear()
        w_pm_path.send_keys(dict_ne_info["pm_path"])

        w_log_path = find_single_widget(driver, 10, id_log_path)
        w_log_path.clear()
        w_log_path.send_keys(dict_ne_info["log_path"])
        
        if 'IMSHSS' == dict_ne_info["ne_type"] or 'LTEHSS' == dict_ne_info["ne_type"]:
            w_snmp_port = find_single_widget(driver, 10, id_snmp_port)
            w_snmp_port.clear()
            w_snmp_port.send_keys(dict_ne_info["snmp_port"])
        
            w_usm_user = find_single_widget(driver, 10, id_usmusername)
            w_usm_user.clear()
            w_usm_user.send_keys(dict_ne_info["usm_user"])
        
            w_auth_pwd = find_single_widget(driver, 10, id_i_authpwd)
            w_auth_pwd.clear()
            w_auth_pwd.send_keys(dict_ne_info["auth_password"])
        
            w_priv_pwd = find_single_widget(driver, 10, id_i_privpwd)
            w_priv_pwd.clear()
            w_priv_pwd.send_keys(dict_ne_info["priv_password"])
            
        
            w_app_user = find_single_widget(driver, 10, id_i_appuser)
            w_app_user.clear()
            w_app_user.send_keys(dict_ne_info["app_user"])
            
            w_app_pwd = find_single_widget(driver, 10, id_i_apppwd)
            w_app_pwd.clear()
            w_app_pwd.send_keys(dict_ne_info["app_password"])
    
        elif 'OCGAS' == dict_ne_info["ne_type"]:
            w_alarm_path = find_single_widget(driver, 10, id_alarm_path)
            w_alarm_path.clear()
            w_alarm_path.send_keys(dict_ne_info["alarm_path"])

    id_submit_btn = (By.ID, "idBtn-save")
    find_single_widget(driver, 10, id_submit_btn).click()
    try:
        id_dialog_confirm = (By.XPATH, "//div[@class='ebDialogBox-actionBlock']/button[1]")
        find_single_widget(driver, 10,id_dialog_confirm).click()
    except Exception as e:
        test.info('There is no duplicated NEs.')
    test.info('Successfully added an NE: ' + str(ne_name))
    return ne_name
Пример #43
0
def query_alarm(driver):
    search_btn = find_single_widget(driver, 10,
                                    (By.XPATH, "//button[@id='idBtn-search']"))
    search_btn.click()
Пример #44
0
def add_new_ne(driver, dict_ne_info):
    find_single_widget(driver, 10, (By.ID, "idBtn-create")).click()
    sleep(.5)
    # choose the correct ne_type
    id_select_ne_type = (By.XPATH, "//div[@id='i_netype']/div/button")
    find_single_widget(driver, 10, id_select_ne_type).click()

    # id_ne_type_list = (By.XPATH, "//div[@id='i_netype']/div/div/div[" +
    #                  str(ne_type_index_add_ne_page(dict_ne_info["ne_type"])) + "]")
    ne_type = dict_ne_info["ne_type"]
    id_ne_type_list = (By.XPATH, "//div[@id='i_netype']/div/div/div[@title='" +
                       ne_type + "']")
    find_single_widget(driver, 10, id_ne_type_list).click()
    sleep(.5)

    # insert the common part
    id_ne_name = (By.ID, "i_nename")
    id_ne_ip = (By.ID, "i_neip")
    id_ne_user = (By.ID, "i_neuser")
    id_password = (By.ID, "i_nepassword")
    id_ne_port = (By.ID, "i_neport")

    id_sftp_port = (By.ID, "i_nesftpport")

    id_pm_path = (By.ID, "i_nepmfilepath")
    id_log_path = (By.ID, "i_nelogfilepath")
    id_alarm_path = (By.ID, "i_nefmfilepath")

    id_li_pwd = (By.ID, "i_nelipwd")
    id_fro_id = (By.ID, "i_nefroid")

    #add for HSS
    id_snmp_port = (By.ID, "i_snmpport")
    id_usmusername = (By.ID, "i_usmusername")
    id_i_authpwd = (By.ID, "i_authpwd")
    id_i_privpwd = (By.ID, "i_privpwd")
    id_i_appuser = (By.ID, "i_serviceusername")
    id_i_apppwd = (By.ID, "i_servicepwd")

    ne_name = dict_ne_info["ne_type"] + "-" + str(
        binascii.hexlify(os.urandom(8))).upper()
    w_ne_name = find_single_widget(driver, 10, id_ne_name)
    w_ne_name.clear()
    w_ne_name.send_keys(ne_name)

    w_ne_ip = find_single_widget(driver, 10, id_ne_ip)
    w_ne_ip.clear()
    w_ne_ip.send_keys(dict_ne_info["ne_ip"])

    w_ne_user = find_single_widget(driver, 10, id_ne_user)
    w_ne_user.clear()
    w_ne_user.send_keys(dict_ne_info["ne_user"])

    w_ne_password = find_single_widget(driver, 10, id_password)
    w_ne_password.clear()
    w_ne_password.send_keys(dict_ne_info["ne_password"])

    w_ne_port = find_single_widget(driver, 10, id_ne_port)
    w_ne_port.clear()
    w_ne_port.send_keys(dict_ne_info["ne_port"])

    if 'SBC' == dict_ne_info["ne_type"]:
        w_li_pwd = find_single_widget(driver, 10, id_li_pwd)
        w_li_pwd.clear()
        w_li_pwd.send_keys(dict_ne_info["li_pwd"])

        w_fro_id = find_single_widget(driver, 10, id_fro_id)
        w_fro_id.clear()
        w_fro_id.send_keys(dict_ne_info["fro_id"])

    else:
        w_sftp_port = find_single_widget(driver, 10, id_sftp_port)
        w_sftp_port.clear()
        w_sftp_port.send_keys(dict_ne_info["sftp_port"])

        w_pm_path = find_single_widget(driver, 10, id_pm_path)
        w_pm_path.clear()
        w_pm_path.send_keys(dict_ne_info["pm_path"])

        w_log_path = find_single_widget(driver, 10, id_log_path)
        w_log_path.clear()
        w_log_path.send_keys(dict_ne_info["log_path"])

        if 'IMSHSS' == dict_ne_info["ne_type"] or 'LTEHSS' == dict_ne_info[
                "ne_type"]:
            w_snmp_port = find_single_widget(driver, 10, id_snmp_port)
            w_snmp_port.clear()
            w_snmp_port.send_keys(dict_ne_info["snmp_port"])

            w_usm_user = find_single_widget(driver, 10, id_usmusername)
            w_usm_user.clear()
            w_usm_user.send_keys(dict_ne_info["usm_user"])

            w_auth_pwd = find_single_widget(driver, 10, id_i_authpwd)
            w_auth_pwd.clear()
            w_auth_pwd.send_keys(dict_ne_info["auth_password"])

            w_priv_pwd = find_single_widget(driver, 10, id_i_privpwd)
            w_priv_pwd.clear()
            w_priv_pwd.send_keys(dict_ne_info["priv_password"])

            w_app_user = find_single_widget(driver, 10, id_i_appuser)
            w_app_user.clear()
            w_app_user.send_keys(dict_ne_info["app_user"])

            w_app_pwd = find_single_widget(driver, 10, id_i_apppwd)
            w_app_pwd.clear()
            w_app_pwd.send_keys(dict_ne_info["app_password"])

        elif 'OCGAS' == dict_ne_info["ne_type"]:
            w_alarm_path = find_single_widget(driver, 10, id_alarm_path)
            w_alarm_path.clear()
            w_alarm_path.send_keys(dict_ne_info["alarm_path"])

    id_submit_btn = (By.ID, "idBtn-save")
    find_single_widget(driver, 10, id_submit_btn).click()
    try:
        id_dialog_confirm = (
            By.XPATH, "//div[@class='ebDialogBox-actionBlock']/button[1]")
        find_single_widget(driver, 10, id_dialog_confirm).click()
    except Exception as e:
        test.info('There is no duplicated NEs.')
    test.info('Successfully added an NE: ' + str(ne_name))
    return ne_name
Пример #45
0
def refresh_ne_management_page(driver):
    driver.refresh()
    # check page loaded
    find_single_widget(driver, 10, (By.ID, "idBtn-create"))