Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add stay_on_page to testing visit_and_snapshot method #1020

Merged
merged 3 commits into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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