diff --git a/playwright/src/test/java/com/microsoft/playwright/TestPageNetworkRequest.java b/playwright/src/test/java/com/microsoft/playwright/TestPageNetworkRequest.java index 27a29347..c1699393 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestPageNetworkRequest.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestPageNetworkRequest.java @@ -24,7 +24,7 @@ import java.util.*; import java.util.concurrent.Semaphore; import java.util.stream.Collectors; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; public class TestPageNetworkRequest extends TestBase { @Test diff --git a/playwright/src/test/java/com/microsoft/playwright/TestPageRequestContinue.java b/playwright/src/test/java/com/microsoft/playwright/TestPageRequestContinue.java new file mode 100644 index 00000000..5543f6d7 --- /dev/null +++ b/playwright/src/test/java/com/microsoft/playwright/TestPageRequestContinue.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.playwright; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +public class TestPageRequestContinue extends TestBase { + @Test + void shouldNotThrowWhenContinuingAfterPageIsClosed() { + boolean[] done = {false}; + page.route("**/*", route -> { + page.close(); + route.resume(); + done[0] = true; + }); + try { + page.navigate(server.EMPTY_PAGE); + fail("did not throw"); + } catch (PlaywrightException e) { + assertTrue(e.getMessage().contains("Navigation failed because page was closed") || + e.getMessage().contains("frame was detached"), e.getMessage()); + } + assertTrue(done[0]); + } +}