Skip to content
Use proxy with a basic authentication with Chrome and Selenium
Branch: master
Clone or download
Pull request Compare This branch is 3 commits ahead, 24 commits behind henices:master.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Selenium Chrome HTTP Private Proxy

This plugin permit to use proxy with a basic authentication with Chrome and Selenium (it's impossible). This trick can be use for all basic auth in your test with Selenium and Chrome.

Thanks to henices who codes Chrome Proxy Helper. This fork uses it code base.

This plugin is maintained by Robin (PHP developer in Marseille). Report your issues with Github.

How to use it

I use webDriver with a PHP client. So, this example will be in PHP. The logic is the same with another language (java, python... same protocol).

$pluginForProxyLogin = '/tmp/a'.uniqid().'.zip';

$zip = new ZipArchive();
$res = $zip->open($pluginForProxyLogin, ZipArchive::CREATE | ZipArchive::OVERWRITE);
$zip->addFile('/path/to/Chrome-proxy-helper/manifest.json', 'manifest.json');
$background = file_get_contents('/path/to/Chrome-proxy-helper/background.js');
$background = str_replace(['%proxy_host', '%proxy_port', '%username', '%password'], ['', '54991', 'd1g1m00d', '13de02d0e0z9'], $background);
$zip->addFromString('background.js', $background);


$options = new ChromeOptions();
$caps = DesiredCapabilities::chrome();
$caps->setCapability(ChromeOptions::CAPABILITY, $options);

$driver = ChromeDriver::start($caps);

header('Content-Type: image/png');
echo $driver->takeScreenshot();

You can’t perform that action at this time.