void () { CountDownLatch latch = new CountDownLatch(1); JBCefBrowser jbCefBrowser = new JBCefBrowser("http://maps.google.com"); // heavy page jbCefBrowser.setErrorPage(JBCefBrowserBase.ErrorPage.DEFAULT); jbCefBrowser.getJBCefClient().addLoadHandler(new CefLoadHandlerAdapter() { @Override public void onLoadStart(CefBrowser browser, CefFrame frame, CefRequest.TransitionType transitionType) { System.out.println("JBCefLoadHtmlTest.onLoadStarted: " + browser.getURL()); if (browser.getURL().contains("google")) { // cancel loading and start another one jbCefBrowser.getCefBrowser().stopLoad(); jbCefBrowser.loadURL("chrome:version"); } } @Override public void onLoadEnd(CefBrowser browser, CefFrame frame, int httpStatusCode) { System.out.println("JBCefLoadHtmlTest.onLoadEnd: " + browser.getURL()); if (frame.getURL().contains("version")) { latch.countDown(); } } @Override public void onLoadError(CefBrowser browser, CefFrame frame, ErrorCode errorCode, String errorText, String failedUrl) { System.out.println("JBCefLoadHtmlTest.onLoadError: " + browser.getURL()); } }, jbCefBrowser.getCefBrowser()); invokeAndWaitForLoad(jbCefBrowser, () -> { JFrame frame = new JFrame(JBCefLoadHtmlTest.class.getName()); frame.setSize(640, 480); frame.setLocationRelativeTo(null); frame.add(jbCefBrowser.getComponent()); frame.setVisible(true); }); await(latch); assertThat(jbCefBrowser.getCefBrowser().getURL()).contains("version"); }