本文整理汇总了Python中Selenium2Library.locators.TableElementFinder.find_by_content方法的典型用法代码示例。如果您正苦于以下问题:Python TableElementFinder.find_by_content方法的具体用法?Python TableElementFinder.find_by_content怎么用?Python TableElementFinder.find_by_content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Selenium2Library.locators.TableElementFinder
的用法示例。
在下文中一共展示了TableElementFinder.find_by_content方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_find_by_content_with_xpath_locator
# 需要导入模块: from Selenium2Library.locators import TableElementFinder [as 别名]
# 或者: from Selenium2Library.locators.TableElementFinder import find_by_content [as 别名]
def test_find_by_content_with_xpath_locator(self):
finder = TableElementFinder()
browser = mock()
when(browser).find_elements_by_xpath("//table[@id='test1']//*").thenReturn([])
finder.find_by_content(browser, "xpath=//table[@id='test1']", 'hi')
verify(browser).find_elements_by_xpath("//table[@id='test1']//*")
示例2: test_find_by_content_with_css_locator
# 需要导入模块: from Selenium2Library.locators import TableElementFinder [as 别名]
# 或者: from Selenium2Library.locators.TableElementFinder import find_by_content [as 别名]
def test_find_by_content_with_css_locator(self):
finder = TableElementFinder()
browser = mock()
when(browser).find_elements_by_css_selector("table#test1").thenReturn([])
finder.find_by_content(browser, "css=table#test1", 'hi')
verify(browser).find_elements_by_css_selector("table#test1")
示例3: test_find_with_null_content_constraint
# 需要导入模块: from Selenium2Library.locators import TableElementFinder [as 别名]
# 或者: from Selenium2Library.locators.TableElementFinder import find_by_content [as 别名]
def test_find_with_null_content_constraint(self):
finder = TableElementFinder()
browser = mock()
elements = self._make_mock_elements('td', 'td', 'td')
elements[1].text = 'hi'
when(browser).find_elements_by_css_selector("table#test1").thenReturn(elements)
self.assertEqual(finder.find_by_content(browser, "test1", None), elements[0])
verify(browser).find_elements_by_css_selector("table#test1")
示例4: _TableElementKeywords
# 需要导入模块: from Selenium2Library.locators import TableElementFinder [as 别名]
# 或者: from Selenium2Library.locators.TableElementFinder import find_by_content [as 别名]
#.........这里部分代码省略.........
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`.
With table footer can be described as any <td>-element that is
child of a <tfoot>-element. 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_footer(self._current_browser(), table_locator, expected)
if element is None:
self.log_source(loglevel)
raise AssertionError("Footer in table identified by '%s' should have contained "
"text '%s'." % (table_locator, expected))
def table_header_should_contain(self, table_locator, expected, loglevel='INFO'):
"""Verifies that the table header, i.e. any <th>...</th> element, contains `expected`.
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_header(self._current_browser(), table_locator, expected)
if element is None:
self.log_source(loglevel)
raise AssertionError("Header in table identified by '%s' should have contained "
"text '%s'." % (table_locator, expected))
def table_row_should_contain(self, table_locator, row, expected, loglevel='INFO'):
"""Verifies that a specific table row contains `expected`.
The uppermost row is row number 1. A negative column
number can be used to get column counting from the end of the row
(end: -1). For tables that are structured with thead, tbody and tfoot,
only the tbody section is searched. Please use `Table Header Should Contain`
or `Table Footer Should Contain` for tests against the header or
footer content.
If the table contains cells that span multiple rows, a match
only occurs for the uppermost row of those merged cells. 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_row(self._current_browser(), table_locator, row, expected)
if element is None:
self.log_source(loglevel)
raise AssertionError("Row #%s in table identified by '%s' should have contained "
"text '%s'." % (row, table_locator, expected))
def table_should_contain(self, table_locator, expected, loglevel='INFO'):
"""Verifies that `expected` can be found somewhere in the table.
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_content(self._current_browser(), table_locator, expected)
if element is None:
self.log_source(loglevel)
raise AssertionError("Table identified by '%s' should have contained text '%s'." \
% (table_locator, expected))