-
Notifications
You must be signed in to change notification settings - Fork 42
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
Implement BrowserType.connect(wsEndpoint[, options])
#17
Comments
BrowserType.connect(wsEndpoint[, options])
It's an excellent next issue to work on because it's good to keep the browser open and try it with updated code while fixing bugs. So I've been researching about this feature, and I have a few things to clarify before I start working on this :) I appreciate your feedback 🙇 ❤️ 1st QuestionPlaywright.Connect method takes a browserType.connect(wsEndpoint[, options]) <Promise<Browser>>
wsEndpoint <string> A browser websocket endpoint to connect to.
...
// This method attaches Playwright to an existing browser instance. So we probably need to change the xk6-browser/api/browser_type.go Line 29 in 758d14b
To this: Connect(wsEndpoint string, opts goja.Value) 2nd QuestionWe probably need to add a new method to the module's API like this: func (m *JSModule) Connect(wsEndpoint string, opts goja.Value) api.Browser {
// k6common.Throw(m.vu.Runtime(), errors.New("In Progress 🚀"))
if browserName == "chromium" {
bt := chromium.NewBrowserType(m.vu.Context())
return bt.Connect(wsEndpoint, opts)
}
...
} And then call it like this: import chromium from 'k6/x/browser';
export default function() {
const browser = chromium.connect("wss://...", { ... });
const context = browser.newContext();
const page = context.newPage();
...
} 3rd QuestionIt seems like Playwright's This comment tells the difference:
Since we currently only support Chrome, we will need to adjust the Lines 104 to 106 in 758d14b
And here: Lines 110 to 113 in 758d14b
Then, we'll need to skip tracking the following when the Line 176 in 758d14b
Are we going to support closing the browser over CDP? As in here: Lines 341 to 359 in 758d14b
Even if we want to do so, I think we'll need to skip calling these: Lines 349 to 350 in 758d14b
In summary, the plan is to give WebSocket URL to a new |
|
Would be great to have this as browsers are launched in docker and connect is necessary to control the browser vs launch. |
We might want to resurrect this issue if we want to connect to a browser running in a Docker container. Also, the |
Add support for
BrowserType.connect(wsEndpoint[, options])
, to connect to an existing browser instance at specified CDP WS endpoint.Relevant links:
The text was updated successfully, but these errors were encountered: