make `dash_duo.take_snapshot` more flexible
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.4k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 13
Description
Is your feature request related to a problem? Please describe.
Seems like in dash.testing, calling dash_duo.take_snapshot enforces the directory name and the naming convention:
https://github.com/plotly/dash/blob/fed4a9123f5d0cf6213da157bb94f5e1900c3440/dash/testing/browser.py#L153-L171
Describe the solution you'd like
I think that giving the option to change the path and choose the exact name of the snapshot might be nice. Maybe something like this:
def take_snapshot(self, name, save_dir="/tmp/artifacts", append_session_id=True):
"""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
"""
target = save_dir if not self._is_windows() else os.path.join(os.getenv("TEMP"), save_dir)
try:
os.makedirs(target, exist_ok=True)
except OSError:
logger.exception("cannot make artifacts")
if append_session_id:
name += str(self.session_id)
name += ".png"
self.driver.save_screenshot(
os.path.join(target, name)
)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in dash/testing/browser.py at the take_snapshot entry point linked in the issue, and read how the current directory and filename are assembled. Done means callers can choose the save path and exact snapshot name, with session ID appending remaining optional and the documented platform behavior preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100