Есть у меня проект на php-webdriver (facebook-webdriver), в котором использовался chrome-driver и chrome последних версий, так как с непоследними почему-то ничего не работало. Но сейчас и с последними проблема - начиная с Chrome 80 не работает ключ --disable-gpu, а без него Хроменький стартует и сразу вылетает с ошибкой GPU. (поправочка: раньше работало и без --disable-gpu. Почему не работает сейчас - не знаю). При этом нормально работает в headless-режиме, но мне нужно окно. С Firefox же вообще изначально не заладилось, но там драйвер ещё в бета-версии, так что я смирился, и пользовался Хромом.
Нет ли у кого заведомо рабочего свежего кода для php-webdriver? Не важно с каким браузером и какой версии.
Что до текущих ошибок, то они такие:
Со свежим хромом в консоли webdriver-manager:
12:21:50.029 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"chromeOptions": {
"binary": "",
"args": [
"--disable-gpu",
"--user-data-dir=\u002ftmp\u002fchrome",
"--no-sandbox",
"--user-agent=Mozilla\u002f5.0 (Windows NT 6.3; Win64; x64) AppleWebKit\u002f537.36 (KHTML, like Gecko) Chrome\u002f81.0.4044.122 Safari\u002f537.36"
]
}
}
12:21:50.029 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 83.0.4103.39 (ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/4103@{#416}) on port 28239
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-conside... for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
[1590312110,385][SEVERE]: Unable to receive message from renderer
В chrome-debug.log:
[12222:12236:0524/122150.245334:WARNING:gpu_process_host.cc(1217)] The GPU process has crashed 1 time(s)
[12222:12253:0524/122150.252709:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[12222:12253:0524/122150.252761:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[12222:12253:0524/122150.264437:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[12222:12253:0524/122150.264501:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[12222:12236:0524/122150.297853:WARNING:gpu_process_host.cc(1217)] The GPU process has crashed 2 time(s)
[12222:12236:0524/122150.305023:WARNING:gpu_process_host.cc(1217)] The GPU process has crashed 3 time(s)
[12222:12236:0524/122150.317477:WARNING:gpu_process_host.cc(1217)] The GPU process has crashed 4 time(s)
[12222:12236:0524/122150.345186:WARNING:gpu_process_host.cc(1217)] The GPU process has crashed 5 time(s)
[12222:12236:0524/122150.378038:WARNING:gpu_process_host.cc(1217)] The GPU process has crashed 6 time(s)
[12222:12236:0524/122150.378121:FATAL:gpu_data_manager_impl_private.cc(439)] GPU process isn't usable. Goodbye.
При старой версии Хрома он не стартует вообше, соответсвенно в его логах пусто. В логах webdriver-manager ошибок нет:
12:48:55.694 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"chromeOptions": {
"binary": "",
"args": [
"--disable-gpu",
"--user-data-dir=\u002ftmp\u002fchrome",
"--no-sandbox"
]
}
}
12:48:55.694 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
А в выводе PHP такое:
Fatal error: Uncaught Facebook\WebDriver\Exception\SessionNotCreatedException: Unable to create new service: ChromeDriverService
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'lat', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-101-generic', java.version: '14.0.1'
Driver info: driver.version: unknown in /home/me/sc/vendor/php-webdriver/webdriver/lib/Exception/WebDriverException.php:125
Stack trace:
#0 /home/me/sc/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php(370): Facebook\WebDriver\Exception\WebDriverException::throwException('session not cre...', 'Unable to creat...', Array)
#1 /home/me/sc/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php(136): Facebook\WebDriver\Remote\HttpCommandExecutor->execute(Object(Facebook\WebDriver\Remote\WebDriverCommand))
#2 /home/me/sc/test.php(14): Facebook\WebDriver\Remote\RemoteWebDriver::create('http://localhos...', Object(Facebook\WebDriver\Remote\DesiredCapabilities))
#3 in /home/me/sc/vendor/php-webdriver/webdriver/lib/Exception/WebDriverException.php on line 125
Сам тестовый код выглядит так:
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
use Facebook\WebDriver\Chrome\ChromeOptions;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
require_once(__DIR__ . '/vendor/autoload.php');
$options = new ChromeOptions();
$options->addArguments(array('--disable-gpu'));
$options->addArguments(array('--user-data-dir=/tmp/chrome'));
$options->addArguments(array("--no-sandbox"));
$caps = DesiredCapabilities::chrome();
$caps->setCapability(ChromeOptions::CAPABILITY, $options); // constant CAPABILITY is deprecated, но что вместо неё - не нашел
$driver = RemoteWebDriver::create('http://localhost:4444/wd/hub/', $caps);
$driver->get('http://ya.ru');
var_dump($driver->getPageSource());