Closed xurizaemon closed 8 months ago
I feel like we should add @datetime
with a format like 2022-07-15T173709
.
Any requests?
Ran into a couple of unrelated (?) issues getting tests to pass: #54, #56. Apologies ๐
Now that I see screenshots with more meaningful filenames, I realise that when I look at a fail screenshot I mostly want to see the failed step text @step_text
, while on a standard screenshot something like @current_path
is more likely to be useful information. I think having separate filename patterns for fail and success screenshots would be even better.
@xurizaemon thank you so much for your contribution!
Could you please update the description with some examples of real-life file patterns that are different from what is available right now.
Also, could you please add examples of using some of the new tokens, like current page path or URL - if those will be used in the file names - I'd like to understand how they will be converted to path-friendly names.
Thank you
Will do, rebased, current test failures are expected (related to prefix handling).
@xurizaemon Can we please discuss this in an issue before implementation.
I've added my vision of the file naming spec https://github.com/drevops/behat-screenshot/issues/37#issuecomment-1765362632
Please note that an ability to specify different file names based on success/failure should be added in a separate issue. It would be great to progressively change things.
@xurizaemon
could you please pull from main
- I have resolved some issues with abandoned Goutte driver.
@xurizaemon I have some capa ity to pick this up in the next couple of weeks - can you please let me know if it is okay for me to do so or if you still want to finalise this yourself.
Hey @AlexSkrypnyk - yeah totally happy for you to pick this up if that works ๐
WIP commits are a bit more I had locally, you can drop them (go back to 5fb570cc741631a0a174fcde9c77d74141e81dd7) or keep what makes sense, up to you.
@tannguyen04 @AlexSkrypnyk I've added you as collaborators on this repo so you can continue this PR if that's suitable
Implemented in https://github.com/drevops/behat-screenshot/pull/94
This introduces the ability to configure the filenames generated for screenshots more extensively, as proposed in https://github.com/drevops/behat-screenshot/issues/37.
There is a new configuration value
filename_pattern
which can be set in behat.yml or overridden with env varBEHAT_SCREENSHOT_FILENAME_PATTERN
(as forBEHAT_SCREENSHOT_DIR
).This is a text string which permits use of the following tokens:
{datetime}
Ymd_His
format20231128_060912
{datetime:u}
1701105456.71
{ext}
html
orpng
{fail_prefix}
fail_prefix
abovefailed_
,error
{feature_file}
.feature
file currently being executedexample.feature
{microtime}
1697358758.18
{step_line}
.feature
file currently being executed67
{step_text}
I_am_on_the_test_page
{url}
https_example_org_some_path
{url:host}
,{url:path}
, ...parse_url()
).some_path
If the new configuration values are not set, current filename behaviour will be preserved to avoid impact on any tooling which depends on BC here. Changed defaults could be introduced with an appropriate version increment (not proposed for this MR).
Test coverage and docs in PR hopefully clarify further.
Screenshots from early WIP:
Tasks
{datetime}
token{path}
token{ext}
and{fail_prefix}
tokens{feature_file}
,{step_line}
and{step_text}
tokens{url}
and{url:*}
(parse_url()
components) tokensrebase --autosquash
{scenario_title}
Status
Feedback and input welcome, not ready for review yet - last commit is untested, currently moving tokens from variables on the context into an array to ensure safe values and avoid loading too many new variables onto the class.
Keeping test changes in a separate commit so I can patch the release with composer-patches.