A proxy server can be used for various purposes, including enhancing security, improving performance or accessing content that may be restricted in your location.
When you access a website or online service, your requests pass through the proxy server before reaching the destination. The destination server sees the proxy server as the source of the request, it does not see your device.
Using a proxy
To use a proxy, you will need to configure your device's network settings to route traffic through the proxy server. This involves specifying the proxy server's address, port and any optional authentication credentials, if required.
Advantages of using a proxy
Proxies can enhance security by masking your IP address, which makes it more challenging for websites to track your online activities. They can also provide an additional layer of protection by filtering out malicious content.
Proxies can be used to unblock websites, which might be blocked by your organization or ISP.
Configuring a proxy with Selenium
To configure a proxy with Selenium, you can specify the proxy capability, which Selenium will use to configure your browser or OS with the proxy server and port you specified in your capabilities.
With WebDriver, you can specify different proxy types such as:
-
pac
: uses a pac file to configure the proxy -
direct
: do not use any proxy -
autodetect
/system
: detect if a proxy is configured by your operating system -
manual
: specify the host and port of the proxy
Configuring a proxy with Playwright
Playwright is able to set a proxy for the (remote) browser it is automating. You can simply specify a proxy
object as a launchOption
. Please see the example below.
const playwright = require('playwright')
const launchOptions = {
proxy: {
server: '1.1.1.1:80'
}
}
(async () => {
const browser = await playwright['chromium'].launch(launchOptions)
const context = await browser.newContext()
const page = await context.newPage()
await page.goto('https://testingbot.com')
await browser.close()
})()
TestingBot provides TestingBot Tunnel with Playwright, which will allow remote TestingBot browsers to reach restricted websites on your LAN.