使用 Laravel Dusk 的代理服务器
Using a proxy server with Laravel Dusk
我查看了 docks 并搜索了代码,但找不到任何提及代理支持的内容。
所以似乎没有本地方法可以做到这一点。
但是我发现以下代码允许无头 chrome 二进制文件与代理设置一起使用。
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--proxy-server=http://user:password@proxy.com:8080"));
WebDriver driver = new ChromeDriver(capabilities);
所以我的问题是我在哪里可以在 Dusk 中添加此代码以允许我使用带有 Dusk 的代理服务器和其中的无头 chrome?
如果你去 tests/DuskTestCase.php
你会看到这样的代码片段:
return RemoteWebDriver::create(
'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY, $options
)
);
所以我认为您应该将其更改为:
我查看了 docks 并搜索了代码,但找不到任何提及代理支持的内容。
所以似乎没有本地方法可以做到这一点。
但是我发现以下代码允许无头 chrome 二进制文件与代理设置一起使用。
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--proxy-server=http://user:password@proxy.com:8080"));
WebDriver driver = new ChromeDriver(capabilities);
所以我的问题是我在哪里可以在 Dusk 中添加此代码以允许我使用带有 Dusk 的代理服务器和其中的无头 chrome?
如果你去 tests/DuskTestCase.php
你会看到这样的代码片段:
return RemoteWebDriver::create(
'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY, $options
)
);
所以我认为您应该将其更改为: