当前位置: 首页>>代码示例>>Python>>正文


Python BuiltIn.wait_until_element_is_displayed方法代码示例

本文整理汇总了Python中robot.libraries.BuiltIn.BuiltIn.wait_until_element_is_displayed方法的典型用法代码示例。如果您正苦于以下问题:Python BuiltIn.wait_until_element_is_displayed方法的具体用法?Python BuiltIn.wait_until_element_is_displayed怎么用?Python BuiltIn.wait_until_element_is_displayed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在robot.libraries.BuiltIn.BuiltIn的用法示例。


在下文中一共展示了BuiltIn.wait_until_element_is_displayed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Inbox

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import wait_until_element_is_displayed [as 别名]
class Inbox(object):
    """
    High level action for Inbox page
    """

    def __init__(self):
        self._selenium2Library = BuiltIn().get_library_instance('selenium2Library')
        self.elements = {
                 'txtTemp' : '',
                'mail_rows' : 'css=div[class^="list-view-item-container ml-bg"]',
                'mail_table' : 'msg-list',
                'btn_popup_category' : 'btn-select-dd',
                'btn_compose' : "css=button[data-action='compose']",
                'txt_to_field' : 'to-field',
                'txt_cc_field' : 'cc-field',
                'txt_bcc_field' : 'bcc-field',
                'txt_subject_field' : 'subject-field',
                'txt_body_field' : 'rtetext',
                'btn_send' : "css=span[data-action='send']",
                'lbl_from' : "css=div.thread-item-header span[aria-label*='from ']",
                'txt_mail_content' : 'css=div.email-wrapped',
                'btn_delete' : 'btn-delete'

        }
    '''
    Usage: Select the email based on row index. 1st-based index.
    '''
    def select_email_by_index(self, row_index = 1):
        locator = self.elements['mail_rows']
        rows = self._selenium2Library.element_find(locator, False, False, None)
        chk_select = rows[int(row_index)-1].find_element(By.CSS_SELECTOR, "input[role='checkbox']" )
        if not chk_select.is_selected():
            chk_select.click()

    '''
    Usage: Select mass emails whose sender is matched with the sender_name
    Note: This keyword couldn't select the all the emails if there are too many.
    '''
    def select_email_by_sender(self, sender_name):
        locator = self.elements['mail_rows']
        my_rows = self._selenium2Library.element_find(locator, False, False, None)
        logger.info(str(len(my_rows)))
        length = len(my_rows)
        print my_rows
        for i in range(len(my_rows)):
            # BuiltIn().sleep(1, "New Row----")
            # logger.info("Row: " + str(i))
            # logger.info(str(len(my_rows)))
            row = my_rows[i]
            # logger.info(str(row))
            self._selenium2Library.wait_until_element_is_displayed(row, self._selenium2Library.timeout)
            element_sender = row.find_element(By.XPATH, ".//div[starts-with(@class,'from')]")
            # logger.info("Found element_sender.")
            self._selenium2Library.wait_until_element_is_displayed(element_sender,
                                                                   self._selenium2Library.timeout)
            # logger.info("Is Sender element displayed? " + str(element_sender.is_displayed()))
            current_sender_name = element_sender.text.strip()
            # logger.info("Current Sender Name: " + current_sender_name)
            if current_sender_name == sender_name:
                # logger.info("Found matched")
                chk_select = row.find_element(By.XPATH, ".//input[@role='checkbox']")
                if not chk_select.is_selected():
                    chk_select.click()
            # Refresh the rows list
            my_rows = self._selenium2Library.element_find(locator, False, False, None)

    '''
    Usage: Select the 1st email whose title is matched with the input.
    '''
    def select_email_by_subject(self, subject):
        locator = self.elements['mail_table']

        email_table = self._selenium2Library.element_find(locator, True, False, None)
        # Find the checkbox which subject is match with the given subject
        xpath_locator = ".//span[normalize-space(@title)='" + subject + "']/ancestor::div[3]//input"
        checkboxes = email_table.find_elements(By.XPATH, xpath_locator)
        for chk_select in checkboxes:
            if not chk_select.is_selected():
                    chk_select.click()

    '''
    Usage: Open email by subject
    '''
    def open_email_by_subject(self, subject):
        locator = self.elements['mail_table']

        email_table = self._selenium2Library.element_find(locator, True, False, None)
        # Find the checkbox which subject is match with the given subject
        xpath_locator = ".//span[normalize-space(@title)='" + subject + "']"
        _element = email_table.find_element(By.XPATH, xpath_locator)
        _element.click()
        self._selenium2Library.wait_until_page_load(self._selenium2Library.timeout)

    '''
    Usage: Select the email by pre-define category
    Params:
        category: All, None, Read, Unread, Starred, Unstarred
    '''
    def select_email_by_category(self, category):
        self._selenium2Library.click_element(self.elements['btn_popup_category'])
#.........这里部分代码省略.........
开发者ID:vumvo,项目名称:MyFirstGitHub,代码行数:103,代码来源:Inbox.py


注:本文中的robot.libraries.BuiltIn.BuiltIn.wait_until_element_is_displayed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。