(
self,
resource_path: str,
hook_id: str,
wait_for_callbacks=True,
convert_canvases=False,
assert_check=True,
stay_on_page=False,
widths=None,
)
| 100 | logger.exception("webdriver quit was not successful") |
| 101 | |
| 102 | def visit_and_snapshot( |
| 103 | self, |
| 104 | resource_path: str, |
| 105 | hook_id: str, |
| 106 | wait_for_callbacks=True, |
| 107 | convert_canvases=False, |
| 108 | assert_check=True, |
| 109 | stay_on_page=False, |
| 110 | widths=None, |
| 111 | ): |
| 112 | path = resource_path.lstrip("/") |
| 113 | try: |
| 114 | if path != resource_path: |
| 115 | logger.warning("we stripped the left '/' in resource_path") |
| 116 | self.server_url = self.server_url |
| 117 | self.driver.get(f"{self.server_url.rstrip('/')}/{path}") |
| 118 | |
| 119 | # wait for the hook_id to present and all callbacks get fired |
| 120 | self.wait_for_element_by_id(hook_id) |
| 121 | self.percy_snapshot( |
| 122 | path, |
| 123 | wait_for_callbacks=wait_for_callbacks, |
| 124 | convert_canvases=convert_canvases, |
| 125 | widths=widths, |
| 126 | ) |
| 127 | if assert_check: |
| 128 | assert not self.find_elements( |
| 129 | "div.dash-debug-alert" |
| 130 | ), "devtools should not raise an error alert" |
| 131 | if not stay_on_page: |
| 132 | self.driver.back() |
| 133 | except WebDriverException as e: |
| 134 | logger.exception("snapshot at resource %s error", path) |
| 135 | raise e |
| 136 | |
| 137 | def percy_snapshot( |
| 138 | self, name="", wait_for_callbacks=False, convert_canvases=False, widths=None |
nothing calls this directly
no test coverage detected