43 if row == 0
or column == 0:
44 raise ValueError(
'Both row and column must be non-zero, '
45 'got row %d and column %d.' % (row, column))
47 cell = self.
_get_cell_get_cell(locator, row, column)
48 except AssertionError:
54 rows = self.
_get_rows_get_rows(locator, row)
55 if len(rows) < abs(row):
56 raise AssertionError(
"Table '%s' should have had at least %d "
57 "rows but had only %d."
58 % (locator, abs(row), len(rows)))
59 index = row - 1
if row > 0
else row
60 cells = rows[index].find_elements_by_xpath(
'./th|./td')
61 if len(cells) < abs(column):
62 raise AssertionError(
"Table '%s' row %d should have had at "
63 "least %d columns but had only %d."
64 % (locator, row, abs(column), len(cells)))
65 index = column - 1
if column > 0
else column
70 table = self.
find_elementfind_element(locator, tag=
'table')
71 rows = table.find_elements_by_xpath(
"./thead/tr")
72 if count < 0
or len(rows) < count:
73 rows.extend(table.find_elements_by_xpath(
"./tbody/tr"))
74 if count < 0
or len(rows) < count:
75 rows.extend(table.find_elements_by_xpath(
"./tfoot/tr"))
85 content = self.
get_table_cellget_table_cell(locator, row, column, loglevel)
86 if expected
not in content:
88 raise AssertionError(
"Table '%s' cell on row %s and column %s "
89 "should have contained text '%s' but it had "
91 % (locator, row, column, expected, content))
92 self.
infoinfo(
"Table cell contains '%s'." % content)
112 element = self.
_find_by_column_find_by_column(locator, column, expected)
115 raise AssertionError(
"Table '%s' column %s did not contain text "
116 "'%s'." % (locator, column, expected))
134 raise AssertionError(
"Table '%s' footer did not contain text "
135 "'%s'." % (locator, expected))
153 raise AssertionError(
"Table '%s' header did not contain text "
154 "'%s'." % (locator, expected))
174 element = self.
_find_by_row_find_by_row(locator, row, expected)
177 raise AssertionError(
"Table '%s' row %s did not contain text "
178 "'%s'." % (locator, row, expected))
193 raise AssertionError(
"Table '%s' did not contain text '%s'."
194 % (locator, expected))
197 return self.
_find_find(table_locator,
'//*', content)
200 return self.
_find_find(table_locator,
'//th', content)
203 return self.
_find_find(table_locator,
'//tfoot//td', content)
207 locator =
'//tr[{}]'.format(position)
208 return self.
_find_find(table_locator, locator, content)
212 locator =
'//tr//*[self::td or self::th][{}]'.format(position)
213 return self.
_find_find(table_locator, locator, content)
218 raise ValueError(
'Row and column indexes must be non-zero.')
222 return 'position()=last()'
223 return 'position()=last()-{}'.format(abs(index) - 1)
225 def _find(self, table_locator, locator, content):
227 elements = self.
find_elementsfind_elements(locator, parent=table)
228 for element
in elements:
231 if element.text
and content
in element.text:
def find_element(self, locator, tag=None, required=True, parent=None)
Find element matching locator.
def find_elements(self, locator, tag=None, parent=None)
Find all elements matching locator.
def log_source(self, loglevel='INFO')
def info(self, msg, html=False)
def _find_by_row(self, table_locator, row, content)
def table_footer_should_contain(self, locator, expected, loglevel='TRACE')
Verifies table footer contains text expected.
def _find_by_column(self, table_locator, col, content)
def table_column_should_contain(self, locator, column, expected, loglevel='TRACE')
Verifies table column contains text expected.
def _find_by_footer(self, table_locator, content)
def table_header_should_contain(self, locator, expected, loglevel='TRACE')
Verifies table header contains text expected.
def _index_to_position(self, index)
def table_row_should_contain(self, locator, row, expected, loglevel='TRACE')
Verifies that table row contains text expected.
def _find_by_content(self, table_locator, content)
def _get_rows(self, locator, count)
def get_table_cell(self, locator, row, column, loglevel='TRACE')
Returns contents of table cell.
def _get_cell(self, locator, row, column)
def _find(self, table_locator, locator, content)
def table_should_contain(self, locator, expected, loglevel='TRACE')
Verifies table contains text expected.
def _find_by_header(self, table_locator, content)
def table_cell_should_contain(self, locator, row, column, expected, loglevel='TRACE')
Verifies table cell contains text expected.