WWW::Mechanize::Chrome 当前选项卡上的自动化

Automation on current tab with WWW::Mechanize::Chrome

我正在尝试使用 WWW::Mechanize::Chrome 填写 Chrome 中 当前活动的 选项卡中的字段。总体目标是自动执行银行转帐中涉及的一些输入,因此无法打开新会话和导航到页面。

这就是我所在的位置 - 测试当前选项卡上的最低控制级别:

use Log::Log4perl qw(:easy);
use WWW::Mechanize::Chrome;
 
Log::Log4perl->easy_init($ERROR);

my $mech = WWW::Mechanize::Chrome->new(
                       launch_exe => '/usr/bin/google-chrome',
                       launch_arg => [ "--remote-debugging-port=9223" ],
                       autoclose => 0,
                       port => 9223,
                       tab => 'current',
                      );

$mech->get('https://www.reddit.com/r/perl');
$mech->eval_in_page('alert("Hello Chrome")');

my $png = $mech->content_as_png();

with Chrome 是这样开始的:

/usr/bin/google-chrome --remote-debugging-port=9223

然而,这实际上(在浏览器端)的作用是:

并在命令行上输出:

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

如果 Chromium 不是 运行,代码运行良好(打开 Chromium,导航到 reddit,提醒)。

文档说“将选项卡设置为 current 将改用当前的活动选项卡 - 但它似乎不起作用。

我做错了什么?

我在乐队外与 WWW::Mechanize::Chrome 的作者进行了快速交谈。他说您需要在启动要附加到的 Chrome 实例时设置远程调试端口。当它打开一个新的时,它会自动执行此操作。

--remote-debugging-port 9222

关于一直开机