Ver Fonte

update docs a bit

George S. Baugh há 5 anos atrás
pai
commit
83d3e4bb5d
4 ficheiros alterados com 16 adições e 40 exclusões
  1. 0 3
      bin/playwright.js
  2. 1 0
      example.pl
  3. 12 25
      lib/Playwright.pm
  4. 3 12
      lib/Playwright/Base.pm

+ 0 - 3
bin/playwright.js

@@ -88,9 +88,6 @@ app.post('/command', async (req, res) => {
 });
 
 app.get('/shutdown', async (req, res) => {
-    if (objects.browser) {
-        await objects.browser.close();
-    }
     res.json( { error: false, message : "Sent kill signal to browser" });
     process.exit(0);
 });

+ 1 - 0
example.pl

@@ -6,6 +6,7 @@ use JSON::PP;
 use Playwright;
 
 my $handle = Playwright->new();
+#TODO in the future, we should coerce based on the JSON spec
 my $browser = $handle->launch( headless => JSON::PP::false, type => 'chrome' );
 my $page = $browser->newPage();
 my $res = $page->goto('http://google.com', { waitUntil => 'networkidle' });

+ 12 - 25
lib/Playwright.pm

@@ -24,34 +24,23 @@ use feature qw{signatures state};
 
 =head2 SYNOPSIS
 
+    use JSON::PP;
     use Playwright;
-    my ($browser,$page) = Playwright->new( browser => "chrome" );
-    $page->goto('http://www.google.com');
-    my $browser_version = $browser->version();
-    $browser->quit();
+
+    my $handle = Playwright->new();
+    my $browser = $handle->launch( headless => JSON::PP::false, type => 'chrome' );
+    my $page = $browser->newPage();
+    my $res = $page->goto('http://google.com', { waitUntil => 'networkidle' });
+    my $frameset = $page->mainFrame();
+    my $kidframes = $frameset->childFrames();
 
 =head2 DESCRIPTION
 
 Perl interface to a lightweight node.js webserver that proxies commands runnable by Playwright.
-Currently understands commands you can send to the following Playwright classes,
-commands for which can be sent via instances of the noted module
-
-=over 4
-
-=item B<Browser> - L<Playwright> L<https://playwright.dev/#version=master&path=docs%2Fapi.md&q=class-browser>
-
-=item B<BrowserContext> - L<Playwright> L<https://playwright.dev/#version=master&path=docs%2Fapi.md&q=class-browsercontext>
-
-=item B<Page> - L<Playwright::Page> L<https://playwright.dev/#version=v1.5.1&path=docs%2Fapi.md&q=class-page>
-
-=item B<Response> - L<Playwright::Response> L<https://playwright.dev/#version=v1.5.1&path=docs%2Fapi.md&q=class-response>
-
-=back
-
-The specification for the above classes can also be inspected with the 'spec' method for each respective class:
+Currently understands commands you can send to all the playwright classes defined in api.json.
 
-    use Data::Dumper;
-    print Dumper($browser->spec , $page->spec, ...);
+See L<https://playwright.dev/#version=master&path=docs%2Fapi.md&q=>
+for what the classes do, and their usage.
 
 =head1 CONSTRUCTOR
 
@@ -61,9 +50,7 @@ Creates a new browser and returns a handle to interact with it.
 
 =head3 INPUT
 
-    browser (STRING) : Name of the browser to use.  One of (chrome, firefox, webkit).
-    visible (BOOL)   : Whether to start the browser such that it displays on your desktop (headless or not).
-    debug   (BOOL)   : Print extra messages from the Playwright server process
+    debug (BOOL) : Print extra messages from the Playwright server process
 
 =cut
 

+ 3 - 12
lib/Playwright/Base.pm

@@ -12,20 +12,12 @@ use Playwright::Util();
 no warnings 'experimental';
 use feature qw{signatures};
 
-=head2 SYNOPSIS
-
-    use Playwright;
-    my ($handle,$page) = Playwright->new( handle => "chrome" );
-    $page->goto('http://www.google.com');
-    my $handle_version = $handle->version();
-    $handle->quit();
-
 =head2 DESCRIPTION
 
-Base class for each Playwright class.
-You probably shouldn't use this directly; instead use a subclass.
+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 also be inspected with the 'spec' property:
+The specification for each class can be inspected with the 'spec' property:
 
     use Data::Dumper;
     my $object = Playwright::Base->new(...);
@@ -40,7 +32,6 @@ Creates a new page and returns a handle to interact with it.
 =head3 INPUT
 
     handle (Playwright) : Playwright object.
-    spec (HASHREF)      : Specification for the class to build.
     id (STRING)         : _guid returned by a response from the Playwright server with the provided type.
     type (STRING)       : Type to actually use