Keep the suite's ordinary driver and register a second Chrome driver for the proxied route:

Capybara.register_driver :chrome_via_proxy do |app|
  options = Selenium::WebDriver::Chrome::Options.new
  options.add_argument('--proxy-server=http://proxy.example:8080')
  Capybara::Selenium::Driver.new(
    app, browser: :chrome, options: options
  )
end

Select it around the work that needs the route:

Capybara.using_driver(:chrome_via_proxy) do
  visit 'https://www.example.com/'
end

RSpec can also select a registered driver through driver metadata; follow the suite's existing integration. The proxy setting is a browser-creation argument, so registering this driver does not modify a browser already running under another driver. Switching drivers also does not transfer that browser's cookies or open connections.

The example uses an unauthenticated HTTP proxy, with public candidates available in the HTTP proxy list. An authenticated proxy needs a supported browser-authentication arrangement. If the test browser must reach a local application directly, set the intended exception in the browser's supported bypass configuration.

For a remote browser, evaluate both proxy and application reachability from that browser's machine.

Allakkat attuumassuteqartut