我尝试以编程方式使用Laravel Dusk。当我尝试以下代码时:
use Symfony\Component\Process\Process;
use Facebook\WebDriver\Chrome\ChromeOptions;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
$driver = realpath(base_path() . '/vendor/laravel/dusk/bin/chromedriver-linux');
$process = new Process(
array_merge([realpath($driver)], []), null, ['DISPLAY' => ':0']
);
$process->start();
$options = (new ChromeOptions)->addArguments([]);
$capabilities = DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY, $options
);
return RemoteWebDriver::create(
'http://localhost:9515', $capabilities, 5000, 10000
);
我收到此错误。我尝试将FacebookWebDriver用作独立组件,并且也得到了相同的结果:
Curl error thrown for http POST to /session with params:
{"desiredCapabilities":
{"browserName":"chrome","platform":"ANY","chromeOptions":
{"binary":""}}} Operation timed out after 10001 milliseconds with 0 bytes received
有问题的端口未使用。无法找出代码出了什么问题。
答案 0 :(得分:-1)
通过将Selenium Standalone jar和chromedriver放在同一目录中来解决此问题。确保路径中包含文件夹目录。可能会对其他人有用。