|
@@ -5,6 +5,10 @@ use warnings;
|
|
|
|
|
|
|
|
use sigtrap qw/die normal-signals/;
|
|
use sigtrap qw/die normal-signals/;
|
|
|
|
|
|
|
|
|
|
+require Exporter;
|
|
|
|
|
+our @ISA = qw(Exporter);
|
|
|
|
|
+our @EXPORT_OK = qw(await);
|
|
|
|
|
+
|
|
|
use File::Basename();
|
|
use File::Basename();
|
|
|
use Cwd();
|
|
use Cwd();
|
|
|
use LWP::UserAgent();
|
|
use LWP::UserAgent();
|
|
@@ -151,7 +155,6 @@ BEGIN {
|
|
|
next if grep { $_ eq $method } qw{keyboard mouse};
|
|
next if grep { $_ eq $method } qw{keyboard mouse};
|
|
|
my $renamed = exists $methods_to_rename{$method} ? $methods_to_rename{$method} : $method;
|
|
my $renamed = exists $methods_to_rename{$method} ? $methods_to_rename{$method} : $method;
|
|
|
|
|
|
|
|
- print "Installing sub $renamed into Playwright::$class\n";
|
|
|
|
|
Sub::Install::install_sub({
|
|
Sub::Install::install_sub({
|
|
|
code => sub {
|
|
code => sub {
|
|
|
my $self = shift;
|
|
my $self = shift;
|
|
@@ -201,6 +204,19 @@ sub launch ($self, %args) {
|
|
|
return $msg;
|
|
return $msg;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+=head2 await (Playwright::Promise) = MIXED
|
|
|
|
|
+
|
|
|
|
|
+Waits for an asynchronous operation returned by the waitFor* methods to complete and returns the value.
|
|
|
|
|
+
|
|
|
|
|
+=cut
|
|
|
|
|
+
|
|
|
|
|
+sub await ($self, $promise) {
|
|
|
|
|
+ confess("Input must be an AsyncData") unless $promise->isa('AsyncData');
|
|
|
|
|
+ my $obj = $promise->result(1);
|
|
|
|
|
+ my $class = "Playwright::$obj->{_type}";
|
|
|
|
|
+ return $class->new( type => $obj->{_type}, id => $obj->{_guid}, handle => $self );
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
=head2 quit, DESTROY
|
|
=head2 quit, DESTROY
|
|
|
|
|
|
|
|
Terminate the browser session and wait for the Playwright server to terminate.
|
|
Terminate the browser session and wait for the Playwright server to terminate.
|