问题
I have looked at the docks and searched the code but can find no mention of proxy support.
So it seems there is no native way to do this.
However I have found the following code that allows the headless chrome binary to be used with proxy settings.
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--proxy-server=http://user:password@proxy.com:8080"));
WebDriver driver = new ChromeDriver(capabilities);
So my question is where can I add this code in Dusk to allow me to use a proxy server with Dusk and the headless chrome in it?
回答1:
If you go to tests/DuskTestCase.php
you will see fragment of code like this:
return RemoteWebDriver::create(
'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY, $options
)
);
so I believe you should change this into:
来源:https://stackoverflow.com/questions/46486671/using-a-proxy-server-with-laravel-dusk