Repository navigation
Closed
Description
Version
1.42.1
Steps to reproduce
On windows using playwright library (not testing suite) add this code:
import { chromium, devices } from "playwright";
import { access } from "fs/promises";
(async () => {
const browser = await chromium.launch();
const context = await browser.newContext({
...devices["iPhone 11"],
recordVideo: { dir: "videos" },
});
const urls = [
"https://www.google.com",
"https://www.github.com",
"https://www.microsoft.com",
"https://www.stackoverflow.com",
"https://www.npmjs.com",
];
const pagePromises = urls.map(async (url) => {
const page = await context.newPage();
await context.route("**.jpg", (route) => route.abort());
console.log("Visiting", url);
await page.goto(url);
await page.emulateMedia({ reducedMotion: "reduce" });
await page.waitForLoadState("load");
await page.close();
const video = page.video();
console.log(await video.path());
const urlObject = new URL(url);
await video.saveAs(
`videos/video-${urlObject.hostname.split(".")[1]}.mp4"`
);
});
await Promise.all(pagePromises);
await context.close();
await browser.close();
})();Expected behavior
I expect the video name to turn from [guid].webm to video-[url.hostname].webm
Actual behavior
Despite the file existing (validated via 3 different ways, powershell list dir, playwright video.path, and using fs/promises access) I get this error:
node:internal/process/promises:289
triggerUncaughtException(err, true /* fromPromise */);
^
video.saveAs: ENOENT: no such file or directory, copyfile 'D:\repos\LeadLens\playwright-new\videos\56a49c38ac81cf02ae7dd81248875d35.webm' -> 'D:\repos\LeadLens\playwright-new\videos\video-google.mp4"'
at D:\repos\LeadLens\playwright-new\async file:\D:\repos\LeadLens\playwright-new\index.js:44:9
at D:\repos\LeadLens\playwright-new\async file:\D:\repos\LeadLens\playwright-new\index.js:49:5 {
name: 'Error'
}
Node.js v21.5.0
Additional context
No response
Environment
System:
OS: Windows 11 10.0.22631
CPU: (12) x64 Intel(R) Core(TM) i5-10400F CPU @ 2.90GHz
Memory: 6.21 GB / 15.94 GB
Binaries:
Node: 21.5.0 - C:\Program Files\nodejs\node.EXE
npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD
IDEs:
VSCode: 1.87.2 - C:\Users\morde\AppData\Local\Programs\Microsoft VS Code\bin\code.CMD
Languages:
Bash: 5.1.16 - C:\Windows\system32\bash.EXE
npmPackages:
playwright: ^1.42.1 => 1.42.1Metadata
Metadata
Assignees
Labels
No labels
Activity
yury-s commentedon Mar 20, 2024
You have a stray
"in the end of the file path (...}.mp4"). Removing it will fix the error. The error message is a misleading but this is whatfs.promises.copyFilethrows on Windows for such path.MordechaiHadad commentedon Mar 21, 2024
well that was emberassing