Skip to content

Commit 64fefff

Browse files
authored
Merge pull request #1020 from plotly/snapshot-stay-on-page
add stay_on_page to testing visit_and_snapshot method
2 parents 5f08f58 + 2182493 commit 64fefff

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44

55
## Unreleased
66
### Added
7-
- [#967](https://github.com/plotly/dash/pull/967) Adds support for defining
7+
- [#967](https://github.com/plotly/dash/pull/967) Add support for defining
88
clientside JavaScript callbacks via inline strings.
9+
- [#1020](https://github.com/plotly/dash/pull/1020) Allow `visit_and_snapshot` API in `dash.testing.browser` to stay on the page so you can run other checks.
910

1011
### Fixed
1112
- [#1018](https://github.com/plotly/dash/pull/1006) Fix the `dash.testing` **stop** API with process application runner in Python2. Use `kill()` instead of `communicate()` to avoid hanging.

dash/testing/browser.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,12 @@ def __exit__(self, exc_type, exc_val, traceback):
106106
logger.exception("percy runner failed to finalize properly")
107107

108108
def visit_and_snapshot(
109-
self, resource_path, hook_id, wait_for_callbacks=True, assert_check=True
109+
self,
110+
resource_path,
111+
hook_id,
112+
wait_for_callbacks=True,
113+
assert_check=True,
114+
stay_on_page=False
110115
):
111116
try:
112117
path = resource_path.lstrip("/")
@@ -121,7 +126,8 @@ def visit_and_snapshot(
121126
assert not self.driver.find_elements_by_css_selector(
122127
"div.dash-debug-alert"
123128
), "devtools should not raise an error alert"
124-
self.driver.back()
129+
if not stay_on_page:
130+
self.driver.back()
125131
except WebDriverException as e:
126132
logger.exception("snapshot at resource %s error", path)
127133
raise e

0 commit comments

Comments
 (0)