Note: Advice in this article will only work for JxBrowser 6. See the corresponding article for JxBrowser 7 here.(注意:本文中的建议仅适用于JxBrowser6,JxBrowser7相应文章请点击这里。)
In some cases (e.g. automation testing) you might need to block current thread execution and wait until web page is loaded completely. JxBrowser API provides functionality that allows doing it. The following sample code demonstrates how to load http://www.google.com web page and wait until it's loaded completely: (在某些情况下(例如自动化测试),您可能需要阻止当前线程执行,然后等到网页完全加载完毕。 JxBrowser API提供了允许执行此操作的功能。以下示例代码演示了如何加载http://www.google.com网页并等待其完全加载:)
// Blocks current thread execution and waits until http://www.google.com web page is loaded completely Browser.invokeAndWaitFinishLoadingMainFrame(browser, new Callback<Browser>() { @Override public void invoke(Browser value) { value.loadURL("http://www.google.com"); } });
Note: use this method for loading web pages only.(注意:使用此方法仅加载网页。)