Corion / WWW-Mechanize-Chrome

automate the Chrome browser
https://metacpan.org/release/WWW-Mechanize-Chrome
Artistic License 2.0
30 stars 12 forks source link

Could not find node with given id #71

Closed cmadamsgit closed 11 months ago

cmadamsgit commented 1 year ago

I am having trouble with some websites, getting this error when getting almost any information:

Could not find node with given id                                               

-32000 at /home/cmadams/perl5/lib/perl5/Chrome/DevToolsProtocol/Target.pm line 5
04

It seems somewhat hit or miss (so maybe some kind of timing issue/race condition?) and varies based on the site. For example, with Amazon, adding a sleep allows $mech->base to work, but still $mech->links fails.

Here's my test code:

#!/usr/bin/perl

use Modern::Perl;
use WWW::Mechanize::Chrome;
use Log::Log4perl qw(:easy);

Log::Log4perl->easy_init ($WARN);
my $mech = WWW::Mechanize::Chrome->new (
    launch_exe => "/usr/bin/chromium-browser",
);

eval {
        $mech->get ("https://amazon.com/");
        $mech->sleep (1);
        print $mech->base, "\n";
        print $_->text . " -> " . $_->url . "\n" for $mech->links;
};
print $@ if ($@);
$mech->target->send_message ("Browser.close")->get;
sleep (1);
cmadamsgit commented 1 year ago

And sorry, meant to add: this is on Fedora Linux 37 with perl 5.36.1, WWW::Mechanize::Perl 0.70, and Chromium 114.0.5735.198.