本文整理汇总了Python中Selenium2Library.locators.TableElementFinder.find_in_col方法的典型用法代码示例。如果您正苦于以下问题:Python TableElementFinder.find_in_col方法的具体用法?Python TableElementFinder.find_in_col怎么用?Python TableElementFinder.find_in_col使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Selenium2Library.locators.TableElementFinder
的用法示例。
在下文中一共展示了TableElementFinder.find_in_col方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _TableElementKeywords
# 需要导入模块: from Selenium2Library.locators import TableElementFinder [as 别名]
# 或者: from Selenium2Library.locators.TableElementFinder import find_in_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 get_table_rows(self, table_locator, loglevel='INFO'):
"""add by qitao016. 20131115
get_table_rows: return the rows of the table.
"""
table = self._table_element_finder.find(self._current_browser(), table_locator)
if table is not None:
rows = table.find_elements_by_xpath("./thead/tr")
rows.extend(table.find_elements_by_xpath("./tbody/tr"))
rows.extend(table.find_elements_by_xpath("./tfoot/tr"))
return len(rows)
self.log_source(loglevel)
raise AssertionError("Table %s could not be found." % table_locator)
def get_table_cols_at_row(self, table_locator, row, loglevel='INFO'):
"""add by qitao016. 20131115
get_table_cols_at_row: return the cols of the table in one row.
"""
row = int(row)
row_index = row - 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): rows.extend(table.find_elements_by_xpath("./tbody/tr"))
if row_index >= len(rows): rows.extend(table.find_elements_by_xpath("./tfoot/tr"))
if row_index < len(rows):
columns = rows[row_index].find_elements_by_tag_name('th')
columns.extend(rows[row_index].find_elements_by_tag_name('td'))
return len(columns)
raise AssertionError("Cell in Table %s in row #%s could not be found." % (table_locator, str(row)))
def get_index_in_table_column(self, table_locator, col, expected, loglevel='INFO'):
"""add by Adam Wu CSS version. get content's index in a specific column contains `content`.
Row and column number start from 1. Header and footer rows are
included in the count. However, the header and footer content
will not be matched against 'expected'.
See `Page Should Contain Element` for explanation about `loglevel` argument.
"""
has_head=0
element = self._table_element_finder.find_by_header(self._current_browser(), table_locator, None)
if element is not None:
has_head = 1
index = self._table_element_finder.find_in_col(self._current_browser(), table_locator, col, expected)
if index <= 0:
self.log_source(loglevel)
raise AssertionError("Column #%s in table identified by '%s' "
"should have contained text '%s'."
% (col, table_locator, expected))
return index+has_head
def get_index_in_table_row(self, table_locator, row, expected, loglevel='INFO'):
"""added by Adam Wu. Get content's index in a specific table row contains `content`.
Row and column number start from 1. Header and footer rows are
included in the count. This means that also 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`.
#.........这里部分代码省略.........