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

[BUG] page.screenshot doesn't create folder if needed #2930

Closed
leandromuto opened this issue Jul 13, 2020 · 0 comments · Fixed by #3247
Closed

[BUG] page.screenshot doesn't create folder if needed #2930

leandromuto opened this issue Jul 13, 2020 · 0 comments · Fixed by #3247

Comments

@leandromuto
Copy link

leandromuto commented Jul 13, 2020

Context:

  • Playwright Version: 1.2.0
  • Operating System: Mac
  • Node version: 12.13.0
  • Browser: Chromium
  • Extra: using playwright-video plugin

Code Snippet

const { chromium } = require('playwright')
const { saveVideo } = require('playwright-video');

describe('user', function() {

  beforeEach(async function() {
    // await saveVideo(page, `/tmp/video/${this.test.ctx.currentTest.title.replace(' ', '_')}.mp4`);
  })

  afterEach(async function() {
    await page.screenshot({ path: `/tmp/${this.test.ctx.currentTest.title}.png` })
  })

  describe('edit', function() {
    it('user info', async function() {
     ...
    })
  })
}

Describe the bug

I'm using Mocha to run my tests and I'm trying to store the screenshots taken on a tmp folder on the project root. If the folder doesn't exist, page.screenshot returns the following error:

Error: ENOENT: no such file or directory, open 'tmp/user info.png'
Note: use DEBUG=pw:api environment variable and rerun to capture Playwright logs.
    -- ASYNC --
      at Page.screenshot (node_modules/playwright/lib/helper.js:78:23)
      at Context.<anonymous> (test/mocha/user.js:62:16)
      at processImmediate (internal/timers.js:439:21)

PoC
In the first run, I had saveVideo function being called, and it created the tmp folder on the root. In the second run, I commented the saveVideo line and removed the previously created folder to see if page.screenshot were able to create a new folder. Recorded a video to demonstrate the scenario. 👇

https://www.loom.com/share/4f6fe2f6289e41d09e27a40d02a7f54d

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.

1 participant