Why can't I make chrome pick up the proxy I try to set?

68 Views Asked by At

I'm trying to make chromedriver to run through a proxy. I have tried the following:

options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--incognito')

# Set up the proxy
proxy = Selenium::WebDriver::Proxy.new(
  http:    "#{proxy_username}:#{proxy_password}@#{proxy_host}:#{proxy_port}",
  ftp:     "#{proxy_username}:#{proxy_password}@#{proxy_host}:#{proxy_port}",
  ssl:     "#{proxy_username}:#{proxy_password}@#{proxy_host}:#{proxy_port}"
)
options.proxy = proxy

# Initiate the browser
driver = Selenium::WebDriver.for :chrome, options: options
driver.navigate.to("https://whatismyipaddress.com")

However the IP is still my local IP not the proxy

I have also tried:

options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--incognito')
options.add_argument("--proxy-server=#{proxy_username}:#{proxy_password}@#{proxy_host}:#{proxy_port}")

# Initiate the browser
driver = Selenium::WebDriver.for :chrome, options: options
driver.navigate.to("https://whatismyipaddress.com")

However then I get a "cannot connect ERR_NO_SUPPORTED_PROXIES" in chrome.

I'm running:

  • OSx 13.2
  • Chrome: Version 116.0.5845.140 (official version) (arm64)
  • ChromeDriver 116.0.5845.96 (installed with homebrew)
  • Ruby 3.1
  • selenium-webdriver (4.11.0) gem
0

There are 0 best solutions below