-
Notifications
You must be signed in to change notification settings - Fork 7
Added sample script which uses connectovercdp #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@Ishita-Jinturkar please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
puagarwa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add me readMe file with minimal instructions on how customer would use cdp from our service. Follow examples of playwright for guidance and reference.
| try { | ||
| console.log('🔌 Connecting to CDP server...'); | ||
| const browser = await chromium.connectOverCDP('ENTER YOUR CDP WEBSOCKET URL HERE', | ||
| {headers:{'User-Agent': 'Chrome-DevTools-Protocol/1.3'}}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this mandatory ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
This script retrieves the WebSocket URL for a remote browser using Playwright's API, handling environment variables and making asynchronous HTTP requests.
Add example environment configuration for Playwright service.
Added functionality to fetch CDP WebSocket URL from Playwright service and connect to the CDP server using it.
| import { chromium } from 'playwright'; | ||
|
|
||
| const WORKSPACE_ID = process.env.PLAYWRIGHT_SERVICE_WORKSPACE_ID; | ||
| const REGION = process.env.PLAYWRIGHT_SERVICE_REGION; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we keep this consistent with our other examples where we only ask browser regional endpoint and accesstoken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we modify the script for 2 api flow to support this? First call will go to auth
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the above comment , my expectation is that you ask customer to provide same two env variable which we ask endpoint and token and then internally you could parse and get other thing you need
| } | ||
|
|
||
| console.log('🌐 Navigating to Google...'); | ||
| await page.goto('https://google.com'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change this url to playwright.dev
| try { | ||
| console.log('🔍 Fetching CDP WebSocket URL...'); | ||
| const cdpUrl = await getRemoteBrowserWebSocketUrl(); | ||
| console.log('✅ Got WebSocket URL:', cdpUrl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets not log url, make it debug log
samples/cdp-tests/GetCdpUrl.py
Outdated
| @@ -0,0 +1,53 @@ | |||
| import aiohttp | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets remove this and we should add browser-use example here later.
Clear sensitive information from the example environment file.
Refactor to use Azure OpenAI instead of local Ollama LLM for Amazon product search.
Updated environment variable usage and added parsing for service URL.
Updated prerequisites and usage instructions. Refactored remote browser session creation and added dotenv support.
Updated the script to connect to a remote browser via CDP using Python. Added prerequisites and usage instructions.
Updated environment variable placeholders for Playwright and Azure OpenAI.
Updated script usage instructions and refactored remote browser session creation.
This file provides a Python client for Microsoft Playwright Service, including methods to retrieve a CDP endpoint URL for connecting to remote browsers. It includes error handling and environment variable support.
This script provides a testing framework using Microsoft Playwright Service to run tests on remote browsers via the Chrome DevTools Protocol. It includes context managers for easy browser and page access, example tests, and a test runner.
Added a README file with usage instructions and examples for Python CDP samples using Microsoft Playwright Service.
Added a sample js script which uses connectovercdp