Skip to content
Advertisement

Java Playwright using connect with Proxy for browserless

I want to use Playwright.connect() method using Proxy to consume Browserless. According to Browserless doc.

JavaScript

Playwright official website

The standard connect method uses playwright’s built-in browser-server to handle the connection. This, generally, is a faster and more fully-featured method since it supports most of the playwright parameters (such as using a proxy and more). However, since this requires the usage of playwright in our implementation, things like ad-blocking and stealth aren’t supported. In order to utilize those, you’ll need to see our integration with connectOverCDP.

I thought well connect will have a .setProxy(), Like launch()

JavaScript

But connect methods it has 2 variations

JavaScript

I thought well i will pick connect + ConnectOptions it sures has a .setProxy as well but it doesn’t.

JavaScript

I have try this

JavaScript

But the proxy returns authentication is required.

I’m confused now Browserless says that .connect could provide a Proxy but how? Is browserless wrong? Or am I missing something? I’m new on this technology.

I have tried as well using page.setExtraHTTPHeaders.

JavaScript

Advertisement

Answer

With the help of my friend Alejandro Loyola at Browserless, I am now able to connect. I will post the snippet:

JavaScript

My gotchas were as follows.

I was using:

JavaScript

Instead of:

JavaScript

And use:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement