Closed pjaneiro closed 3 years ago
Most (maybe all) drivers bypass proxies for localhost. I know I ran into this issue with PhantomJS in the past, but don't try to proxy localhost anymore so I'm not aware of any current workarounds. The PhantomJS workaround was to not use that driver for tests needing to proxy localhost.
I'd do some research on ways to force your driver to use a proxy which would then route through puffing-billy.
It was indeed an issue with the driver. For a driver based on Chrome, the following made it work:
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('ignore-certificate-errors')
options.add_argument("proxy-server=#{Billy.proxy.host}:#{Billy.proxy.port}")
options.add_argument('proxy-bypass-list=<-loopback>')
Closing the issue
I've tried using the
selenium_chrome_billy
andselenium_chrome_headless_billy
, as well as appendingoptions.add_argument("proxy-server=#{Billy.proxy.host}:#{Billy.proxy.port}")
to my existing Selenium/WebDriver/Chrome driver.I've messed quite a lot with the configurations, but currently they look like:
My stub is as simple as
However, anytime I run my test, the requests to this endpoint are still being made directly to the server, and the response is unaffected. I tried the sample snippet in the README.md that prints all requests at the end of the run, and requests to localhost are not being printed, nor is there any mention in the logs that the stub was created/called. I tried stubbing other requests in the exact same way, and everything works as expected, only localhost requests seem to be ignored.
Is this expected behavior? Am I missing something? Is there any other piece of information that might be relevant here?