adding getCdpUrl and playwright examlpe

This commit is contained in:
Tommy D. Rossi
2025-11-16 12:26:06 +01:00
parent 3a1de6d9c7
commit b5d48296b5
6 changed files with 41 additions and 6 deletions
+27
View File
@@ -7,6 +7,8 @@
<br/>
</div>
## Comparison
### BrowserMCP
@@ -34,3 +36,28 @@ Navigation:
- `browsermcp_browser_press_key` - Press a key on the keyboard
Utilities:
- `browsermcp_browser_wait` - Wait for a specified time in seconds
### Using with Playwright
You can use playwriter programmatically with playwright-core:
```typescript
import { chromium } from 'playwright-core'
import { startPlayWriterCDPRelayServer, getCdpUrl } from 'playwriter'
const port = 19987
const server = await startPlayWriterCDPRelayServer({ port })
const browser = await chromium.connectOverCDP(getCdpUrl({ port }))
const context = browser.contexts()[0]
const page = context.pages()[0]
await page.goto('https://example.com')
await page.screenshot({ path: 'screenshot.png' })
await browser.close()
server.close()
```