George S. Baugh пре 2 година
родитељ
комит
aca5a8f395
3 измењених фајлова са 10 додато и 6 уклоњено
  1. 3 2
      example.pl
  2. 4 0
      generate_perl_modules.pl
  3. 3 4
      lib/Playwright/Base.pm

+ 3 - 2
example.pl

@@ -2,9 +2,7 @@ use strict;
 use warnings;
 
 use Data::Dumper;
-
 use Playwright;
-
 use Try::Tiny;
 
 my $handle = Playwright->new( debug => 1 );
@@ -17,6 +15,9 @@ print "Browser PID: ".$process->{pid}."\n";
 # Open a tab therein
 my $page = $browser->newPage({ videosPath => 'video', acceptDownloads => 1 });
 
+# Test the spec method
+print Dumper($page->spec(),$page);
+
 # Browser contexts don't exist until you open at least one page.
 # You'll need this to grab and set cookies.
 my ($context) = @{$browser->contexts()};

+ 4 - 0
generate_perl_modules.pl

@@ -177,6 +177,10 @@ sub new {
 
 =cut
 
+sub spec {
+    return $Playwright::spec->{'%CLASSNAME%'}{members};
+}
+
 %SUBROUTINES%
 
 1;

+ 3 - 4
lib/Playwright/Base.pm

@@ -20,11 +20,11 @@ use feature qw{signatures};
 Base class for each Playwright class magic'd up by Sub::Install in Playwright's BEGIN block.
 You probably shouldn't use this.
 
-The specification for each class can be inspected with the 'spec' property:
+The specification for each class can be inspected with the 'spec' method:
 
     use Data::Dumper;
     my $object = Playwright::Base->new(...);
-    print Dumper($object->{spec});
+    print Dumper($object->spec());
 
 =head1 CONSTRUCTOR
 
@@ -45,7 +45,6 @@ sub new ( $class, %options ) {
 
     my $self = bless(
         {
-            spec   => $Playwright::spec->{ $options{type} }{members},
             type   => $options{type},
             guid   => $options{id},
             ua     => $options{handle}{ua},
@@ -88,7 +87,7 @@ sub _coerce ( $spec, %args ) {
 
 sub _api_request ( $self, %args ) {
 
-    %args = Playwright::Base::_coerce( $self->{spec}, %args );
+    %args = Playwright::Base::_coerce( $self->spec(), %args );
 
     return Playwright::Util::async( sub { &Playwright::Base::_do( $self, %args ) } )
       if $args{command} =~ m/^waitFor/;