I am working with Playwright and setting up tests using Aerokube Moon. In my configuration, I connect remotely to the browser using chromium.connect, which allows me to pass additional parameters through the URL. Here’s an example of my code:
`if (moonConfig.enableMoon) { console.log("Starting test via Aerokube - Moon");
const wsUrl = new URL(moonConfig.remoteUrl);
// For each key in capabilities:
// If the value is an array, add each element as a separate parameter,
// otherwise set the parameter directly.
for (const [key, value] of Object.entries(moonConfig.capabilities)) {
if (Array.isArray(value)) {
for (const item of value) {
wsUrl.searchParams.append(key, item);
}
} else {
wsUrl.searchParams.set(key, value);
}
}
this.browser = await chromium.connect({ wsEndpoint: wsUrl.toString() });
this.context = await this.browser.newContext({ viewport: { width: 1920, height: 1080 } });
this.page = await this.context.newPage();
}`
The issue is that using newContext() creates an incognito context where I cannot use extensions. I need a persistent context (to load extensions), which is typically created using the launchPersistentContext method.
However, if I try to use launchPersistentContext, I get type errors because this method is not supported when using remote connections via chromium.connect.
My question: Is there any workaround to use a persistent context (with extension support) when connecting remotely via Aerokube Moon? Or do I need to separate the launch logic based on the environment (i.e., local for persistent context and remote for incognito context)?
Any advice or alternative approaches would be greatly appreciated.
Thank you!
I attempted to use launchPersistentContext when connecting via Aerokube Moon, expecting to get a persistent context with extension support. Instead, I got type errors since persistent contexts aren’t supported with remote connections; chromium.connect only allows creating incognito contexts via newContext()