def test_table_totals(web_fixture, table_fixture, scenario): """You can pass footer_items to with_data to add a footer with a row for each footer_item. Each column with footer content defined will have that content rendered in its footer row, columns inbetween will be collapsed with a colspan to ensure alignment. """ class MainWidget(Div): def __init__(self, view): super().__init__(view) table = Table(view) table.with_data([ StaticColumn(Field(label='Another Row Number'), 'row_another'), StaticColumn(Field(label='Row Number'), 'row'), scenario.total_column ], table_fixture.data, footer_items=[EmptyStub(total=123)]) self.add_child(table) fixture = table_fixture wsgi_app = web_fixture.new_wsgi_app(enable_js=True, child_factory=MainWidget.factory()) web_fixture.reahl_server.set_app(wsgi_app) browser = web_fixture.driver_browser browser.open('/') filler_cell = XPath.table_cell()[1].inside_of(XPath.table_footer()) assert browser.get_attribute(filler_cell, 'colspan') == '2' total_cell = XPath.table_cell()[2].inside_of(XPath.table_footer()) assert browser.get_text(total_cell) == scenario.expected_total assert not browser.get_attribute(total_cell, 'colspan')
def address_is_listed_as(self, name): return self.browser.is_element_present( XPath.table_cell().with_text(name))