QA & Automation · November 26, 2026 · 6 min read · Ler em português
How to use a proxy in Selenium (Chrome and Firefox)
How to set up a proxy in Selenium with Chrome and Firefox, the username-and-password authentication problem, the IP authorization workaround and good IP rotation practices in automation.
Selenium drives a real browser, which makes it great for tests and automations that need to run JavaScript. Setting the proxy is simple; authentication is what complicates things, because Chrome doesn't accept a username and password on the command line. Here's how to solve it.
Chrome: proxy from the command line
In Chrome, the proxy goes in as an argument: options.add_argument("--proxy-server=http://host:port") or, for SOCKS5, socks5://host:port. The browser opens through the proxy, but without username and password, because that argument doesn't take credentials.
The authentication problem
With an authenticated proxy, Chrome opens a window asking for username and password, and Selenium can't fill that window through normal means. There are three ways out:
- IP authorization: in the proxys.app panel you enter the IP of the server where Selenium runs, and the proxy accepts connections from it without a password. It's the simplest option for servers with a fixed IP.
- A small Chrome extension that answers the authentication request with the credentials. It works, but it's one more component to maintain.
- Switching to Playwright, which accepts proxy username and password directly in the browser settings.
Firefox
In Firefox, the proxy is set through profile preferences (manual proxy type, host and port for HTTP or SOCKS). Authentication has the same password-window problem, and IP authorization solves it the same way.
Checking and rotating the IP
At the start of the test, open a "what is my IP" page and log the IP: if something goes wrong later, you know where the test exited from. To rotate the IP between runs, use the Monthly plan's rotation link (one GET call, one rotation per minute per proxy) and wait a few seconds before opening the browser again. Don't rotate the IP with the browser logged in mid-flow: to the site, the session suddenly came from somewhere else.
Several browsers in parallel
The Mobile Proxy has no limit on simultaneous connections, so several browsers can exit through the same proxy. Remember that they all show the same IP. If tests simulate different users who shouldn't look like the same person, use one proxy per group of browsers.
Ready to run on a dedicated Mobile Proxy?