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

Screenshots custom naming #1651

Closed
adamorlowskipoland opened this issue Jul 27, 2017 · 5 comments
Closed

Screenshots custom naming #1651

adamorlowskipoland opened this issue Jul 27, 2017 · 5 comments
Assignees
Labels
AREA: server STATE: Auto-locked An issue has been automatically locked by the Lock bot. TYPE: enhancement The accepted proposal for future implementation.
Milestone

Comments

@adamorlowskipoland
Copy link

Are you requesting a feature or reporting a bug?

requesting a feature

What is the current behavior?

Current default settings for saving a screenshot is:
{currentDate}\test-{testIndex}{userAgent}{screenshotIndex}.png; {currentDate}\test-{testIndex}\run-{quarantineAttempt}{userAgent}{screenshotIndex}.png if quarantine mode is enabled.

What is the expected behavior?

Screenshot will be named:
'userAgent ' + 'screenshotIndex' + '.png'
V
{currentDate}\test-{testIndex}{userAgent}{userAgentscreenshotIndex}.png

How would you reproduce the current behavior (if this is a bug)?

Provide the test code and the tested page URL (if applicable)

Tested page URL:

Test code

Specify your

  • operating system:
    Windows 10 Home
    10.0.15063
  • testcafe version:
    "testcafe": "^0.16.2",
  • node.js version:
    v6.10.3
@helen-dikareva
Copy link
Collaborator

So far, you can specify a custom path to save a screenshot to only when you take screenshots using the takeScreenshot action. Anyway, we like your idea to create a template for the screenshot path, we will think about a better way to implement it.

@thireven
Copy link

thireven commented Oct 2, 2017

I wrote this helper function to manage how my screenshots are saved:

function screenshotPath(t, ...args) {
  let filename = args.pop();
  const currentTest = t.testRun.test;
  const browser = t.testRun.browserConnection;

  const pathArray = [
    browser.browserInfo.userAgent.replace('/', '_'), // Browser and OS
    currentTest.fixture.name, // Fixture name
    currentTest.name, // Test name
    ...args
  ];

  const path = pathArray.join('/').replace(/\s/g, '-');
  
  if (screenshotMap[path] === undefined) {
    screenshotMap[path] = -1;
  }
  screenshotMap[path]++;

  const numberIndex = (`000${screenshotMap[path]}`).slice(-3);
  filename = `${numberIndex}.${filename}`;
  return `${path}/${filename}`;
}

I'm also building an internal GUI for testcafe and would love to be able to apply screenshot path "filters" in the CLI. For instance, something like: <path to screenshots>/%BROWSER%/%FIXTURE_NAME%/%TEST_NAME%/%NUMBERED%_%FILENAME%

I don't suppose it's something that can feasibly be done in the CLI right now?

@helen-dikareva
Copy link
Collaborator

Hello @thireven
This feature request is not included in our nearest sprints, but we are going to implement setting templates for screenshot paths. You can create your own TestCafe fork, PRs are always welcome.
And please vote for the features you like.

@AlexanderMoskovkin
Copy link
Contributor

closed in favor of #2152

miherlosev added a commit that referenced this issue Jul 6, 2018
* Screenshot file pattern

* refactor test constrants

* small refactoring

* renames

* don't correct file path for custom file path

* try to fix tests2

* revert back correct file path for custom path

* revert dedent module

* fix review issues
@AndreyBelym AndreyBelym added TYPE: enhancement The accepted proposal for future implementation. and removed TYPE: proposal labels Feb 6, 2019
@lock
Copy link

lock bot commented Mar 27, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests. For TestCafe API, usage and configuration inquiries, we recommend asking them on StackOverflow.

@lock lock bot added the STATE: Auto-locked An issue has been automatically locked by the Lock bot. label Mar 27, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
AREA: server STATE: Auto-locked An issue has been automatically locked by the Lock bot. TYPE: enhancement The accepted proposal for future implementation.
Projects
None yet
Development

No branches or pull requests

6 participants