Hook method to take snapshot when a selenium test fails. The snapshot is placed under. - `/tmp/dash_artifacts` in linux - `%TEMP` in windows with a filename combining test case name and the running selenium session id
(self, name: str)
| 222 | ) |
| 223 | |
| 224 | def take_snapshot(self, name: str): |
| 225 | """Hook method to take snapshot when a selenium test fails. The |
| 226 | snapshot is placed under. |
| 227 | |
| 228 | - `/tmp/dash_artifacts` in linux |
| 229 | - `%TEMP` in windows |
| 230 | with a filename combining test case name and the |
| 231 | running selenium session id |
| 232 | """ |
| 233 | target = ( |
| 234 | "/tmp/dash_artifacts" if not self._is_windows() else os.getenv("TEMP", "") |
| 235 | ) |
| 236 | |
| 237 | if not os.path.exists(target): |
| 238 | try: |
| 239 | os.mkdir(target) |
| 240 | except OSError: |
| 241 | logger.exception("cannot make artifacts") |
| 242 | |
| 243 | self.driver.save_screenshot(f"{target}/{name}_{self.session_id}.png") |
| 244 | |
| 245 | def find_element(self, selector, attribute="CSS_SELECTOR"): |
| 246 | """find_element returns the first found element by the attribute `selector` |
no test coverage detected