Skip to content

Commit b5dae9a

Browse files
committed
Add troubleshooting for path not available issue
1 parent 671bc2d commit b5dae9a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

articles/playwright-testing/troubleshoot-test-run-failures.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,29 @@ Web applications often display the time based on the user's location. When you r
5050

5151
You can mitigate the issue by [specifying the time zone in the Playwright configuration file](https://playwright.dev/docs/emulation#locale--timezone).
5252

53+
## Test fails with `Path is not available when connecting remotely`
54+
55+
You might encounter the `Path is not available when connecting remotely` error when you run your Playwright tests on remote browsers with Microsoft Playwright Testing. For example, when you're testing the functionality to download a file in your test code.
56+
57+
The cause of this issue is that the `path()` function on the download file instance is not available when run on remote browsers.
58+
59+
To resolve this issue, you should use the `saveAs()` function to save a local copy of the file on your client machine. Learn more about [downloads in the Playwright documentation](https://playwright.dev/docs/downloads).
60+
61+
The following code snippet gives an example of how to use `saveAs()` instead of `path()` for reading the contents of a downloaded file:
62+
63+
```typescript
64+
const downloadPromise = page.waitForEvent('download');
65+
await page.getByText('Download file').click();
66+
67+
const download = await downloadPromise;
68+
69+
// FAILS: download.path() fails when connecting to a remote browser
70+
// const result = fs.readFileSync(await download.path(), 'utf-8');
71+
72+
// FIX: use saveAs() to download the file, when connecting to a remote browser
73+
await download.saveAs('/path/to/save/at/' + download.suggestedFilename());
74+
```
75+
5376
## Related content
5477

5578
- [Manage workspace access](./how-to-manage-workspace-access.md)

0 commit comments

Comments
 (0)