Skip to content

Commit

Permalink
Merge pull request #1020 from plotly/snapshot-stay-on-page
Browse files Browse the repository at this point in the history
add stay_on_page to testing visit_and_snapshot method
  • Loading branch information
alexcjohnson committed Nov 21, 2019
2 parents 5f08f58 + 2182493 commit 64fefff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased
### Added
- [#967](https://github.com/plotly/dash/pull/967) Adds support for defining
- [#967](https://github.com/plotly/dash/pull/967) Add support for defining
clientside JavaScript callbacks via inline strings.
- [#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.

### Fixed
- [#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.
Expand Down
10 changes: 8 additions & 2 deletions dash/testing/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ def __exit__(self, exc_type, exc_val, traceback):
logger.exception("percy runner failed to finalize properly")

def visit_and_snapshot(
self, resource_path, hook_id, wait_for_callbacks=True, assert_check=True
self,
resource_path,
hook_id,
wait_for_callbacks=True,
assert_check=True,
stay_on_page=False
):
try:
path = resource_path.lstrip("/")
Expand All @@ -121,7 +126,8 @@ def visit_and_snapshot(
assert not self.driver.find_elements_by_css_selector(
"div.dash-debug-alert"
), "devtools should not raise an error alert"
self.driver.back()
if not stay_on_page:
self.driver.back()
except WebDriverException as e:
logger.exception("snapshot at resource %s error", path)
raise e
Expand Down

0 comments on commit 64fefff

Please sign in to comment.