コード例 #1
0
    def get_node_title(self):
        xpath = '//*[@id="%s"]/a/span[2]' % self.get_current_node_id()
        if DEBUG_LOG_PRINT:
            PD_DebugLog.debug_print(self.__class__.__name__ +
                                    "The xpath is : " + xpath)

        return self.node.find_element(By.XPATH, xpath).text
コード例 #2
0
    def get_current_node_id(self):
        id_attr = self.node.get_attribute('id')
        if DEBUG_LOG_PRINT:
            PD_DebugLog.debug_print(self.__class__.__name__ +
                                    " The node is: " + id_attr)

        return id_attr
コード例 #3
0
 def click(self):
     xpath = '//*[@id="%s"]/a/span[1]' % self.get_current_node_id()
     if DEBUG_LOG_PRINT:
         PD_DebugLog.debug_print(self.__class__.__name__ +
                                 "The xpath is : " + xpath)
     elm = self.node.find_element(By.XPATH, xpath)
     elm.click()
コード例 #4
0
def wait_for(func, timeout, first=0.0, step=1.0, text=None):
    """
    If func() evaluates to True before timeout expires, return the
    value of func(). Otherwise return None.

    @brief: Wait until func() evaluates to True.

    :param timeout: Timeout in seconds
    :param first: Time to sleep before first attempt
    :param steps: Time to sleep between attempts in seconds
    :param text: Text to print while waiting, for debug purposes
    """
    start_time = time.time()
    end_time = time.time() + timeout

    time.sleep(first)

    while time.time() < end_time:
        if text:
            PD_DebugLog.debug_print("%s (%f secs)" %
                                    (text, (time.time() - start_time)))

        output = func()
        if output:
            return output

        time.sleep(step)

    return None
コード例 #5
0
 def check_if_platform_ip_existing(self, driver, platform_ip, platform_name):
     '''
     To get platform node from the web page
     And enter into the page, and get the elements info.
     '''
     cur_platform_ip = ''
     cur_platform_name = ''
     
     default_main_browser = Main_Browser_UIMap(driver)
     subtree = default_main_browser.get_platform_sub_menu_tree()
     platform_subtree = Platform_Tree(driver, subtree)
     count = platform_subtree.get_platform_count()
     for index in range(count):
         #elem = platform_subtree.get_platform_item(index)  #platformNode.switch_to_page()
         platform_subtree.enter_platform_summary_page(index)
         # elem.click()    # switch into the platform tree node
         # elem_page_driver = Platform_Summary_UIMap(default_main_browser)
         cur_platform_name = platform_subtree.get_platform_name(index)
         cur_platform_ip = platform_subtree.get_platform_ip() #index
         if platform_name == cur_platform_name:
             break 
     
     PD_DebugLog.debug_print("")
     if platform_ip != cur_platform_ip or platform_name != cur_platform_name:
         return False
     else:
         return True
コード例 #6
0
def wait_for(func, timeout, first=0.0, step=1.0, text=None):
    """
    If func() evaluates to True before timeout expires, return the
    value of func(). Otherwise return None.

    @brief: Wait until func() evaluates to True.

    :param timeout: Timeout in seconds
    :param first: Time to sleep before first attempt
    :param steps: Time to sleep between attempts in seconds
    :param text: Text to print while waiting, for debug purposes
    """
    start_time = time.time()
    end_time = time.time() + timeout

    time.sleep(first)

    while time.time() < end_time:
        if text:
            PD_DebugLog.debug_print("%s (%f secs)" % ( text, (time.time() - start_time)))

        output = func()
        if output:
            return output

        time.sleep(step)

    return None
コード例 #7
0
def save_screenshot(driver, path, filename):
    '''
    To save the screenshot for the failed case
    '''
    screenshot_filename = os.path.join(path, filename)
    PD_DebugLog.debug_print("The saved file is " + screenshot_filename)
    
    driver.save_screenshot(screenshot_filename)
コード例 #8
0
def save_screenshot(driver, path, filename):
    '''
    To save the screenshot for the failed case
    '''
    screenshot_filename = os.path.join(path, filename)
    PD_DebugLog.debug_print("The saved file is " + screenshot_filename)

    driver.save_screenshot(screenshot_filename)
コード例 #9
0
 def get_submenu_tree_id(self):
     #ul_elm = self.tree.find_element(By.XPATH, '//li/ul')
     #if DEBUG_LOG_PRINT:
     #    PD_DebugLog.debug_print("The sub tree is: " + ul_elm.text)
     
     id_attr = self.tree.get_attribute('id')
     if DEBUG_LOG_PRINT:
         PD_DebugLog.debug_print("The tree id is: " + id_attr)
         
     return id_attr
コード例 #10
0
 def get_submenu_tree(self, submenu_idx):
     ##platform_tree //*[@id="pane"]/div[1]
     # //*[@id="pane"]/div[1]/ul/li
     left_panel = self.driver.find_element(By.ID, Submenu_Tree.LeftPanelID)
     xpath = '//div[%d]/ul/li/ul' % (submenu_idx)
     submenu = left_panel.find_element(By.XPATH, xpath)
     if DEBUG_LOG_PRINT:
         PD_DebugLog.debug_print("The sub menu text is: " + submenu.text)
         
     return submenu
コード例 #11
0
    def get_submenu_tree(self, submenu_idx):
        ##platform_tree //*[@id="pane"]/div[1]
        # //*[@id="pane"]/div[1]/ul/li
        left_panel = self.driver.find_element(By.ID, Submenu_Tree.LeftPanelID)
        xpath = '//div[%d]/ul/li/ul' % (submenu_idx)
        submenu = left_panel.find_element(By.XPATH, xpath)
        if DEBUG_LOG_PRINT:
            PD_DebugLog.debug_print("The sub menu text is: " + submenu.text)

        return submenu
コード例 #12
0
ファイル: Platform_Tree.py プロジェクト: a5601564/WebAutotest
    def get_platform_ip(self):
        '''Get the platform ip from the ip page '''

        ip_text = ''
        if self.platform_summary:
            ip_text = self.platform_summary.get_platform_ip()

        if PD_DebugLog.DEBUG_LOG_PRINT:
            PD_DebugLog.debug_print("The IP text is: " + ip_text)
        return ip_text
コード例 #13
0
    def get_submenu_tree_id(self):
        #ul_elm = self.tree.find_element(By.XPATH, '//li/ul')
        #if DEBUG_LOG_PRINT:
        #    PD_DebugLog.debug_print("The sub tree is: " + ul_elm.text)

        id_attr = self.tree.get_attribute('id')
        if DEBUG_LOG_PRINT:
            PD_DebugLog.debug_print("The tree id is: " + id_attr)

        return id_attr
コード例 #14
0
 def get_platform_ip(self):
     '''Get the platform ip from the ip page '''
     
     ip_text = ''
     if self.platform_summary:
         ip_text = self.platform_summary.get_platform_ip()
         
     if PD_DebugLog.DEBUG_LOG_PRINT:
         PD_DebugLog.debug_print("The IP text is: " + ip_text)
     return ip_text
コード例 #15
0
 def get_vm_static_label_text(self, label_xpath):
     '''
     get the static label text
     '''
     self._common_enter_summary_frame_proc()
     
     elem = self.driver.find_element(By.XPATH, label_xpath)
     text = elem.text
     PD_DebugLog.debug_print("Get the element title: " + elem.text)
     self._common_exit_summary_frame_proc()
     return text
コード例 #16
0
 def is_closed(self):
     # check if the switch is closed
     
     xpath = '//*[@id="%s"]/span' % self.get_current_node_id()
     if DEBUG_LOG_PRINT:
         PD_DebugLog.debug_print(self.__class__.__name__ + "The xpath is : " + xpath)
     elem = self.node.find_element(By.XPATH, xpath)
     attr = elem.get_attribute('class')
     node_closed = attr.endwith('_close') 
         
     return node_closed
コード例 #17
0
    def get_vm_static_label_text(self, label_xpath):
        """
        get the static label text
        """
        self._common_enter_summary_frame_proc()

        elem = self.driver.find_element(By.XPATH, label_xpath)
        text = elem.text
        PD_DebugLog.debug_print("Get the element title: " + elem.text)
        self._common_exit_summary_frame_proc()
        return text
コード例 #18
0
    def get_all_child_nodes(self):
        xpath = '//*[@id="%s"]/li' % self.get_current_node_id()
        if self.has_child_node():
            xpath = '//*[@id="%s"]/ul/li' % self.get_current_node_id()

        if DEBUG_LOG_PRINT:
            PD_DebugLog.debug_print(self.__class__.__name__ + ":" + \
                  "get_all_child_nodes" +  \
                  "The xpath is : " + xpath)

        elemts = self.node.find_elements(By.XPATH, xpath)
        return elemts
コード例 #19
0
    def is_closed(self):
        # check if the switch is closed

        xpath = '//*[@id="%s"]/span' % self.get_current_node_id()
        if DEBUG_LOG_PRINT:
            PD_DebugLog.debug_print(self.__class__.__name__ +
                                    "The xpath is : " + xpath)
        elem = self.node.find_element(By.XPATH, xpath)
        attr = elem.get_attribute('class')
        node_closed = attr.endwith('_close')

        return node_closed
コード例 #20
0
 def get_all_child_nodes(self):
     xpath = '//*[@id="%s"]/li' % self.get_current_node_id()
     if self.has_child_node():
         xpath = '//*[@id="%s"]/ul/li' % self.get_current_node_id()
     
     if DEBUG_LOG_PRINT:
         PD_DebugLog.debug_print(self.__class__.__name__ + ":" + \
               "get_all_child_nodes" +  \
               "The xpath is : " + xpath)
               
     elemts = self.node.find_elements(By.XPATH, xpath)
     return elemts
コード例 #21
0
def readconfig(classname):
    
    config = ConfigParser.ConfigParser()
    config_file = 'cfg\\' + classname + '.cfg'
    PD_DebugLog.debug_print("The self.config_file is " + config_file)
    config_file = os.path.join(Basejob.TESTCASE_DIR, config_file)
    PD_DebugLog.debug_print("The self.config_file is " + config_file)
    if config_file and os.path.exists(config_file):
        config.read(config_file)
        return config
    else:
        return None
コード例 #22
0
def get_loss_ratio(output):
    """
    Get the packet loss ratio from the output of ping.

    :param output: Ping output.
    """
    try:
        # packet loss
        return int(re.findall(u'(\d+)% 丢失', output)[0])
    except IndexError:
        PD_DebugLog.debug_print(output)
        return -1
コード例 #23
0
def get_loss_ratio(output):
    """
    Get the packet loss ratio from the output of ping.

    :param output: Ping output.
    """
    try:
        # packet loss
        return int(re.findall(u'(\d+)% 丢失', output)[0])
    except IndexError:
        PD_DebugLog.debug_print(output)
        return -1
コード例 #24
0
def readconfig(classname):

    config = ConfigParser.ConfigParser()
    config_file = 'cfg\\' + classname + '.cfg'
    PD_DebugLog.debug_print("The self.config_file is " + config_file)
    config_file = os.path.join(Basejob.TESTCASE_DIR, config_file)
    PD_DebugLog.debug_print("The self.config_file is " + config_file)
    if config_file and os.path.exists(config_file):
        config.read(config_file)
        return config
    else:
        return None
コード例 #25
0
 def get_platform_name(self):
     '''
     get the platform name
     '''
     
     self._common_enter_summary_frame_proc()
     # /html/body/div/fieldset/legend
     xpath = '/html/body/div/fieldset/legend'
     elem = self.driver.find_element(By.XPATH, xpath)
     text = elem.text
     PD_DebugLog.debug_print("Get the element title: " + elem.text)
     self._common_exit_summary_frame_proc()
     return text
コード例 #26
0
 def get_task_count(self):
     '''
     get the task table element
     '''
     summary_text = self.get_task_summary()
     if DEBUG_LOG_PRINT:
         PD_DebugLog.debug_print("Summary text is: " + summary_text)
     ptn = re.compile(r'\d+')
     result = re.findall(ptn, summary_text)
     count = result[0]
     if DEBUG_LOG_PRINT:
         PD_DebugLog.debug_print("The count in summary is: " + count)
     return count
コード例 #27
0
 def get_history_tasks_count(self):
     '''
     get all the history tasks count
     '''
     task_status_text = self.driver.find_element(By.XPATH, 
                         "/html/body/div/div[2]/div[6]/div[1]/div[6]/div[6]/span").text
     if (DEBUG_LOG_PRINT):
         PD_DebugLog.debug_print("History task status:" +  task_status_text)
     
     ptn = re.compile(r'\d+')      
     count = re.findall(ptn, task_status_text)
     PD_DebugLog.debug_print("count is: " + count)
     return int(count)
コード例 #28
0
 def get_tab_from_leftpanel(self, tab_idx):
     '''
     get the tab element for platform resource
     '''
     # //*[@id="tab"]/li[2]/a
     tab = self.driver.find_element(By.XPATH, '//*[@id="tab"]/li[%d]/a' % tab_idx )
     #tab = tab_elemts.find_elements(By.XPATH, '//li[%d]' % (tab_idx))
     #xpath_ptn = '//li[%d]' % (tab_idx)
     # /html/body/div[2]/div/ul/li[4]
     # tab_elmt = ta#tab_elemts[tab_idx-1]
     if PD_DebugLog.DEBUG_LOG_PRINT:
         PD_DebugLog.debug_print("The tab text is: " + tab.text)
     return tab
コード例 #29
0
 def is_tab_current_selected(self, tab_idx):
     '''
     return bool value to represent whether the tab is current selected
     '''
     cur_selected = False
     tab_elm = self.get_tab_from_leftpanel(tab_idx)
     attr = tab_elm.get_attribute('class')
     if PD_DebugLog.DEBUG_LOG_PRINT:
         PD_DebugLog.debug_print("The current tab attribute is: " + attr)
     if 'current' == attr:
         cur_selected = True
         
     return cur_selected
コード例 #30
0
    def get_platform_name(self):
        '''
        get the platform name
        '''

        self._common_enter_summary_frame_proc()
        # /html/body/div/fieldset/legend
        xpath = '/html/body/div/fieldset/legend'
        elem = self.driver.find_element(By.XPATH, xpath)
        text = elem.text
        PD_DebugLog.debug_print("Get the element title: " + elem.text)
        self._common_exit_summary_frame_proc()
        return text
コード例 #31
0
    def is_tab_current_selected(self, tab_idx):
        '''
        return bool value to represent whether the tab is current selected
        '''
        cur_selected = False
        tab_elm = self.get_tab_from_leftpanel(tab_idx)
        attr = tab_elm.get_attribute('class')
        if PD_DebugLog.DEBUG_LOG_PRINT:
            PD_DebugLog.debug_print("The current tab attribute is: " + attr)
        if 'current' == attr:
            cur_selected = True

        return cur_selected
コード例 #32
0
 def get_task_count(self):
     '''
     get the task table element
     '''
     summary_text = self.get_task_summary()
     if DEBUG_LOG_PRINT:
         PD_DebugLog.debug_print("Summary text is: " + summary_text)
     ptn = re.compile(r'\d+')
     result = re.findall(ptn, summary_text)
     count = result[0]
     if DEBUG_LOG_PRINT:
         PD_DebugLog.debug_print("The count in summary is: " + count)
     return count
コード例 #33
0
    def has_child_node(self):
        child_node_existed = False

        try:
            xpath = '//*[@id="%s"]/ul' % self.get_current_node_id()
            if DEBUG_LOG_PRINT:
                PD_DebugLog.debug_print("The xpath is : " + xpath)
            elemts = self.node.find_elements(By.XPATH, xpath)
            if elemts:
                child_node_existed = True
        except:
            child_node_existed = False

        return child_node_existed
コード例 #34
0
 def get_iso_table(self):
     '''
     get the iso table
     '''
     table = self.driver.find_element(By.ID, 'rdo_from_iso')
     ##iso_table > tbody > tr:nth-child(1)
     #table_records = table.find_elements_by_tag_name("tr")
     #PD_DebugLog.debug_print("table count is : %d " % len(table_records))
     table_records = self.driver.find_elements_by_xpath('//*[@id="iso_table"]/tbody/tr')
     PD_DebugLog.debug_print("table count is : %d " % len(table_records))
     for tr in table_records:
         field2_elm = self.driver.find_element_by_xpath('//*[@id="iso_table"]/tbody/tr[2]/td[2]/div')
         field2_txt = field2_elm.text
         PD_DebugLog.debug_print("The table field[1] is :" + field2_txt)
コード例 #35
0
 def get_task_percentage(self, task_idx):
     '''
     get the task name for the table row0 field 0
     '''
     table_elm = self.get_task_table()
     xpath_str = '//tr[%d]/td[3]/div/div[2]' % (task_idx)
     elem = table_elm.find_element(By.XPATH, xpath_str)
     percentage_text = elem.text
     ptn = re.compile(r'\d+')
     result = re.findall(ptn, percentage_text)
     percentage = result[0]
     if DEBUG_LOG_PRINT:
         PD_DebugLog.debug_print("the percentage text is " + percentage_text)
     return percentage
コード例 #36
0
    def get_task_description(self, task_type, task_target):
        '''
        get the task name for the table row0 field 0
        '''
        table_elm = self.get_task_table()
        result = ''
        desc = ''
        for rowid in range(1, 10):
            xpath_str = '//tbody/tr[%d]/td[1]/div' % (rowid)
            elem = table_elm.find_element(By.XPATH, xpath_str)
            task_type_text = elem.text
            PD_DebugLog.debug_print("Task type is: " + task_type_text)
            xpath_str = '//tbody/tr[%d]/td[4]/div' % (rowid)
            elem = table_elm.find_element(By.XPATH, xpath_str)
            task_target_text = elem.text
            PD_DebugLog.debug_print("Task type is: " + task_target_text)
            
            if task_type == task_type_text and task_target == task_target_text:
                xpath_str = '//tbody/tr[%d]/td[6]/div' % (rowid)
                elem = table_elm.find_element(By.XPATH, xpath_str)
                result = elem.text
                PD_DebugLog.debug_print("Get the task status: " + result)
                
                desc_xpath_str = '//tbody/tr[%d]/td[7]/div' % (rowid)
                elem = table_elm.find_element(By.XPATH, desc_xpath_str)
                desc = elem.text
                PD_DebugLog.debug_print("Get the task status description: " + desc)

        return result, desc

        
コード例 #37
0
    def has_child_node(self):
        child_node_existed = False

        try:
            xpath = '//*[@id="%s"]/ul' % self.get_current_node_id()
            if DEBUG_LOG_PRINT:
                PD_DebugLog.debug_print("The xpath is : " + xpath)
            elemts = self.node.find_elements(By.XPATH, xpath)
            if elemts:
                child_node_existed = True
        except:
            child_node_existed = False
            
        return child_node_existed
コード例 #38
0
 def get_submenu_tree(self, submenu_idx):
     ##platform_tree //*[@id="pane"]/div[1]
     # //*[@id="pane"]/div[1]/ul/li
     left_panel = self.driver.find_element(By.ID, Main_Browser_UIMap.LeftPanelID)
     xpath = '//*[@id="pane"]/div[%d]/ul/li/ul/li' % (submenu_idx)
     submenu = left_panel.find_element(By.XPATH, xpath)
     if PD_DebugLog.DEBUG_LOG_PRINT:
         if submenu is list:
             for menu in submenu:
                 PD_DebugLog.debug_print("The sub menu text is: " + menu.text)
         else:
             PD_DebugLog.debug_print("The sub menu text is: " + submenu.text)
         
     return submenu
コード例 #39
0
 def get_sub_menu_tree_title(self, tabid):
     # //*[@id="pane"]/div[%d]/ul/li/span
     # /html/body/div[2]/div/div[2]/div[%d]/ul/li/span
     left_panel = self.driver.find_element(By.ID, Main_Browser_UIMap.LeftPanelID)
     xpath = '//*[@id="pane"]/div[%d]/ul/li/span' % (tabid)
     submenu = left_panel.find_element(By.XPATH, xpath)
     if PD_DebugLog.DEBUG_LOG_PRINT:
         if submenu is list:
             for menu in submenu:
                 PD_DebugLog.debug_print("The sub menu text is: " + menu.text)
         else:
             PD_DebugLog.debug_print("The sub menu text is: " + submenu.text)
         
     return submenu.text
コード例 #40
0
 def __init__(self, driver, root_elemt):
     '''
     Constructor
     '''
     self.driver = driver
     self.root = root_elemt
     expected_root_title = "DataCenter"
     PD_DebugLog.debug_print("The expected root title is: " + expected_root_title)
     self.platform_total_num = 0
     self.platform_summary = None
     
     root_elemt_title = self.get_tree_node_elemt_title(self.root)
     PD_DebugLog.debug_print("The fetched root title is: " + root_elemt_title)
     assert(expected_root_title == root_elemt_title)
コード例 #41
0
 def pd_login(self, driver, username, password):
     '''
     Use default configurations in shared_config file to login PD
     '''
         
     pd_browser_client = driver
 
     PD_DebugLog.stepinfo("Login PowerDirector")
     PD_DebugLog.debug_print("client browser title is " + pd_browser_client.title)
     assert "PowerDirector" in pd_browser_client.title
     PD_DebugLog.info_print("Page title: " + pd_browser_client.title)
 
     uid_input = pd_browser_client.find_element_by_id("uid")
     uid_input.send_keys(username)
     p_input = pd_browser_client.find_element_by_id("pword")
     p_input.send_keys(password)
     login_button = pd_browser_client.find_element_by_xpath("/html/body/div/form/div/p[4]/input")
     login_button.click()
     expect_welcome_panel = pd_browser_client.find_element_by_id("user_panel")
     welcome_text = "PowerDirector"
 
     try:
        if welcome_text in expect_welcome_panel.text:
             PD_DebugLog.debug_print(expect_welcome_panel.text)
     except:
         raise Login_Error("Login fails")
         pd_browser_client.quit()
 
     return pd_browser_client
コード例 #42
0
 def get_tab_from_leftpanel(self, tab_idx):
     '''
     get the tab element for platform resource
     '''
     # //*[@id="tab"]/li[2]/a
     tab = self.driver.find_element(By.XPATH,
                                    '//*[@id="tab"]/li[%d]/a' % tab_idx)
     #tab = tab_elemts.find_elements(By.XPATH, '//li[%d]' % (tab_idx))
     #xpath_ptn = '//li[%d]' % (tab_idx)
     # /html/body/div[2]/div/ul/li[4]
     # tab_elmt = ta#tab_elemts[tab_idx-1]
     if PD_DebugLog.DEBUG_LOG_PRINT:
         PD_DebugLog.debug_print("The tab text is: " + tab.text)
     return tab
コード例 #43
0
 def get_task_percentage(self, task_idx):
     '''
     get the task name for the table row0 field 0
     '''
     table_elm = self.get_task_table()
     xpath_str = '//tr[%d]/td[3]/div/div[2]' % (task_idx)
     elem = table_elm.find_element(By.XPATH, xpath_str)
     percentage_text = elem.text
     ptn = re.compile(r'\d+')
     result = re.findall(ptn, percentage_text)
     percentage = result[0]
     if DEBUG_LOG_PRINT:
         PD_DebugLog.debug_print("the percentage text is " +
                                 percentage_text)
     return percentage
コード例 #44
0
ファイル: UploadISO.py プロジェクト: xhan-shannon/WebAutotest
 def test_upload_iso(self):
     u'''注册平台 后,需要上传ISO镜像用于安装虚拟机'''
     
     u'''???平台注册后,有什么标志可以用来检测判断已经成功注册'''
     # Step 1: 登陆PD Web界面(用户名密码在配置文件tests-shared.cfg)
     PD_DebugLog.stepinfo(Messages.LOGIN_POWERDIRECTOR) #"Login PowerDirector"
     pd_client_browser = self.driver
     pd_client_browser.implicitly_wait(30)
     pd_client_browser.maximize_window()
     
     # Login and pass in with username, password, server and port
     self.pd_login()
     
     # Step 2: 选择上传镜像快捷按钮
     print("select and click the upload image button")
     PD_DebugLog.stepinfo(Messages.SELECT_CLICK_UPLOAD_IMG)
     pd_browser_main_map = Main_Browser_UIMap(pd_client_browser)
     upload_iso_btn = pd_browser_main_map.get_upload_iso_btn()
     upload_iso_btn.click()
     time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
     
     # Step 3: verify the text of the header in the popup window 
     pd_register_vg_uimap = Upload_ISO_UIMap(pd_client_browser)
     expect_title = u"上传镜像"
     print("The title is: " + pd_register_vg_uimap.get_header().text)
     assert expect_title == pd_register_vg_uimap.get_header().text
     time.sleep(1)
         
     # Step 4: input the image name    
     image_name_input = pd_register_vg_uimap.get_image_name_input()
     image_name_input.send_keys('E:\\VMWare\\ubuntu_server\\start-download.iso')
     
     # Step 5: select iso radio button
     # ... the default selection is iso ...
     next_btn = pd_register_vg_uimap.get_next_button()
     time.sleep(1)
 
     # Step 6: select Toolkit 
     # ... default Toolkit ...
     time.sleep(1)  
     
     # Step 7: select OS name 
     pd_register_vg_uimap.select_osname_by_name("IBM ToolKit v54")
     time.sleep(1)
 
   
     next_btn.click()
     time.sleep(0.5)
コード例 #45
0
ファイル: UploadISO.py プロジェクト: a5601564/WebAutotest
    def test_upload_iso(self):
        u'''注册平台 后,需要上传ISO镜像用于安装虚拟机'''
        u'''???平台注册后,有什么标志可以用来检测判断已经成功注册'''
        # Step 1: 登陆PD Web界面(用户名密码在配置文件tests-shared.cfg)
        PD_DebugLog.stepinfo(
            Messages.LOGIN_POWERDIRECTOR)  #"Login PowerDirector"
        pd_client_browser = self.driver
        pd_client_browser.implicitly_wait(30)
        pd_client_browser.maximize_window()

        # Login and pass in with username, password, server and port
        self.pd_login()

        # Step 2: 选择上传镜像快捷按钮
        print("select and click the upload image button")
        PD_DebugLog.stepinfo(Messages.SELECT_CLICK_UPLOAD_IMG)
        pd_browser_main_map = Main_Browser_UIMap(pd_client_browser)
        upload_iso_btn = pd_browser_main_map.get_upload_iso_btn()
        upload_iso_btn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        # Step 3: verify the text of the header in the popup window
        pd_register_vg_uimap = Upload_ISO_UIMap(pd_client_browser)
        expect_title = u"上传镜像"
        print("The title is: " + pd_register_vg_uimap.get_header().text)
        assert expect_title == pd_register_vg_uimap.get_header().text
        time.sleep(1)

        # Step 4: input the image name
        image_name_input = pd_register_vg_uimap.get_image_name_input()
        image_name_input.send_keys(
            'E:\\VMWare\\ubuntu_server\\start-download.iso')

        # Step 5: select iso radio button
        # ... the default selection is iso ...
        next_btn = pd_register_vg_uimap.get_next_button()
        time.sleep(1)

        # Step 6: select Toolkit
        # ... default Toolkit ...
        time.sleep(1)

        # Step 7: select OS name
        pd_register_vg_uimap.select_osname_by_name("IBM ToolKit v54")
        time.sleep(1)

        next_btn.click()
        time.sleep(0.5)
コード例 #46
0
 def get_platform_ip(self):
     '''
     get the platform ip
     '''
     
     self._common_enter_summary_frame_proc()
     # /html/body/div/fieldset/table/tbody/tr/td[2]/ul/li[2]/span[2]
     # //*[@id="wrapper"]/fieldset/table/tbody/tr/td[2]/ul/li[2]/span[2]
     xpath_from_Chrome = '//*[@id="wrapper"]/fieldset/table/tbody/tr/td[2]/ul/li[2]/span[2]'
     xpath_from_firefox = '/html/body/div/fieldset/table/tbody/tr/td[2]/ul/li/span[2]'
     xpath_str = xpath_from_firefox
     elem = self.driver.find_element(By.XPATH, xpath_str)
     PD_DebugLog.debug_print("Get the element (platform ip) title: " + elem.text)
     text = elem.text
     self._common_exit_summary_frame_proc()
     return text
コード例 #47
0
ファイル: Platform_Tree.py プロジェクト: a5601564/WebAutotest
    def __init__(self, driver, root_elemt):
        '''
        Constructor
        '''
        self.driver = driver
        self.root = root_elemt
        expected_root_title = "DataCenter"
        PD_DebugLog.debug_print("The expected root title is: " +
                                expected_root_title)
        self.platform_total_num = 0
        self.platform_summary = None

        root_elemt_title = self.get_tree_node_elemt_title(self.root)
        PD_DebugLog.debug_print("The fetched root title is: " +
                                root_elemt_title)
        assert (expected_root_title == root_elemt_title)
コード例 #48
0
 def select_template_from_table_by_name(self, name):
     # //*[@id="templates_table"]/tbody/tr[2]/td[2]/div
     table_records = self.driver.find_elements_by_xpath('//*[@id="templates_table"]/tbody/tr')
     PD_DebugLog.debug_print("table count is : %d " % len(table_records))
     # select the table record and click the radio button
     for nid in range(len(table_records)):
         field2_elm = self.driver.find_element_by_xpath('//*[@id="templates_table"]/tbody/tr[%d]/td[2]/div' % (nid + 1) )
         field2_txt = field2_elm.text
         PD_DebugLog.debug_print("table element name is :" + field2_txt)
         if name in field2_txt:
             #self.driver.find_element_by_xpath('//*[@id="templates_table"]/tbody/tr[%d]/td[1]/div/[@id="imagePcid"]' % (nid + 1) ).click()
             table_records[nid].find_element(By.ID, 'imagePcid').click()
             PD_DebugLog.debug_print("Hit")
             PD_DebugLog.debug_print("The id is %d" % nid)
             #break
         
         PD_DebugLog.debug_print("The table field[%d] is : %s"  % (nid+1, field2_txt))
コード例 #49
0
    def get_platform_ip(self):
        '''
        get the platform ip
        '''

        self._common_enter_summary_frame_proc()
        # /html/body/div/fieldset/table/tbody/tr/td[2]/ul/li[2]/span[2]
        # //*[@id="wrapper"]/fieldset/table/tbody/tr/td[2]/ul/li[2]/span[2]
        xpath_from_Chrome = '//*[@id="wrapper"]/fieldset/table/tbody/tr/td[2]/ul/li[2]/span[2]'
        xpath_from_firefox = '/html/body/div/fieldset/table/tbody/tr/td[2]/ul/li/span[2]'
        xpath_str = xpath_from_firefox
        elem = self.driver.find_element(By.XPATH, xpath_str)
        PD_DebugLog.debug_print("Get the element (platform ip) title: " +
                                elem.text)
        text = elem.text
        self._common_exit_summary_frame_proc()
        return text
コード例 #50
0
    def get_submenu_tree(self, submenu_idx):
        ##platform_tree //*[@id="pane"]/div[1]
        # //*[@id="pane"]/div[1]/ul/li
        left_panel = self.driver.find_element(By.ID,
                                              Main_Browser_UIMap.LeftPanelID)
        xpath = '//*[@id="pane"]/div[%d]/ul/li/ul/li' % (submenu_idx)
        submenu = left_panel.find_element(By.XPATH, xpath)
        if PD_DebugLog.DEBUG_LOG_PRINT:
            if submenu is list:
                for menu in submenu:
                    PD_DebugLog.debug_print("The sub menu text is: " +
                                            menu.text)
            else:
                PD_DebugLog.debug_print("The sub menu text is: " +
                                        submenu.text)

        return submenu
コード例 #51
0
    def get_sub_menu_tree_title(self, tabid):
        # //*[@id="pane"]/div[%d]/ul/li/span
        # /html/body/div[2]/div/div[2]/div[%d]/ul/li/span
        left_panel = self.driver.find_element(By.ID,
                                              Main_Browser_UIMap.LeftPanelID)
        xpath = '//*[@id="pane"]/div[%d]/ul/li/span' % (tabid)
        submenu = left_panel.find_element(By.XPATH, xpath)
        if PD_DebugLog.DEBUG_LOG_PRINT:
            if submenu is list:
                for menu in submenu:
                    PD_DebugLog.debug_print("The sub menu text is: " +
                                            menu.text)
            else:
                PD_DebugLog.debug_print("The sub menu text is: " +
                                        submenu.text)

        return submenu.text
コード例 #52
0
    def expand_more_actions_bar(self):
        """
        Make the more actions bar is expanded, if not expand it
        """
        self._common_enter_summary_frame_proc()

        xpath = "/html/body/div/form/div/table/tbody/tr/td[2]/div/h3/a"
        more_actions_bar_elemt = self.driver.find_element(By.XPATH, xpath)
        class_attribute_value = more_actions_bar_elemt.get_attribute("class")

        PD_DebugLog.debug_print("more actions bar class attribute is : " + class_attribute_value)
        if class_attribute_value != "expand":
            more_actions_bar_elemt.click()

        class_attribute_value = more_actions_bar_elemt.get_attribute("class")
        PD_DebugLog.debug_print("more actions bar class attribute is : " + class_attribute_value)

        self._common_exit_summary_frame_proc()
コード例 #53
0
    def click_register_image_link(self):
        '''
        get the register image link
        should use the right xpath expression end with 'a' element.
        '''
        
        self._common_enter_summary_frame_proc()
        
        xpath_from_Chrome = '//*[@id="wrapper"]/div[2]/table/tbody/tr/td/div/ul/li[2]/a'
        #xpath_from_firefox = '/html/body/div/fieldset/table/tbody/tr/td[2]/ul/li/span[2]'
        xpath_str = xpath_from_Chrome
        elem = self.frame_summary_wrapper.find_element(By.XPATH, xpath_str)
        #elem = self.frame_summary_wrapper.find_element_by_link_text(u'注册镜像')
        PD_DebugLog.debug_print("Get the element (register image) title: " + elem.text)

        elem.click()
        
        self._common_exit_summary_frame_proc()
コード例 #54
0
 def expand_more_actions_bar(self):
     '''
     Make the more actions bar is expanded, if not expand it
     '''
     self._common_enter_summary_frame_proc()
     
     xpath = '/html/body/div/form/div/table/tbody/tr/td[2]/div/h3/a'
     more_actions_bar_elemt = self.driver.find_element(By.XPATH, xpath)
     class_attribute_value = more_actions_bar_elemt.get_attribute("class")
     
     PD_DebugLog.debug_print("more actions bar class attribute is : " + class_attribute_value)
     if class_attribute_value != 'expand':
         more_actions_bar_elemt.click() 
     
     class_attribute_value = more_actions_bar_elemt.get_attribute("class")
     PD_DebugLog.debug_print("more actions bar class attribute is : " + class_attribute_value)
     
     self._common_exit_summary_frame_proc()
コード例 #55
0
 def get_task_id(self, vm_name):
     '''
     '''
     table_elm = self.get_task_table()
     ret_val = 0
     
     task_count = int(self.get_task_count())
     for tid in range(1, task_count+1):
         vm_name_in_task = table_elm.find_element(By.XPATH, 
                               '//tr[1]/td[2]/span[1]').text
         vm_name_in_task = vm_name_in_task.split(':')[1].strip()
         if DEBUG_LOG_PRINT:
             PD_DebugLog.debug_print("task name " + vm_name_in_task)
             
         if vm_name == vm_name_in_task:
             ret_val = tid + 1
             break
     
     return ret_val