forked from microsoft/playwright
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new commands to list installed browsers. Solves microsoft#34183 * Add `playwright ls` command to list installed browsers in `packages/playwright-core/src/cli/commands/ls.ts`. * Add `--list` option to `npx playwright install` command in `packages/playwright-core/src/cli/commands/install.ts`. * Register the new `ls` command in the CLI program in `packages/playwright-core/src/cli/program.ts`. * Write tests for the `playwright ls` command in `packages/playwright-core/src/cli/commands/ls.test.ts`. * Add documentation for the new `playwright ls` command and `--list` option in `docs/src/cli.md`. * Update `.github/actions/run-test/action.yml` to use `npx playwright install --with-deps --list` to list installed browsers.
- Loading branch information
Showing
6 changed files
with
130 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Playwright CLI | ||
|
||
## `playwright ls` | ||
|
||
List installed browsers. | ||
|
||
### Usage | ||
|
||
```sh | ||
npx playwright ls | ||
``` | ||
|
||
### Description | ||
|
||
The `playwright ls` command lists all installed browsers along with their versions and installation locations. | ||
|
||
### Example | ||
|
||
```sh | ||
$ npx playwright ls | ||
Browser: chromium | ||
Version: 91.0.4472.124 | ||
Install location: /path/to/chromium | ||
|
||
Browser: firefox | ||
Version: 89.0 | ||
Install location: /path/to/firefox | ||
|
||
Browser: webkit | ||
Version: 14.2 | ||
Install location: /path/to/webkit | ||
``` | ||
|
||
## `npx playwright install --list` | ||
|
||
List installed browsers after installing them. | ||
|
||
### Usage | ||
|
||
```sh | ||
npx playwright install --list | ||
``` | ||
|
||
### Description | ||
|
||
The `--list` option for the `npx playwright install` command lists all installed browsers along with their versions and installation locations after installing them. | ||
|
||
### Example | ||
|
||
```sh | ||
$ npx playwright install --list | ||
Installing browsers... | ||
Browser: chromium | ||
Version: 91.0.4472.124 | ||
Install location: /path/to/chromium | ||
|
||
Browser: firefox | ||
Version: 89.0 | ||
Install location: /path/to/firefox | ||
|
||
Browser: webkit | ||
Version: 14.2 | ||
Install location: /path/to/webkit | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { registry } from '../../server'; | ||
import { gracefullyProcessExitDoNotHang } from '../../utils'; | ||
|
||
async function listInstalledBrowsers() { | ||
try { | ||
const executables = registry.executables(); | ||
for (const executable of executables) { | ||
if (executable.installType !== 'none') { | ||
console.log(`Browser: ${executable.name}`); | ||
console.log(` Version: ${executable.browserVersion}`); | ||
console.log(` Install location: ${executable.directory}`); | ||
console.log(''); | ||
} | ||
} | ||
} catch (e) { | ||
console.log(`Failed to list installed browsers\n${e}`); | ||
gracefullyProcessExitDoNotHang(1); | ||
} | ||
} | ||
|
||
export { listInstalledBrowsers }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { execSync } from 'child_process'; | ||
import { expect, test } from '@playwright/test'; | ||
|
||
test('playwright ls command should list installed browsers', async () => { | ||
const result = execSync('npx playwright ls').toString(); | ||
expect(result).toContain('Browser:'); | ||
expect(result).toContain('Version:'); | ||
expect(result).toContain('Install location:'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { registry } from '../../server'; | ||
import { gracefullyProcessExitDoNotHang } from '../../utils'; | ||
|
||
async function listInstalledBrowsers() { | ||
try { | ||
const executables = registry.executables(); | ||
for (const executable of executables) { | ||
if (executable.installType !== 'none') { | ||
console.log(`Browser: ${executable.name}`); | ||
console.log(` Version: ${executable.browserVersion}`); | ||
console.log(` Install location: ${executable.directory}`); | ||
console.log(''); | ||
} | ||
} | ||
} catch (e) { | ||
console.log(`Failed to list installed browsers\n${e}`); | ||
gracefullyProcessExitDoNotHang(1); | ||
} | ||
} | ||
|
||
export { listInstalledBrowsers }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters