Open pauloacosta opened 4 years ago
You need to install Chrome
For example, I am using ubuntu 18 $ wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb $ sudo apt install ./google-chrome-stable_current_amd64.deb
I am using Windows 10 and Chrome is installed at default folder: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
Is there a file where I set up the Chrome address?
You can specific Chrome path like this:
$launcher = new Launcher();
$launcher->setExecutable('/usr/bin/google-chrome-stable');
$instance = $launcher->launch();
Thank You! Worked like a charm!
I am a Windows user, then my code was:
// launcher starts chrome process ($instance)
$launcher = new Launcher();
$launcher->setExecutable('C:\Program Files (x86)\Google\Chrome\Application');
$instance = $launcher->launch($ctx);
Fatal error: Uncaught ChromeDevtoolsProtocol\Exception\RuntimeException: Executable [chrome] not found. in C:\xampp\htdocs\vendor\jakubkulhan\chrome-devtools-protocol\src\ChromeDevtoolsProtocol\Instance\Launcher.php:139 Stack trace: #0 C:\xampp\htdocs\index.php(17): ChromeDevtoolsProtocol\Instance\Launcher->launch(Object(ChromeDevtoolsProtocol\Context)) #1 {main} thrown in C:\xampp\htdocs\vendor\jakubkulhan\chrome-devtools-protocol\src\ChromeDevtoolsProtocol\Instance\Launcher.php on line 139
Code:
`<?php
require "./vendor/autoload.php";
use ChromeDevtoolsProtocol\Context; use ChromeDevtoolsProtocol\Instance\Launcher; use ChromeDevtoolsProtocol\Model\Page\PrintToPDFRequest; use ChromeDevtoolsProtocol\Model\Page\NavigateRequest;
@unlink(DIR . '/test.pdf');
// context creates deadline for operations $ctx = Context::withTimeout(Context::background(), 30 / seconds /);
// launcher starts chrome process ($instance) $launcher = new Launcher(); $instance = $launcher->launch($ctx);
try { // work with new tab $tab = $instance->open($ctx); $tab->activate($ctx);
} finally { // process needs to be killed $instance->close(); }`
Any idea what could be going on? Is there a place where I set the Chrome address? On my system it is installed at the default address.