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

How to remove duplicate screenshot name from report? #16456

Closed
thedavidhoffman opened this issue Aug 11, 2022 · 2 comments · Fixed by #16929
Closed

How to remove duplicate screenshot name from report? #16456

thedavidhoffman opened this issue Aug 11, 2022 · 2 comments · Fixed by #16929
Assignees

Comments

@thedavidhoffman
Copy link

When I add screenshots to a test, the test report displays the name twice. While, functionally, this isn't an issue, the detail oriented part of me is annoyed by this :)

const screenshot = await page.screenshot({ fullPage: true });
await test.info().attach(name, { body: screenshot, contentType: 'image/png' });

image

I have tried specifying the path when taking a screenshot, and that does not produce the duplicate file name in the report, however, I want to use the default behavior in Playwright for taking screenshots, as it cleans up the screenshot directory every time the tests are run.

@rwoll rwoll added the triaging label Aug 11, 2022
@rwoll
Copy link
Member

rwoll commented Aug 11, 2022

Is the issue that the text is repeated (like you have in the screenshot above), or is the issue if you call attach multiple times:

  const screenshot = await page.screenshot({ fullPage: true });
  await test.info().attach('should be login screen', { body: screenshot, contentType: 'image/png' });
  await test.info().attach('should be login screen', { body: screenshot, contentType: 'image/png' });

you end up with multiple screenshots in the report? Both?

Regardless, looks like we need to clean up the repetition and/or formatting that is observed in your screenshot! Thanks for pointing it out!

@rwoll rwoll self-assigned this Aug 11, 2022
@rwoll rwoll added v1.26 and removed triaging labels Aug 11, 2022
@thedavidhoffman
Copy link
Author

@rwoll
My tests are taking multiple screenshots throughout each test, but I'm only calling screenshot/attach once for each screenshot that is being taken.

So I have this type of code repeated throughout my tests...

const screenshot = await page.screenshot({ fullPage: true });
await test.info().attach(name, { body: screenshot, contentType: 'image/png' });

But nowhere that I am making a double call to attach, as you mentioned...

const screenshot = await page.screenshot({ fullPage: true });
await test.info().attach(name, { body: screenshot, contentType: 'image/png' });
await test.info().attach(name, { body: screenshot, contentType: 'image/png' });

It is only taking one screenshot, but listing the name as a link and as a text element right after the link.

image

Here's the markup being emitted by the report...

<a href="data/cb153e1d8e54b4eed0376a038565bff284c736af.png" target="_blank">should be login screen</a>
<span>should be login screen</span>

rwoll added a commit to rwoll/playwright that referenced this issue Aug 30, 2022
Fixes microsoft#16456.

The extra span/name was coming from
https://github.com/microsoft/playwright/blob/077b8a928960493a4cf275bc4fc4d4176b2a6098/packages/html-reporter/src/links.tsx#L72
(in conjunction with the line above it).

These two lines assume `path` and `body` are mutally exclusive.

Regression likely introduced by the PR that added the now removed line microsoft#10778.
dgozman pushed a commit that referenced this issue Sep 3, 2022
Fixes #16456.

The extra span/name was coming from
https://github.com/microsoft/playwright/blob/077b8a928960493a4cf275bc4fc4d4176b2a6098/packages/html-reporter/src/links.tsx#L72
(in conjunction with the line above it).

These two lines assume `path` and `body` are mutally exclusive.

Regression likely introduced by the PR that added the now removed line #10778.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants