symfony / panther

A browser testing and web crawling library for PHP and Symfony
MIT License
2.94k stars 222 forks source link

cannot find Chrome binary #83

Closed lava83 closed 3 years ago

lava83 commented 6 years ago

Hy,

on a new installation, I'll testing the example request code on a laravel installation and will become, with the default configuration the following error:

unknown error: cannot find Chrome binary (Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Linux 4.4.0-131-generic x86_64)

The binaries are avalaible and executable. I've tested the chromium X64 binary for linux on the command line interface and can resolve the status from the server.

For the completenes here the code to test symfony/panther:

Route::get('test', function(){
    $client = \Symfony\Component\Panther\Client::createChromeClient();
    $crawler = $client->request('GET', 'http://api-platform.com'); // Yes, this website is 100% in JavaScript

    $link = $crawler->selectLink('Support')->link();
    $crawler = $client->click($link);

    // Wait for an element to be rendered
    $client->waitFor('.support');

    echo $crawler->filter('.support')->text();
    $client->takeScreenshot('screen.png');
});
bobrain008 commented 6 years ago

Hello, I have the same issue here on CentOS 7. How to correctly launch Chrome and navigate, please?

bobrain008 commented 6 years ago

Here I had to yum install chromium

pgrimaud commented 5 years ago

Or apt-get install chromium on some distros 🙄

This issue can be closed I guess.

michaelKaefer commented 5 years ago

Is there a solution if you can not use yum nor apt-get on the machine you want to run the PHP file? We can not run either of them on our NAS nor on our managed servers.

pgrimaud commented 5 years ago

@michaelKaefer You can set path of $chromeDriverBinary when you create your Chrome client :

https://github.com/symfony/panther/blob/770cfeeb57da4ba85f809652a5af8b56bc1cba18/src/Client.php#L58

\Symfony\Component\Panther\Client::createChromeClient('/path/of/your/chrome/driver/on/your/env');

Binaries are here : https://github.com/symfony/panther/tree/master/chromedriver-bin

smbat00 commented 11 months ago

On Laravel controller this code works corectly

$client = Client::createChromeClient(base_path("drivers/chromedriver"), null, ["port" => rand(1000, 9999)]); // create a chrome client

$crawler = $client->request('GET', $url);

but whenr I am trying to run it in Job, this error occurs Facebook\WebDriver\Exception\SessionNotCreatedException: session not created: Chrome failed to start: exited normally.

(session not created: DevToolsActivePort file doesn't exist)

(The process started from chrome location /opt/google/chrome/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) in