Test that a table component is rendered properly. Args: driver: Selenium WebDriver open to the app table: Harness for Table app route: Page route or path.
(driver, table: AppHarness, route)
| 136 | |
| 137 | @pytest.mark.parametrize("route", ["", "/another"]) |
| 138 | def test_table(driver, table: AppHarness, route): |
| 139 | """Test that a table component is rendered properly. |
| 140 | |
| 141 | Args: |
| 142 | driver: Selenium WebDriver open to the app |
| 143 | table: Harness for Table app |
| 144 | route: Page route or path. |
| 145 | """ |
| 146 | driver.get(f"{table.frontend_url}/{route}") |
| 147 | assert table.app_instance is not None, "app is not running" |
| 148 | |
| 149 | thead = driver.find_element(By.TAG_NAME, "thead") |
| 150 | # poll till page is fully loaded. |
| 151 | table.poll_for_content(element=thead) |
| 152 | # check headers |
| 153 | assert thead.find_element(By.TAG_NAME, "tr").text == "NAME AGE LOCATION" |
| 154 | # check first row value |
| 155 | assert ( |
| 156 | driver.find_element(By.TAG_NAME, "tbody") |
| 157 | .find_elements(By.TAG_NAME, "tr")[0] |
| 158 | .text |
| 159 | == "John 30 New York" |
| 160 | ) |
| 161 | # check footer |
| 162 | assert ( |
| 163 | driver.find_element(By.TAG_NAME, "tfoot") |
| 164 | .find_element(By.TAG_NAME, "tr") |
| 165 | .text.lower() |
| 166 | == "footer1 footer2 footer3" |
| 167 | ) |
| 168 | # check caption |
| 169 | assert driver.find_element(By.TAG_NAME, "caption").text == "random caption" |