使用php启动selenium网络驱动程序



启动selenium网络驱动程序时出现问题当我开始使用时

chromedriver --port=4444

运行php文件并得到错误

PHP Fatal error:  Uncaught FacebookWebDriverExceptionWebDriverException: JSON decoding of remote response failed.
Error code: 4

https://prnt.sc/wcmlga

尝试了其他命令

java -jar selenium-server-standalone-3.141.59.jar
java -Dwebdriver.chrome.driver="chromedriver.exe" -jar selenium-server-standalone-3.141.59.jar

得到相同的错误

这是我的php代码

$host = 'http://localhost:4444';
$capabilities = DesiredCapabilities::chrome();
$options = new ChromeOptions();
// $options->addArguments(['--headless', 'window-size=1024,768']);
$options->addArguments(['--disable-extensions',]);
$options->setExperimentalOption('excludeSwitches', ['enable-logging','enable-automation']);
$options->setExperimentalOption('useAutomationExtension', false);
$options->setExperimentalOption('w3c', false);
$options->setExperimentalOption('prefs', array(
"download.prompt_for_download" => false,
"download.default_directory" => "/tmp",
"profile.default_content_setting_values.notifications" => 2,
"profile.password_manager_enabled" => false,
"credentials_enable_service" => false
));
$capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
$driver = RemoteWebDriver::create($host, $capabilities);

selenium正在进行屏幕拍摄https://prnt.sc/wcmjw1

经过几次体验,我发现我的错误,所有命令都没有错。

使用java -Dwebdriver.chrome.driver="chromedriver.exe" -jar selenium-server-standalone-3.141.59.jar

我忘记更新chromedriver.exe

更新chromedriver.exe后,我的问题已经解决

相关内容

最新更新