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

Place named-screenshots under the relevant test screenshots folder rather than the screenshots root #1974

Closed
adrianaisemberg opened this issue Nov 30, 2017 · 3 comments
Labels
STATE: Auto-locked An issue has been automatically locked by the Lock bot. TYPE: enhancement The accepted proposal for future implementation.

Comments

@adrianaisemberg
Copy link

Are you requesting a feature or reporting a bug?

Bug

What is the current behavior?

Taking named screenshots saves them under the screenshots root.
Compared to taking unnamed screenshots which saves those under the currently running test folder.

What is the expected behavior?

Save named screenshots to the same place as the unnamed (indexed) ones, or at least under a sibling folder.

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

  1. Write two different and unrelated tests.
  2. In each test, call to t.takeScreenshot("after-click")
  3. Run the tests
  4. Observe the screenshots folder. Notice that only one file exists although we took two screenshots.
    This is a result of the second test screenshot overwriting the first's.

This raises several concerns:

  1. If we want to report the test results and include all relevant screenshots of a certain test - we don't have a way to collect test-specific relevant named screenshots from the results folder.
  2. Using the same name results in overwriting screenshots. The only way to prevent this is to have strict naming constraints. However, those can't be enforced.

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

Tested page URL:

Test code

Specify your

  • operating system:
  • testcafe version:
  • node.js version:
@AndreyBelym
Copy link
Contributor

Hi @adrianaisemberg, we are working out a way to enable more flexible screenshots path, but now you can use the following approach as a workaround:

import { ClientFunction } from 'testcafe';
import { parse } from 'useragent';

fixture `Take a screenshot`
    .page `example.com`;

const getUserAgent = ClientFunction(() => navigator.userAgent.toString());

test('Take a screenshot with a custom path', async t => {
    const ua       = await getUserAgent();
    const parsedUA = parse(ua);

    await t.takeScreenshot('custom/' + parsedUA.family + '.png');
});

It will save screenshots to files according to browser names, e.g. custom/Chrome.png, custom/Firefox.png, etc.

@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
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

3 participants