Я пытаюсь использовать следующий скрипт из Github: https://github.com/php-webdriver/php-webdriver
Установка с composer в "/ mnt / hgfs /" была простой, но загрузка класс в файле php кажется невозможным
Как видите, в имени есть дефис, и я не могу загрузить класс каким-либо образом. Я много гуглил и перепробовал много вещей, но та же проблема, либо я получаю:
Пытаюсь использовать дефис в пространстве имен и получаю
PHP Ошибка разбора : синтаксическая ошибка, неожиданное '-', ожидание '{' в /mnt/hgfs/test.php в строке 3
Замена дефиса подчеркиванием или просто удаление его, я получаю:
PHP Неустранимая ошибка: необнаруженная ошибка: класс 'php_webdriver \ WebDriver \ Remote \ DesiredCapabilities' не найден в /mnt/hgfs/test.php:10
Вот так выглядит мой код (/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);
Как мне загрузить этот класс?