Using a proxy server with Laravel Dusk

和自甴很熟 提交于 2019-12-25 01:46:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!