将代理服务器与Laravel Dusk一起使用 [英] Using a proxy server with Laravel Dusk

查看:76
本文介绍了将代理服务器与Laravel Dusk一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经查看了扩展坞并搜索了代码,但找不到代理支持.

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.

但是我发现以下代码允许无头chrome二进制文件与代理设置一起使用.

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?

推荐答案

如果转到tests/DuskTestCase.php,您将看到如下代码片段:

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:

这篇关于将代理服务器与Laravel Dusk一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆