我正在尝试使用来自 Github 的以下脚本:https ://github.com/php-webdriver/php-webdriver
在“/mnt/hgfs/”中使用 composer 安装很容易,但是在 php 文件中加载类似乎是不可能的
如您所见,名称中有一个连字符,我似乎无法以任何方式加载该类。我已经搜索了很多并尝试了很多东西,但同样的问题,我得到:
尝试在命名空间中使用连字符并使用我得到
PHP 解析错误:语法错误,意外的“-”,在第 3 行的 /mnt/hgfs/test.php 中需要“{”
用下划线替换连字符,或者只是删除它我得到:
PHP 致命错误:未捕获的错误:在 /mnt/hgfs/test.php:10 中找不到类 'php_webdriver\WebDriver\Remote\DesiredCapabilities'
这就是我的代码的外观(/mnt/hgfs/test.php):
namespace php_webdriver\WebDriver;
require 'vendor/autoload.php';
use php_webdriver\WebDriver\Chrome\ChromeOptions;
use php_webdriver\WebDriver\Chrome\ChromeDriver;
use php_webdriver\WebDriver\Remote\DesiredCapabilities;
use php_webdriver\WebDriver\Remote\RemoteWebDriver;
$host = 'http://localhost:4444/wd/hub'; // this is the default
$capabilities = DesiredCapabilities::htmlUnitWithJS();
{
$options = new ChromeOptions();
$options->addArguments(array(
'--disable-extensions',
'--no-sandbox',
'--headless',
'--no-proxy-server'
));
$capabilities = DesiredCapabilities::chrome();
$capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
$capabilities->setPlatform("Linux");
}
$driver_spec = RemoteWebDriver::create($host, $capabilities, 600000, 600000);
我应该如何加载这个类?
慕后森
拉风的咖菲猫
随时随地看视频慕课网APP