|
31 | 31 | import java.util.regex.Pattern; |
32 | 32 |
|
33 | 33 | import static com.microsoft.playwright.impl.Serialization.gson; |
| 34 | +import static com.microsoft.playwright.impl.Serialization.parseError; |
34 | 35 | import static com.microsoft.playwright.impl.Utils.*; |
35 | 36 | import static com.microsoft.playwright.options.ScreenshotType.JPEG; |
36 | 37 | import static com.microsoft.playwright.options.ScreenshotType.PNG; |
@@ -567,6 +568,17 @@ public List<ElementHandle> querySelectorAll(String selector) { |
567 | 568 | return mainFrame.querySelectorAll(selector); |
568 | 569 | } |
569 | 570 |
|
| 571 | + @Override |
| 572 | + public List<Request> requests() { |
| 573 | + JsonObject json = sendMessage("requests", new JsonObject(), NO_TIMEOUT).getAsJsonObject(); |
| 574 | + JsonArray requests = json.getAsJsonArray("requests"); |
| 575 | + List<Request> result = new ArrayList<>(); |
| 576 | + for (JsonElement item : requests) { |
| 577 | + result.add(connection.getExistingObject(item.getAsJsonObject().get("guid").getAsString())); |
| 578 | + } |
| 579 | + return result; |
| 580 | + } |
| 581 | + |
570 | 582 | @Override |
571 | 583 | public void addLocatorHandler(Locator locator, Consumer<Locator> handler, AddLocatorHandlerOptions options) { |
572 | 584 | LocatorImpl locatorImpl = (LocatorImpl) locator; |
@@ -983,6 +995,29 @@ public Keyboard keyboard() { |
983 | 995 | return keyboard; |
984 | 996 | } |
985 | 997 |
|
| 998 | + @Override |
| 999 | + public List<ConsoleMessage> consoleMessages() { |
| 1000 | + JsonObject json = sendMessage("consoleMessages", new JsonObject(), NO_TIMEOUT).getAsJsonObject(); |
| 1001 | + JsonArray messages = json.getAsJsonArray("messages"); |
| 1002 | + List<ConsoleMessage> result = new ArrayList<>(); |
| 1003 | + for (JsonElement item : messages) { |
| 1004 | + result.add(new ConsoleMessageImpl(connection, item.getAsJsonObject(), this)); |
| 1005 | + } |
| 1006 | + return result; |
| 1007 | + } |
| 1008 | + |
| 1009 | + @Override |
| 1010 | + public List<String> pageErrors() { |
| 1011 | + JsonObject json = sendMessage("pageErrors", new JsonObject(), NO_TIMEOUT).getAsJsonObject(); |
| 1012 | + JsonArray errors = json.getAsJsonArray("errors"); |
| 1013 | + List<String> result = new ArrayList<>(); |
| 1014 | + for (JsonElement item : errors) { |
| 1015 | + String errorStr = parseError(item.getAsJsonObject()); |
| 1016 | + result.add(errorStr); |
| 1017 | + } |
| 1018 | + return result; |
| 1019 | + } |
| 1020 | + |
986 | 1021 | @Override |
987 | 1022 | public Locator locator(String selector, LocatorOptions options) { |
988 | 1023 | return mainFrame.locator(selector, convertType(options, Frame.LocatorOptions.class)); |
|
0 commit comments