Browse Source

Fix #56: Ensure all locator objects are blessed correctly

George Baugh 1 year ago
parent
commit
fa97cc10d2
5 changed files with 8 additions and 4 deletions
  1. 1 0
      at/test.html
  2. 3 0
      conf/Changes
  3. 1 1
      dist.ini
  4. 2 0
      example.pl
  5. 1 3
      playwright_server

+ 1 - 0
at/test.html

@@ -35,6 +35,7 @@
         <br />
         <a href="other.html" target="_blank" id="linky" class="red">Test Link</a>
         <a href="../test.jpg" id="d-lo" download>Download</a>
+        <img src="../test.jpg" alt="picture" />
         <br />
         <iframe id="frame" src="other.html" />
     </body>

+ 3 - 0
conf/Changes

@@ -1,5 +1,8 @@
 Revision history for Playwright
 
+1.324 2023-04-18 TEODESIAN
+    - Ensure all PW methods returning Locator objects are correctly blessed
+
 1.323 2023-04-17 TEODESIAN
     - Ensure temporary files used for IPC by await() are cleaned out of /tmp.  Patch courtesy of Yanick Champoux.
     - Add experimental support for the locator API via Page->locator().

+ 1 - 1
dist.ini

@@ -1,5 +1,5 @@
 name = Playwright
-version = 1.323
+version = 1.324
 author = George S. Baugh <george@troglodyne.net>
 license = MIT
 copyright_holder = Troglodyne LLC

+ 2 - 0
example.pl

@@ -153,6 +153,8 @@ use Try::Tiny;
     my $loc = $page->locator('body');
     my $innerTubes = $loc->allInnerTexts();
     print Dumper($innerTubes);
+    my $image = $page->getByAltText('picture');
+    print Dumper($image);
 
     # Save a video now that we are done
     my $bideo = $page->video;

+ 1 - 3
playwright_server

@@ -203,8 +203,6 @@ app.post('/command', async (req, res) => {
                 }
             }
 
-            console.log("COMMAND RESULT:", commandResult);
-
             // XXX videos are special, we have to magic up a guid etc for them
             if (command == 'video' && commandResult) {
                 commandResult._guid = 'Video@' + uuidv4();
@@ -225,7 +223,7 @@ app.post('/command', async (req, res) => {
                 commandResult._guid = 'FetchResponse@' + uuidv4();
                 commandResult._type = 'FetchResponse';
             }
-            if (commandResult && type == 'Page' && command == 'locator') {
+            if (commandResult && spec[type].members[command].type.name == 'Locator') {
                 commandResult._guid = 'Locator@' + uuidv4();
                 commandResult._type = 'Locator';
             }