Răsfoiți Sursa

Fix #9: needed special handling

George S. Baugh 5 ani în urmă
părinte
comite
8dd8a264dd
5 a modificat fișierele cu 18 adăugiri și 0 ștergeri
  1. 1 0
      at/test.html
  2. 5 0
      bin/playwright.js
  3. 7 0
      example.pl
  4. 2 0
      lib/Playwright.pm
  5. 3 0
      lib/Playwright/Base.pm

+ 1 - 0
at/test.html

@@ -26,6 +26,7 @@
             <input id="radio1" name="radio2" type="radio"></input>
             <input id="radio2" name="radio2" type="radio" checked></input>
             <input id="hammertime" type="submit" disabled></input>
+            <input id="drphil" type="file"></input>
             <input id="hidon" type="hidden"></input>
         </form>
         <br />

+ 5 - 0
bin/playwright.js

@@ -112,6 +112,11 @@ app.post('/command', async (req, res) => {
                 res._guid = 'Video@' + uuidv4();
                 res._type = 'Video';
             }
+            // XXX So are FileChooser object unfortunately
+            if (args[0] == 'filechooser' && res) {
+                res._guid = 'FileChooser@' + uuidv4();
+                res._type = 'FileChooser';
+            }
 
             if (res && res._guid) {
                 objects[res._guid] = res;

+ 7 - 0
example.pl

@@ -105,3 +105,10 @@ $page->select('#d-lo')->click();
 
 my $download = $handle->await( $promise );
 $download->saveAs('test2.jpg');
+
+# Fiddle with file inputs
+my $choochoo = $page->waitForEvent('filechooser');
+$page->select('#drphil')->click();
+my $chooseu = $handle->await( $choochoo );
+$chooseu->setFiles('test.jpg');
+

+ 2 - 0
lib/Playwright.pm

@@ -220,6 +220,8 @@ Waits for an asynchronous operation returned by the waitFor* methods to complete
 sub await ($self, $promise) {
     confess("Input must be an AsyncData") unless $promise->isa('AsyncData');
     my $obj = $promise->result(1);
+    use Data::Dumper;
+    print Dumper($obj);
     my $class = "Playwright::$obj->{_type}";
     return $obj unless $class;
     return $class->new( type => $obj->{_type}, id => $obj->{_guid}, handle => $self ); 

+ 3 - 0
lib/Playwright/Base.pm

@@ -64,6 +64,9 @@ sub _request ($self, %args) {
 
     my $msg = Playwright::Base::_do->($self,%args);
 
+    use Data::Dumper;
+    print Dumper($msg);
+
     if (ref $msg eq 'ARRAY') {
         @$msg = map {
             my $subject = $_;