oesmith / puffing-billy

A rewriting web proxy for testing interactions between your browser and external sites. Works with ruby + rspec.
MIT License
662 stars 168 forks source link

cuprite driver support ? #326

Closed zedtux closed 2 years ago

zedtux commented 2 years ago

After having faced slow builds, we have migrated to the Cuprite driver and we're now looking to use this gem but there's nothing about Cuprite here.

The only thing I found is comment from @thbar in the issue #259 talking to the Cuprite guys.

So is there any way to use that gem with Cuprite today, or should a new driver being added to that gem in order to get it working with Cuprite please ? (Like duplicating the register_apparition_driver method, but for the Cuprite driver, and loading capybara/cuprite intead of capybara/apparition).

zedtux commented 2 years ago

I've forked this repo and tried to add the cuprite driver like describe above, and Cucumber runs like before, meaning like if puffing-billy is not installed...

So my setup is made with Docker, with my rails container running my app, cucumber, and the Capybara's server to expose the app to the browser, which runs in another container using the browserless Docker image.

I have configure puffing-billy in order to run on port 3002 with the host rails (the name of the container where is running puffing-billy) and it works when I curl the proxy from the chrome container with :+1:

curl --proxy http://rails:3002 http://www.google.com

It's intended to use a HTTP URL in order to avoid any possible issues about SSL/TLS verifications

I can see the puts from my before_handle_request block.

I though then that the set_proxy method from cuprite doesn't work with my Chrome version 94, so I've checked the running commands with ps aux from the chrome container, and I wasn't able to find the port 3002, nor the host rails ...

I will check on the cuprite side if there's an issue with set_proxy, I would appreciate if anyone could tell me if puffing-billy works with a remote browser (no matter the driver) ?

zedtux commented 2 years ago

Here is what I found :

I'm now investigating how to pass that proxy-server option even do the browser is in remote.

ronwsmith commented 2 years ago

Puffing-billy just acts as the proxy for your browser. It's not a standalone thing.

You should just be able to use cuprite's proxy setting:

page.driver.set_proxy(ip, port, type, user, password)

with Billy.proxy.host and Billy.proxy.port (not sure if the others are required)

zedtux commented 2 years ago

Thank you for your comment, but like I'm showing in my various component, I'm actually not only requesting support for cuprite in this gem, but also implementing proxy setting in remote browser -- at least for Cuprite -- in the Ferrum gem.

I'm just sharing my finds in the case it could help someone else who would try to use puffing-billy with another driver and a remote web browser.

Anyway, it's good to know that without implementing a driver in this gem we can still use it with page.driver.set_proxy.

zedtux commented 2 years ago

The cuprite driver config has been published in version 3.0.4 :tada: