feat: support wait until commit, roll driver (#687)

This commit is contained in:
Yury Semikhatsky 2021-11-02 13:07:56 -07:00 committed by GitHub
parent 49a54d7ee4
commit 2d0d941e18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 216 additions and 20 deletions

View File

@ -160,7 +160,7 @@ public class TestLocatorAssertions extends TestBase {
fail("did not throw");
} catch (AssertionFailedError e) {
assertEquals("[]", e.getExpected().getStringRepresentation());
assertEquals("null", e.getActual().getStringRepresentation());
assertEquals("[]", e.getActual().getStringRepresentation());
assertTrue(e.getMessage().contains("Locator expected not to have text"), e.getMessage());
}
}

View File

@ -813,6 +813,7 @@ public interface Frame {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public WaitUntilState waitUntil;
@ -841,6 +842,7 @@ public interface Frame {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public NavigateOptions setWaitUntil(WaitUntilState waitUntil) {
@ -1455,6 +1457,7 @@ public interface Frame {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public WaitUntilState waitUntil;
@ -1475,6 +1478,7 @@ public interface Frame {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public SetContentOptions setWaitUntil(WaitUntilState waitUntil) {
@ -1886,6 +1890,7 @@ public interface Frame {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public WaitUntilState waitUntil;
@ -1933,6 +1938,7 @@ public interface Frame {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public WaitForNavigationOptions setWaitUntil(WaitUntilState waitUntil) {
@ -2012,6 +2018,7 @@ public interface Frame {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public WaitUntilState waitUntil;
@ -2032,6 +2039,7 @@ public interface Frame {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public WaitForURLOptions setWaitUntil(WaitUntilState waitUntil) {

View File

@ -1147,6 +1147,7 @@ public interface Page extends AutoCloseable {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public WaitUntilState waitUntil;
@ -1167,6 +1168,7 @@ public interface Page extends AutoCloseable {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public GoBackOptions setWaitUntil(WaitUntilState waitUntil) {
@ -1188,6 +1190,7 @@ public interface Page extends AutoCloseable {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public WaitUntilState waitUntil;
@ -1208,6 +1211,7 @@ public interface Page extends AutoCloseable {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public GoForwardOptions setWaitUntil(WaitUntilState waitUntil) {
@ -1234,6 +1238,7 @@ public interface Page extends AutoCloseable {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public WaitUntilState waitUntil;
@ -1262,6 +1267,7 @@ public interface Page extends AutoCloseable {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public NavigateOptions setWaitUntil(WaitUntilState waitUntil) {
@ -1889,6 +1895,7 @@ public interface Page extends AutoCloseable {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public WaitUntilState waitUntil;
@ -1909,6 +1916,7 @@ public interface Page extends AutoCloseable {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public ReloadOptions setWaitUntil(WaitUntilState waitUntil) {
@ -2195,6 +2203,7 @@ public interface Page extends AutoCloseable {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public WaitUntilState waitUntil;
@ -2215,6 +2224,7 @@ public interface Page extends AutoCloseable {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public SetContentOptions setWaitUntil(WaitUntilState waitUntil) {
@ -2723,6 +2733,7 @@ public interface Page extends AutoCloseable {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public WaitUntilState waitUntil;
@ -2770,6 +2781,7 @@ public interface Page extends AutoCloseable {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public WaitForNavigationOptions setWaitUntil(WaitUntilState waitUntil) {
@ -2937,6 +2949,7 @@ public interface Page extends AutoCloseable {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public WaitUntilState waitUntil;
@ -2957,6 +2970,7 @@ public interface Page extends AutoCloseable {
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500} ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
public WaitForURLOptions setWaitUntil(WaitUntilState waitUntil) {
@ -4542,15 +4556,15 @@ public interface Page extends AutoCloseable {
*/
List<ElementHandle> querySelectorAll(String selector);
/**
* Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
* last redirect.
* This method reloads the current page, in the same way as if the user had triggered a browser refresh. Returns the main
* resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect.
*/
default Response reload() {
return reload(null);
}
/**
* Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
* last redirect.
* This method reloads the current page, in the same way as if the user had triggered a browser refresh. Returns the main
* resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect.
*/
Response reload(ReloadOptions options);
/**

View File

@ -31,7 +31,7 @@ import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import static com.microsoft.playwright.options.LoadState.*;
import static com.microsoft.playwright.options.WaitUntilState.*;
import static com.microsoft.playwright.impl.Serialization.*;
import static com.microsoft.playwright.impl.Utils.convertViaJson;
@ -40,7 +40,7 @@ public class FrameImpl extends ChannelOwner implements Frame {
private String url;
FrameImpl parentFrame;
Set<FrameImpl> childFrames = new LinkedHashSet<>();
private final Set<LoadState> loadStates = new HashSet<>();
private final Set<WaitUntilState> loadStates = new HashSet<>();
enum InternalEventType { NAVIGATED, LOADSTATE }
private final ListenerCollection<InternalEventType> internalListeners = new ListenerCollection<>();
@ -61,11 +61,12 @@ public class FrameImpl extends ChannelOwner implements Frame {
}
}
private static LoadState loadStateFromProtocol(String value) {
private static WaitUntilState loadStateFromProtocol(String value) {
switch (value) {
case "load": return LOAD;
case "domcontentloaded": return DOMCONTENTLOADED;
case "networkidle": return NETWORKIDLE;
case "commit": return COMMIT;
default: throw new PlaywrightException("Unexpected value: " + value);
}
}
@ -801,6 +802,10 @@ public class FrameImpl extends ChannelOwner implements Frame {
}
void waitForLoadStateImpl(LoadState state, WaitForLoadStateOptions options) {
waitForLoadStateImpl(convertViaJson(state, WaitUntilState.class), options);
}
private void waitForLoadStateImpl(WaitUntilState state, WaitForLoadStateOptions options) {
if (options == null) {
options = new WaitForLoadStateOptions();
}
@ -815,11 +820,11 @@ public class FrameImpl extends ChannelOwner implements Frame {
runUntil(() -> {}, new WaitableRace<>(waitables));
}
private class WaitForLoadStateHelper implements Waitable<Void>, Consumer<LoadState> {
private final LoadState expectedState;
private class WaitForLoadStateHelper implements Waitable<Void>, Consumer<WaitUntilState> {
private final WaitUntilState expectedState;
private boolean isDone;
WaitForLoadStateHelper(LoadState state) {
WaitForLoadStateHelper(WaitUntilState state) {
expectedState = state;
isDone = loadStates.contains(state);
if (!isDone) {
@ -828,7 +833,7 @@ public class FrameImpl extends ChannelOwner implements Frame {
}
@Override
public void accept(LoadState state) {
public void accept(WaitUntilState state) {
if (expectedState.equals(state)) {
isDone = true;
dispose();
@ -851,13 +856,13 @@ public class FrameImpl extends ChannelOwner implements Frame {
private class WaitForNavigationHelper implements Waitable<Response>, Consumer<JsonObject> {
private final UrlMatcher matcher;
private final LoadState expectedLoadState;
private final WaitUntilState expectedLoadState;
private WaitForLoadStateHelper loadStateHelper;
private RequestImpl request;
private RuntimeException exception;
WaitForNavigationHelper(UrlMatcher matcher, LoadState expectedLoadState) {
WaitForNavigationHelper(UrlMatcher matcher, WaitUntilState expectedLoadState) {
this.matcher = matcher;
this.expectedLoadState = expectedLoadState;
internalListeners.add(InternalEventType.NAVIGATED, this);
@ -935,7 +940,7 @@ public class FrameImpl extends ChannelOwner implements Frame {
if (matcher == null) {
matcher = UrlMatcher.forOneOf(page.context().baseUrl, options.url);
}
waitables.add(new WaitForNavigationHelper(matcher, convertViaJson(options.waitUntil, LoadState.class)));
waitables.add(new WaitForNavigationHelper(matcher, options.waitUntil));
waitables.add(page.createWaitForCloseHelper());
waitables.add(page.createWaitableFrameDetach(this));
waitables.add(page.createWaitableNavigationTimeout(options.timeout));
@ -1001,8 +1006,7 @@ public class FrameImpl extends ChannelOwner implements Frame {
options = new WaitForURLOptions();
}
if (matcher.test(url())) {
waitForLoadStateImpl(convertViaJson(options.waitUntil, LoadState.class),
convertViaJson(options, WaitForLoadStateOptions.class));
waitForLoadStateImpl(options.waitUntil, convertViaJson(options, WaitForLoadStateOptions.class));
return;
}
waitForNavigationImpl(() -> {}, convertViaJson(options, WaitForNavigationOptions.class), matcher);
@ -1012,7 +1016,7 @@ public class FrameImpl extends ChannelOwner implements Frame {
if ("loadstate".equals(event)) {
JsonElement add = params.get("add");
if (add != null) {
LoadState state = loadStateFromProtocol(add.getAsString());
WaitUntilState state = loadStateFromProtocol(add.getAsString());
loadStates.add(state);
internalListeners.notify(InternalEventType.LOADSTATE, state);
}

View File

@ -19,5 +19,6 @@ package com.microsoft.playwright.options;
public enum WaitUntilState {
LOAD,
DOMCONTENTLOADED,
NETWORKIDLE
NETWORKIDLE,
COMMIT
}

View File

@ -0,0 +1,124 @@
/*
* 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 com.microsoft.playwright.options.WaitUntilState;
import org.junit.jupiter.api.Test;
import static com.microsoft.playwright.options.WaitUntilState.COMMIT;
import static com.microsoft.playwright.options.WaitUntilState.DOMCONTENTLOADED;
import static org.junit.jupiter.api.Assertions.*;
public class TestPageSetContent extends TestBase {
private static final String expectedOutput = "<html><head></head><body><div>hello</div></body></html>";
@Test
void shouldWork() {
page.setContent("<div>hello</div>");
Object result = page.content();
assertEquals(expectedOutput, result);
}
@Test
void shouldWorkWithDomcontentloaded() {
page.setContent("<div>hello</div>", new Page.SetContentOptions().setWaitUntil(DOMCONTENTLOADED));
Object result = page.content();
assertEquals(expectedOutput, result);
}
@Test
void shouldWorkWithCommit() {
page.setContent("<div>hello</div>", new Page.SetContentOptions().setWaitUntil(COMMIT));
Object result = page.content();
assertEquals(expectedOutput, result);
}
@Test
void shouldWorkWithDoctype() {
String doctype = "<!DOCTYPE html>";
page.setContent(doctype + "<div>hello</div>");
Object result = page.content();
assertEquals(doctype + expectedOutput, result);
}
@Test
void shouldWorkWithHTML4Doctype() {
String doctype = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" " +
"\"http://www.w3.org/TR/html4/strict.dtd\">";
page.setContent(doctype + "<div>hello</div>");
Object result = page.content();
assertEquals(doctype + expectedOutput, result);
}
@Test
void shouldRespectTimeout() {
String imgPath = "/img.png";
// stall for image
server.setRoute(imgPath, exchange -> {});
try {
page.setContent("<img src='" + server.PREFIX + imgPath + "'></img>", new Page.SetContentOptions().setTimeout(100));
fail("did not throw");
} catch (TimeoutError e) {
}
}
@Test
void shouldRespectDefaultNavigationTimeout() {
page.setDefaultNavigationTimeout(100);
String imgPath = "/img.png";
// stall for image
server.setRoute(imgPath, exchange -> {});
try {
page.setContent("<img src='" + server.PREFIX + imgPath + "'></img>");
fail("did not throw");
} catch (TimeoutError e) {
assertTrue(e.getMessage().contains("Timeout 100ms exceeded."), e.getMessage());
}
}
@Test
void shouldWorkFastEnough() {
for (int i = 0; i < 20; ++i) {
page.setContent("<div>yo</div>");
}
}
@Test
void shouldWorkWithTrickyContent() {
page.setContent("<div>hello world</div>" + "\\x7F");
assertEquals("hello world", page.evalOnSelector("div", "div => div.textContent"));
}
@Test
void shouldWorkWithAccents() {
page.setContent("<div>aberración</div>");
assertEquals("aberración", page.evalOnSelector("div", "div => div.textContent"));
}
@Test
void shouldWorkWithEmojis() {
page.setContent("<div>🐥</div>");
assertEquals("🐥", page.evalOnSelector("div", "div => div.textContent"));
}
@Test
void shouldWorkWithNewline() {
page.setContent("<div>\n</div>");
assertEquals("\n", page.evalOnSelector("div", "div => div.textContent"));
}
}

View File

@ -19,12 +19,14 @@ package com.microsoft.playwright;
import com.microsoft.playwright.options.WaitUntilState;
import org.junit.jupiter.api.Test;
import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.regex.Pattern;
import static com.microsoft.playwright.Utils.expectedSSLError;
import static java.util.Collections.nCopies;
import static org.junit.jupiter.api.Assertions.*;
public class TestPageWaitForNavigation extends TestBase {
@ -54,6 +56,23 @@ public class TestPageWaitForNavigation extends TestBase {
void shouldWorkWithBothDomcontentloadedAndLoad() {
}
@Test
void shouldWorkWithCommit() {
server.setRoute("/empty.html", exchange -> {
exchange.getResponseHeaders().add("Content-Type", "text/html");
exchange.sendResponseHeaders(200, 8192);
OutputStreamWriter writer = new OutputStreamWriter(exchange.getResponseBody());
writer.write("<title>" + String.join("", nCopies(4100, "A")));
writer.flush();
});
page.waitForNavigation(new Page.WaitForNavigationOptions().setWaitUntil(WaitUntilState.COMMIT), () -> {
try {
page.navigate(server.EMPTY_PAGE, new Page.NavigateOptions().setTimeout(100));
} catch (TimeoutError e) {
}
});
}
@Test
void shouldWorkWithClickingOnAnchorLinks() {
page.navigate(server.EMPTY_PAGE);

View File

@ -19,6 +19,11 @@ package com.microsoft.playwright;
import com.microsoft.playwright.options.WaitUntilState;
import org.junit.jupiter.api.Test;
import java.io.OutputStreamWriter;
import java.util.Collections;
import java.util.concurrent.Semaphore;
import static java.util.Collections.nCopies;
import static org.junit.jupiter.api.Assertions.*;
public class TestPageWaitForUrl extends TestBase {
@ -47,6 +52,27 @@ public class TestPageWaitForUrl extends TestBase {
page.waitForURL("**/one-style.html", new Page.WaitForURLOptions().setWaitUntil(WaitUntilState.LOAD));
}
@Test
void shouldWorkWithCommit() {
server.setRoute("/empty.html", exchange -> {
exchange.getResponseHeaders().add("Content-Type", "text/html");
exchange.sendResponseHeaders(200, 8192);
OutputStreamWriter writer = new OutputStreamWriter(exchange.getResponseBody());
writer.write("<title>" + String.join("", nCopies(4100, "A")));
writer.flush();
});
try {
page.navigate(server.EMPTY_PAGE, new Page.NavigateOptions().setTimeout(100));
} catch (TimeoutError e) {
}
page.waitForURL("**/empty.html", new Page.WaitForURLOptions().setWaitUntil(WaitUntilState.COMMIT));
}
@Test
void shouldWorkWithCommitAndAboutBlank() {
page.waitForURL("about:blank", new Page.WaitForURLOptions().setWaitUntil(WaitUntilState.COMMIT));
}
@Test
void shouldWorkWithClickingOnAnchorLinks() {
page.navigate(server.EMPTY_PAGE);

View File

@ -1 +1 @@
1.17.0-next-1635526444000
1.17.0-next-1635811939000