Skip to content

Fail on intialization #26

@pauloacosta

Description

@pauloacosta

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);

$devtools = $tab->devtools();
try {
	$devtools->page()->enable($ctx);
	$devtools->page()->navigate($ctx, NavigateRequest::builder()->setUrl("https://www.google.com/")->build());
	$devtools->page()->awaitLoadEventFired($ctx);
    $data = $devtools->page()->printToPDF($ctx, PrintToPDFRequest::fromJson((object) [
        'displayHeaderFooter' => false
    ]))->data;
    file_put_contents(__DIR__ . '/../test.pdf', base64_decode($data));
} finally {
	// devtools client needs to be closed
	$devtools->close();
}

} 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions