Created
October 2, 2024 05:48
-
-
Save VikashLoomba/18aff2fead43a0fd319defbd6066c16b to your computer and use it in GitHub Desktop.
Launch a custom firefox browser binary (camoufox) with Playwright
This file contains hidden or 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
| import { firefox } from 'playwright'; | |
| const config = { | |
| 'window.history.length': 4, | |
| 'navigator.language': 'en-US', | |
| 'navigator.languages': ['en-US'], | |
| }; | |
| const browserServer = await firefox.launchServer({ | |
| headless: false, | |
| args: ['--config', JSON.stringify(config)], | |
| port: 9222, | |
| // Path to the camoufox launch binary from a camoufox release | |
| executablePath: '/camoufox/launch', | |
| wsPath: '/session' | |
| }); | |
| const wsEndpoint = browserServer.wsEndpoint(); | |
| console.log(wsEndpoint); | |
| // Use web socket endpoint later to establish a connection. | |
| browserServer.on('close', () => { | |
| console.log('Browser server closed'); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment