Corion / WWW-Mechanize-Chrome

automate the Chrome browser

Home Page:https://metacpan.org/release/WWW-Mechanize-Chrome

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't connect without knowing the port?! 0 at .../Chrome/DevToolsProtocol.pm line 317.

hakonhagland opened this issue · comments

With a running Chrome browser already open, when I run this program (Ubuntu 20.04, perl version 5.30, Chrome Version 89.0.4389.114 (Official Build) (64-bit)) :

use strict;
use warnings;
use Log::Log4perl qw(:easy);
use WWW::Mechanize::Chrome;
Log::Log4perl->easy_init($ERROR);
my $mech = WWW::Mechanize::Chrome->new(
    autoclose => 0,
    tab       => 'current',
);

the constructor WWW::Mechanize::Chrome->new() aborts with

Can't connect without knowing the port?! 0 at /home/hakon/perlbrew/perls/perl-5.30.0/lib/site_perl/5.30.0/Chrome/DevToolsProtocol.pm line 317.

See also this question on stackoverflow.

Some more information:

  • If I close google-chrome by clicking the close button in the upper right corner of each open chrome window, and then run the script again, the script is opening a new chrome window but then I get the same error.
  • If I instead choose "Exit" from the Chrome menu and then run the script again, I do not get the error.

So my guess is that there is some sort of chrome server still running in the first case, whereas in the second case the server is also shut down. And this is needed for the script to run properly ?

I am facing the same issue.