File tree Expand file tree Collapse file tree 5 files changed +16
-7
lines changed
main/java/com/microsoft/playwright/impl
test/java/com/microsoft/playwright Expand file tree Collapse file tree 5 files changed +16
-7
lines changed Original file line number Diff line number Diff line change 2626import java .util .Base64 ;
2727import java .util .Map ;
2828
29+ import static com .microsoft .playwright .impl .LoggingSupport .isApiLoggingEnabled ;
2930import static com .microsoft .playwright .impl .LoggingSupport .logApi ;
3031import static com .microsoft .playwright .impl .Serialization .fromNameValues ;
3132import static com .microsoft .playwright .impl .Serialization .gson ;
@@ -66,7 +67,9 @@ void handle(Route route) {
6667 String action = response .get ("action" ).getAsString ();
6768 if ("redirect" .equals (action )) {
6869 String redirectURL = response .get ("redirectURL" ).getAsString ();
69- logApi ("HAR: " + route .request ().url () + " redirected to " + redirectURL );
70+ if (isApiLoggingEnabled ()) {
71+ logApi ("HAR: " + route .request ().url () + " redirected to " + redirectURL );
72+ }
7073 ((RouteImpl ) route ).redirectNavigationRequest (redirectURL );
7174 return ;
7275 }
@@ -83,7 +86,9 @@ void handle(Route route) {
8386 }
8487
8588 if ("error" .equals (action )) {
86- logApi ("HAR: " + response .get ("message" ).getAsString ());
89+ if (isApiLoggingEnabled ()) {
90+ logApi ("HAR: " + response .get ("message" ).getAsString ());
91+ }
8792 // Report the error, but fall through to the default handler.
8893 }
8994
Original file line number Diff line number Diff line change @@ -60,6 +60,10 @@ static void logWithTimestamp(String message) {
6060 System .err .println (timestamp + " " + message );
6161 }
6262
63+ static boolean isApiLoggingEnabled () {
64+ return isEnabled ;
65+ }
66+
6367 static void logApi (String message ) {
6468 // This matches log format produced by the server.
6569 logWithTimestamp ("pw:api " + message );
Original file line number Diff line number Diff line change @@ -39,9 +39,6 @@ private static class RouteInfo {
3939 }
4040
4141 boolean handle (RouteImpl route ) {
42- if (times != null && times <= 0 ) {
43- return false ;
44- }
4542 if (!matcher .test (route .request ().url ())) {
4643 return false ;
4744 }
Original file line number Diff line number Diff line change @@ -326,8 +326,7 @@ void shouldRoundTripHarWithPostData(@TempDir Path tmpDir) {
326326 assertEquals ("3" , page2 .evaluate (fetchFunction , "3" ));
327327 assertEquals ("3" , page2 .evaluate (fetchFunction , "3" ));
328328 try {
329- Object result = page2 .evaluate (fetchFunction , "4" );
330- System .out .println (result );
329+ page2 .evaluate (fetchFunction , "4" );
331330 fail ("did not throw" );
332331 } catch (PlaywrightException e ) {
333332 }
Original file line number Diff line number Diff line change @@ -133,10 +133,14 @@ void shouldFallBackAfterException() {
133133 @ Test
134134 void shouldChainOnce () {
135135 page .route ("**/empty.html" , route -> {
136+ System .out .println ("before fulfill" );
136137 route .fulfill (new Route .FulfillOptions ().setStatus (200 ).setBody ("fulfilled one" ));
138+ System .out .println ("after fulfill" );
137139 }, new Page .RouteOptions ().setTimes (1 ));
138140 page .route ("**/empty.html" , route -> {
141+ System .out .println ("before fallback" );
139142 route .fallback ();
143+ System .out .println ("after fallback" );
140144 }, new Page .RouteOptions ().setTimes (1 ));
141145 Response response = page .navigate (server .EMPTY_PAGE );
142146 assertEquals ("fulfilled one" , response .text ());
You can’t perform that action at this time.
0 commit comments