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


Python TableElementFinder.find_by_col方法代码示例

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


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

示例1: test_find_by_col_with_xpath_locator

# 需要导入模块: from Selenium2Library.locators import TableElementFinder [as 别名]
# 或者: from Selenium2Library.locators.TableElementFinder import find_by_col [as 别名]
    def test_find_by_col_with_xpath_locator(self):
        finder = TableElementFinder()
        browser = mock()
        when(browser).find_elements_by_xpath("//table[@id='test1']//tr//*[self::td or self::th][2]").thenReturn([])

        finder.find_by_col(browser, "xpath=//table[@id='test1']", 2, 'hi')

        verify(browser).find_elements_by_xpath("//table[@id='test1']//tr//*[self::td or self::th][2]")
开发者ID:IlfirinPL,项目名称:robotframework-MarcinKoperski,代码行数:10,代码来源:test_tableelementfinder.py

示例2: test_find_by_col_with_css_locator

# 需要导入模块: from Selenium2Library.locators import TableElementFinder [as 别名]
# 或者: from Selenium2Library.locators.TableElementFinder import find_by_col [as 别名]
    def test_find_by_col_with_css_locator(self):
        finder = TableElementFinder()
        browser = mock()
        when(browser).find_elements_by_css_selector("table#test1 tr td:nth-child(2)").thenReturn([])
        when(browser).find_elements_by_css_selector("table#test1 tr th:nth-child(2)").thenReturn([])

        finder.find_by_col(browser, "css=table#test1", 2, 'hi')

        verify(browser).find_elements_by_css_selector("table#test1 tr td:nth-child(2)")
        verify(browser).find_elements_by_css_selector("table#test1 tr th:nth-child(2)")
开发者ID:IlfirinPL,项目名称:robotframework-MarcinKoperski,代码行数:12,代码来源:test_tableelementfinder.py

示例3: _TableElementKeywords

# 需要导入模块: from Selenium2Library.locators import TableElementFinder [as 别名]
# 或者: from Selenium2Library.locators.TableElementFinder import find_by_col [as 别名]
class _TableElementKeywords(KeywordGroup):

    def __init__(self):
        self._table_element_finder = TableElementFinder()

    # Public

    def get_table_cell(self, table_locator, row, column, loglevel='INFO'):
        """Returns the content from a table cell.

        Row and column number start from 1. Header and footer rows are
        included in the count. A negative row or column number can be used
        to get rows counting from the end (end: -1). Cell content from header
        or footer rows can be obtained with this keyword. To understand how
        tables are identified, please take a look at the `introduction`.

        See `Page Should Contain` for explanation about `loglevel` argument.
        """
        row = int(row)
        row_index = row
        if row > 0: row_index = row - 1
        column = int(column)
        column_index = column
        if column > 0: column_index = column - 1
        table = self._table_element_finder.find(self._current_browser(), table_locator)
        if table is not None:
            rows = table.find_elements_by_xpath("./thead/tr")
            if row_index >= len(rows) or row_index < 0:
                rows.extend(table.find_elements_by_xpath("./tbody/tr"))
            if row_index >= len(rows) or row_index < 0:
                rows.extend(table.find_elements_by_xpath("./tfoot/tr"))
            if row_index < len(rows):
                columns = rows[row_index].find_elements_by_tag_name('th')
                if column_index >= len(columns) or column_index < 0:
                    columns.extend(rows[row_index].find_elements_by_tag_name('td'))
                if column_index < len(columns):
                    return columns[column_index].text
        self.log_source(loglevel)
        raise AssertionError("Cell in table %s in row #%s and column #%s could not be found."
            % (table_locator, str(row), str(column)))

    def table_cell_should_contain(self, table_locator, row, column, expected, loglevel='INFO'):
        """Verifies that a certain cell in a table contains `expected`.

        Row and column number start from 1. This keyword passes if the
        specified cell contains the given content. If you want to test
        that the cell content matches exactly, or that it e.g. starts
        with some text, use `Get Table Cell` keyword in combination
        with built-in keywords such as `Should Be Equal` or `Should
        Start With`.

        To understand how tables are identified, please take a look at
        the `introduction`.

        See `Page Should Contain` for explanation about `loglevel` argument.
        """
        message = ("Cell in table '%s' in row #%s and column #%s "
                   "should have contained text '%s'."
                   % (table_locator, row, column, expected))
        try:
            content = self.get_table_cell(table_locator, row, column, loglevel='NONE')
        except AssertionError as err:
            self._info(err)
            self.log_source(loglevel)
            raise AssertionError(message)
        self._info("Cell contains %s." % (content))
        if expected not in content:
            self.log_source(loglevel)
            raise AssertionError(message)

    def table_column_should_contain(self, table_locator, col, expected, loglevel='INFO'):
        """Verifies that a specific column contains `expected`.

        The first leftmost column is column number 1. A negative column
        number can be used to get column counting from the end of the row (end: -1).
        If the table contains cells that span multiple columns, those merged cells
        count as a single column. For example both tests below work,
        if in one row columns A and B are merged with colspan="2", and
        the logical third column contains "C".

        Example:
        | Table Column Should Contain | tableId | 3 | C |
        | Table Column Should Contain | tableId | 2 | C |

        To understand how tables are identified, please take a look at
        the `introduction`.

        See `Page Should Contain Element` for explanation about
        `loglevel` argument.
        """
        element = self._table_element_finder.find_by_col(self._current_browser(), table_locator, col, expected)
        if element is None:
            self.log_source(loglevel)
            raise AssertionError("Column #%s in table identified by '%s' "
                   "should have contained text '%s'."
                   % (col, table_locator, expected))

    def table_footer_should_contain(self, table_locator, expected, loglevel='INFO'):
        """Verifies that the table footer contains `expected`.

#.........这里部分代码省略.........
开发者ID:neizod,项目名称:robotfw-selenium2,代码行数:103,代码来源:_tableelement.py


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