Giter Club home page Giter Club logo

Comments (6)

xurizaemon avatar xurizaemon commented on June 9, 2024 2

And don't miss the existing WIP in #53 :)

You're welcome to squash commits on that branch to base your work on. When doing so please retain commit credit for existing progress 😄

It's fine to start over too! Thanks for picking this up 😁

from behat-screenshot.

AlexSkrypnyk avatar AlexSkrypnyk commented on June 9, 2024 1

@xurizaemon
I liked your suggestion and was thinking about supporting this. But I do not have the bandwidth to support this. A PR is always welcomed!

Please note that there is a purge option available to purge all screenshots after every run.

The timestamp prefix was added to order screenshots by creation time.

from behat-screenshot.

AlexSkrypnyk avatar AlexSkrypnyk commented on June 9, 2024 1

@xurizaemon I work with @tannguyen04 on this and the priority for this issue has changed a bit. We will be addressing this in a week or two.

from behat-screenshot.

AlexSkrypnyk avatar AlexSkrypnyk commented on June 9, 2024

Here is a suggested spec for providing configurable file names for screenshots.

Token format

{name[_qualifier[:format]}, where

  • { and } denote the start and end of a token
  • name is the name of the token
  • qualifier is an optional qualifier for the token. Must be separated from the name by an underscore.
  • format is an optional format for the token. Must be separated from the qualifier by a colon.

The reasoning behind using {} as delimiters instead of @ is to make it easier to identify the token end delimiter in
the string.

Supported tokens

Using http://example.com/mypath/subpath?myquery=1+2+3&another[]=4#somefragment in URL examples.

Token Substituted with Example value(s)
{ext} The extension of the file captured html or png
{fail_prefix} The value of fail_prefix from configuration failed_, error_ (do include the _ suffix, if required)
{url} Full URL http_example_com_mypath_subpath__query__myquery_1_plus_2_plus_3_and_another1_4__fragment__somefragment
{url_origin} Scheme with domain http_example_com
{url_relative} Path + query + fragment mypath_subpath__query__myquery_1_plus_2_plus_3_and_another1_4__fragment__somefragment
{url_domain} Domain example_com
{url_path} Path mypath_subpath
{url_query} Query myquery_1_plus_2_plus_3_and_another1_4
{url_fragment} Fragment somefragment
{feature_file} The filename of the .feature file currently being executed, without extension my_example.feature -> my_example
{step_line} Step line number 1, 10, 100
{step_line:%03d} Step line number with leading zeros. Modifiers are from sprintf(). 001, 010, 100
{step_name} Step name without Given/When/Then and lower-cased. i_am_on_the_test_page
{datetime} Current date and time. defaults to Ymd_His format. 20010310_171618
{datetime:u} Current date and time as microtime. Modifiers are from date(). 1697490961192498

Based on the above, the current format can be expressed as:

{datetime:u}.{fail_prefix}{feature_file}.feature_{step_line}.{ext}

resulting in filenames like:

1697490961192498.login.feature_14.png - success

1697490961192498.failed_login.feature_14.png - failed

Config changes

extensions:
    DrevOps\BehatScreenshotExtension:
      dir: %paths.base%/screenshots
      fail: true
      purge: false
      # New config option.
      filenamePattern: {datetime:u}.{fail_prefix}{feature_file}.feature_{step_line}.{ext}

Success vs failed patterns

Although adding an ability to provide different file name patterns for successful and failed screenshots is not a part of this issue, it is worth specifying how it would look like in config:

extensions:
    DrevOps\BehatScreenshotExtension:
      dir: %paths.base%/screenshots
      fail: true
      purge: false
      # New config option.
      filenamePattern: {datetime:u}.{feature_file}.feature_{step_line}.{ext}
      filenamePatternFailed: {datetime:u}.{fail_prefix}{feature_file}.feature_{step_line}.{ext}      

from behat-screenshot.

AlexSkrypnyk avatar AlexSkrypnyk commented on June 9, 2024

@tannguyen04
When working on this, please note that this implementation should work well with #28.

from behat-screenshot.

xurizaemon avatar xurizaemon commented on June 9, 2024

@tannguyen04 came across the config for this in a repo today and wondered how it had progressed. Did you get anywhere? Can I help in any way?

from behat-screenshot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.